frontend: add dark mode support

This commit is contained in:
2026-01-03 12:48:25 +08:00
parent 827c9198ae
commit f46c2a039b
11 changed files with 710 additions and 166 deletions
+13 -2
View File
@@ -5,14 +5,25 @@
</template>
<script setup>
import { onMounted } from 'vue'
import { onMounted, computed } from 'vue'
import { ConfigProvider as AConfigProvider } from 'ant-design-vue'
import zhCN from 'ant-design-vue/es/locale/zh_CN'
import { useAuthStore } from '@/stores/auth'
import antdTheme from './antd-theme'
import getAntdTheme from './antd-theme'
import { useTheme, initTheme, watchSystemTheme } from '@/composables/useTheme'
const authStore = useAuthStore()
// 初始化主题(全局)
initTheme()
watchSystemTheme()
// 使用主题
const { isDark } = useTheme()
// 动态生成 Ant Design 主题
const antdTheme = computed(() => getAntdTheme(isDark.value))
// 应用启动时验证 Token
onMounted(async () => {
if (authStore.isAuthenticated) {