feat: 添加 vue-sonner,优化反馈

This commit is contained in:
2026-05-23 14:37:53 +08:00
parent 7d68db723b
commit e317e117d9
9 changed files with 141 additions and 12 deletions
+20
View File
@@ -0,0 +1,20 @@
// app/stores/global.ts - 全局通用状态(主题等),持久化由 @nuxtjs/color-mode 统一管理(localStorage/cookie
export const useGlobalStore = defineStore("theme", () => {
// useColorMode 会自动读写持久化存储,class 也由其挂到 <html>
const colorMode = useColorMode();
/** 当前是否深色模式 */
const isDark = computed(() => colorMode.value === "dark");
/** 切换深色 / 浅色 */
const toggle = () => {
colorMode.value = isDark.value ? "light" : "dark";
};
/** vue-sonner Toaster 的 theme prop 值,跟随当前模式 */
const toasterTheme = computed<"light" | "dark">(() =>
isDark.value ? "dark" : "light"
);
return { isDark, toggle, toasterTheme };
});