admin-vben/apps/web-antd/src/app.vue

41 lines
953 B
Vue
Raw Normal View History

2024-05-19 13:20:42 +00:00
<script lang="ts" setup>
import 'dayjs/locale/zh-cn';
2024-06-01 15:15:29 +00:00
import { preferences, usePreferences } from '@vben-core/preferences';
2024-05-19 13:20:42 +00:00
import { GlobalProvider } from '@vben/common-ui';
import { ConfigProvider, theme } from 'ant-design-vue';
import zhCN from 'ant-design-vue/es/locale/zh_CN';
import dayjs from 'dayjs';
import { computed } from 'vue';
defineOptions({ name: 'App' });
dayjs.locale(zhCN.locale);
2024-06-01 15:15:29 +00:00
const { isDark } = usePreferences();
2024-05-19 13:20:42 +00:00
const tokenTheme = computed(() => {
const algorithms = isDark.value
? [theme.darkAlgorithm]
: [theme.defaultAlgorithm];
// antd 紧凑模式算法
2024-06-01 15:15:29 +00:00
if (preferences.app.compact) {
2024-05-19 13:20:42 +00:00
algorithms.push(theme.compactAlgorithm);
}
return {
algorithms,
2024-06-01 15:15:29 +00:00
token: { colorPrimary: preferences.theme.colorPrimary },
2024-05-19 13:20:42 +00:00
};
});
</script>
<template>
<GlobalProvider>
<ConfigProvider :locale="zhCN" :theme="tokenTheme">
<RouterView />
</ConfigProvider>
</GlobalProvider>
</template>