app.vue 1.1 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 { Login } from '#/components/login';
  7. import { antdLocale } from '#/locales';
  8. import { useLoginModalStore } from '#/store';
  9. defineOptions({ name: 'App' });
  10. const { isDark } = usePreferences();
  11. const { tokens } = useAntdDesignTokens();
  12. const loginModalStore = useLoginModalStore();
  13. const tokenTheme = computed(() => {
  14. const algorithm = isDark.value
  15. ? [theme.darkAlgorithm]
  16. : [theme.defaultAlgorithm];
  17. // antd 紧凑模式算法
  18. if (preferences.app.compact) {
  19. algorithm.push(theme.compactAlgorithm);
  20. }
  21. return {
  22. algorithm,
  23. token: tokens,
  24. };
  25. });
  26. function handleSubmit(_values: any) {
  27. loginModalStore.close();
  28. }
  29. </script>
  30. <template>
  31. <ConfigProvider :locale="antdLocale" :theme="tokenTheme">
  32. <App>
  33. <RouterView />
  34. </App>
  35. <Login v-model:open="loginModalStore.isOpen" @submit="handleSubmit" />
  36. </ConfigProvider>
  37. </template>