app.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <script lang="ts" setup>
  2. import { computed } from 'vue';
  3. import { useAntdDesignTokens } from '@velofex/hooks';
  4. import { preferences, usePreferences } from '@velofex/preferences';
  5. import { App, ConfigProvider, theme } from 'antdv-next';
  6. import { antdLocale } from '#/locales';
  7. defineOptions({ name: 'App' });
  8. const { isDark } = usePreferences();
  9. const { tokens } = useAntdDesignTokens();
  10. const antFontFamily =
  11. "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'";
  12. const tokenTheme = computed(() => {
  13. const algorithm = isDark.value
  14. ? [theme.darkAlgorithm]
  15. : [theme.defaultAlgorithm];
  16. // antd 紧凑模式算法
  17. if (preferences.app.compact) {
  18. algorithm.push(theme.compactAlgorithm);
  19. }
  20. return {
  21. algorithm,
  22. token: {
  23. ...tokens,
  24. fontFamily: antFontFamily,
  25. fontSize: 14,
  26. lineHeight: 22 / 14,
  27. },
  28. };
  29. });
  30. </script>
  31. <template>
  32. <ConfigProvider :locale="antdLocale" :theme="tokenTheme">
  33. <App>
  34. <RouterView />
  35. </App>
  36. </ConfigProvider>
  37. </template>