App.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <script setup lang="ts">
  2. import { computed } from 'vue';
  3. import { NConfigProvider, darkTheme } from 'naive-ui';
  4. import type { WatermarkProps } from 'naive-ui';
  5. import { useAppStore } from './store/modules/app';
  6. import { useThemeStore } from './store/modules/theme';
  7. import { naiveDateLocales, naiveLocales } from './locales/naive';
  8. defineOptions({
  9. name: 'App'
  10. });
  11. const appStore = useAppStore();
  12. const themeStore = useThemeStore();
  13. const naiveDarkTheme = computed(() => (themeStore.darkMode ? darkTheme : undefined));
  14. const naiveLocale = computed(() => {
  15. return naiveLocales[appStore.locale];
  16. });
  17. const naiveDateLocale = computed(() => {
  18. return naiveDateLocales[appStore.locale];
  19. });
  20. const watermarkProps = computed<WatermarkProps>(() => {
  21. return {
  22. content: themeStore.watermarkContent,
  23. cross: true,
  24. fullscreen: true,
  25. fontSize: 16,
  26. lineHeight: 16,
  27. width: 384,
  28. height: 384,
  29. xOffset: 12,
  30. yOffset: 60,
  31. rotate: -15,
  32. zIndex: 9999
  33. };
  34. });
  35. </script>
  36. <template>
  37. <NConfigProvider
  38. :theme="naiveDarkTheme"
  39. :theme-overrides="themeStore.naiveTheme"
  40. :locale="naiveLocale"
  41. :date-locale="naiveDateLocale"
  42. class="h-full"
  43. >
  44. <AppProvider>
  45. <RouterView class="bg-layout" />
  46. <NWatermark v-if="themeStore.watermark.visible" v-bind="watermarkProps" />
  47. </AppProvider>
  48. </NConfigProvider>
  49. </template>
  50. <style scoped></style>