| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <template>
- <StyleProvider hash-priority="high" :transformers="[legacyLogicalPropertiesTransformer]">
- <ConfigProvider :locale="getAntdLocale" :theme="getTheme">
- <AppProvider prefixCls="jeesite">
- <RouterView />
- </AppProvider>
- </ConfigProvider>
- </StyleProvider>
- </template>
- <script lang="ts" setup>
- import { computed, onMounted, unref, watch } from 'vue';
- import { StyleProvider, legacyLogicalPropertiesTransformer, ConfigProvider, theme } from 'ant-design-vue';
- import { authorizationInfoApi } from '@/core/api/sys/login';
- import { AppProvider } from '@/core/components/Application';
- import { useRootSetting } from '@/core/hooks/setting/useRootSetting';
- import { useUserStore } from '@/core/store/modules/case';
- import { ThemeEnum } from '@/core/enums/appEnum';
- import { useLocale } from '@/core/locales/useLocale';
- import { useTitle } from '@/core/hooks/web/useTitle';
- import { useWatermark } from '@/core/hooks/web/useWatermark';
- import { extractAuthorizationCache } from '@/core/utils/license';
- import { darkPrimaryColor } from '@build/theme/themeConfig';
- import 'dayjs/locale/zh-cn';
- // support Multi-language
- const { getAntdLocale } = useLocale();
- const { getDarkMode, getThemeColor } = useRootSetting();
- const userStore = useUserStore();
- const { setWatermark, clear } = useWatermark();
- const authorizationUnit = computed(() => String(userStore.getPageCacheByKey('authorizationUnit', '') || '').trim());
- const getTheme = computed(() => {
- const isDark = unref(getDarkMode) === ThemeEnum.DARK;
- return {
- algorithm: isDark ? theme.darkAlgorithm : theme.defaultAlgorithm,
- token: {
- colorPrimary: isDark ? darkPrimaryColor : unref(getThemeColor),
- colorLink: isDark ? darkPrimaryColor : unref(getThemeColor),
- colorInfo: isDark ? darkPrimaryColor : unref(getThemeColor),
- borderRadius: 6,
- },
- };
- });
- // Listening to page changes and dynamically changing site titles
- useTitle();
- async function ensureAuthorizationUnit() {
- if (unref(authorizationUnit)) return;
- try {
- const res = await authorizationInfoApi();
- const { authorizationUnit: unit } = extractAuthorizationCache(res);
- userStore.setPageCache('authorizationUnit', unit);
- } catch {
- clear();
- }
- }
- watch(
- authorizationUnit,
- (unit) => {
- if (!unit) {
- clear();
- return;
- }
- setWatermark(unit);
- },
- { immediate: true },
- );
- onMounted(() => {
- void ensureAuthorizationUnit();
- });
- </script>
- <style lang="less">
- body {
- line-height: 1.5715;
- font-family:
- -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif,
- 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
- }
- </style>
|