app.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <script lang="ts" setup>
  2. import { computed } from 'vue';
  3. import { useNaiveDesignTokens } from '@vben/hooks';
  4. import { preferences } from '@vben/preferences';
  5. import {
  6. darkTheme,
  7. dateEnUS,
  8. dateZhCN,
  9. enUS,
  10. GlobalThemeOverrides,
  11. lightTheme,
  12. zhCN,
  13. } from 'naive-ui';
  14. defineOptions({ name: 'App' });
  15. const { commonTokens } = useNaiveDesignTokens();
  16. const tokenLocale = computed(() =>
  17. preferences.app.locale === 'zh-CN' ? zhCN : enUS,
  18. );
  19. const tokenDateLocale = computed(() =>
  20. preferences.app.locale === 'zh-CN' ? dateZhCN : dateEnUS,
  21. );
  22. const tokenTheme = computed(() =>
  23. preferences.theme.mode === 'dark' ? darkTheme : lightTheme,
  24. );
  25. const themeOverrides = computed((): GlobalThemeOverrides => {
  26. return {
  27. common: commonTokens,
  28. };
  29. });
  30. </script>
  31. <template>
  32. <NConfigProvider
  33. :date-locale="tokenDateLocale"
  34. :locale="tokenLocale"
  35. :theme="tokenTheme"
  36. :theme-overrides="themeOverrides"
  37. class="h-full"
  38. >
  39. <NNotificationProvider>
  40. <NMessageProvider>
  41. <RouterView />
  42. </NMessageProvider>
  43. </NNotificationProvider>
  44. </NConfigProvider>
  45. </template>