App.vue 813 B

1234567891011121314151617181920212223242526272829
  1. <template>
  2. <el-config-provider :locale="appStore.locale" :size="appStore.size">
  3. <router-view />
  4. </el-config-provider>
  5. </template>
  6. <script setup lang="ts">
  7. import { useSettingsStore } from '@/store/modules/settings';
  8. import { handleThemeStyle } from '@/utils/theme';
  9. import { useAppStore } from '@/store/modules/app';
  10. const appStore = useAppStore();
  11. onMounted(() => {
  12. nextTick(() => {
  13. try {
  14. // 初始化主题样式,添加错误处理
  15. const settingsStore = useSettingsStore();
  16. const theme = settingsStore.theme;
  17. console.log('初始化主题:', theme);
  18. handleThemeStyle(theme);
  19. } catch (error) {
  20. console.warn('主题初始化失败,使用默认主题:', error);
  21. // 使用默认主题色
  22. handleThemeStyle('#409EFF');
  23. }
  24. });
  25. });
  26. </script>