feat: 添加 vue-sonner,优化反馈
This commit is contained in:
@@ -12,14 +12,10 @@ import {
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
import { useGlobalStore } from "@/stores/global";
|
||||
|
||||
/** 使用 VueUse 的 useColorMode 切换 dark/light,class 会挂到 <html> 上 */
|
||||
const colorMode = useColorMode();
|
||||
const isDark = computed(() => colorMode.value === "dark");
|
||||
|
||||
const toggleColorMode = () => {
|
||||
colorMode.value = isDark.value ? "light" : "dark";
|
||||
};
|
||||
/** 主题状态由 themeStore 统一管理,持久化由 @nuxtjs/color-mode 处理 */
|
||||
const themeStore = useGlobalStore();
|
||||
|
||||
const authStore = useAuthStore();
|
||||
|
||||
@@ -45,6 +41,7 @@ const isActive = (to: string) => {
|
||||
return route.path.startsWith(to);
|
||||
};
|
||||
|
||||
// 退出登录
|
||||
const handleSignOut = async () => {
|
||||
await authStore.signOut();
|
||||
await navigateTo("/login");
|
||||
@@ -93,9 +90,9 @@ const handleSignOut = async () => {
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
aria-label="切换主题"
|
||||
@click="toggleColorMode"
|
||||
@click="themeStore.toggle"
|
||||
>
|
||||
<Sun v-if="isDark" class="size-4" />
|
||||
<Sun v-if="themeStore.isDark" class="size-4" />
|
||||
<Moon v-else class="size-4" />
|
||||
</Button>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user