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

41 lines
890 B
Vue
Raw Normal View History

2024-05-19 13:20:42 +00:00
<script lang="ts" setup>
2024-06-08 11:49:06 +00:00
import { computed } from 'vue';
2024-05-19 13:20:42 +00:00
import { GlobalProvider } from '@vben/common-ui';
import { preferences, usePreferences } from '@vben/preferences';
2024-06-01 15:15:29 +00:00
2024-06-21 16:25:13 +00:00
import { App, ConfigProvider, theme } from 'ant-design-vue';
2024-06-08 11:49:06 +00:00
import { antdLocale } from '#/locales';
2024-05-19 13:20:42 +00:00
defineOptions({ name: 'App' });
2024-06-01 15:15:29 +00:00
const { isDark } = usePreferences();
2024-05-19 13:20:42 +00:00
const tokenTheme = computed(() => {
2024-06-21 16:25:13 +00:00
const algorithm = isDark.value
2024-05-19 13:20:42 +00:00
? [theme.darkAlgorithm]
: [theme.defaultAlgorithm];
// antd 紧凑模式算法
2024-06-01 15:15:29 +00:00
if (preferences.app.compact) {
2024-06-21 16:25:13 +00:00
algorithm.push(theme.compactAlgorithm);
2024-05-19 13:20:42 +00:00
}
2024-06-21 16:25:13 +00:00
2024-05-19 13:20:42 +00:00
return {
2024-06-21 16:25:13 +00:00
algorithm,
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="antdLocale" :theme="tokenTheme">
2024-06-21 16:25:13 +00:00
<App>
<RouterView />
</App>
2024-05-19 13:20:42 +00:00
</ConfigProvider>
</GlobalProvider>
</template>