2023-05-24 11:08:08 +08:00
|
|
|
|
<template>
|
|
|
|
|
<a-config-provider :locale="locale">
|
|
|
|
|
<router-view />
|
|
|
|
|
<global-setting />
|
|
|
|
|
</a-config-provider>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2023-07-28 16:34:32 +08:00
|
|
|
|
import { computed, onBeforeMount } from 'vue';
|
2023-05-24 11:08:08 +08:00
|
|
|
|
import enUS from '@arco-design/web-vue/es/locale/lang/en-us';
|
|
|
|
|
import zhCN from '@arco-design/web-vue/es/locale/lang/zh-cn';
|
2023-06-08 14:28:53 +08:00
|
|
|
|
import GlobalSetting from '@/components/pure/global-setting/index.vue';
|
2023-05-24 11:08:08 +08:00
|
|
|
|
import useLocale from '@/locale/useLocale';
|
2023-07-28 16:34:32 +08:00
|
|
|
|
import { saveBaseInfo, getBaseInfo } from '@/api/modules/setting/config';
|
|
|
|
|
import { getLocalStorage, setLocalStorage } from '@/utils/local-storage';
|
2023-08-02 14:18:24 +08:00
|
|
|
|
import useAppStore from '@/store/modules/app';
|
2023-08-18 15:55:25 +08:00
|
|
|
|
import useLicenseStore from '@/store/modules/setting/license';
|
2023-08-08 16:28:44 +08:00
|
|
|
|
import { watchStyle, watchTheme, setFavicon } from '@/utils/theme';
|
|
|
|
|
import { GetPlatformIconUrl } from '@/api/requrls/setting/config';
|
2023-08-02 14:18:24 +08:00
|
|
|
|
|
|
|
|
|
const appStore = useAppStore();
|
2023-08-18 15:55:25 +08:00
|
|
|
|
const licenseStore = useLicenseStore();
|
2023-05-24 11:08:08 +08:00
|
|
|
|
|
|
|
|
|
const { currentLocale } = useLocale();
|
|
|
|
|
const locale = computed(() => {
|
|
|
|
|
switch (currentLocale.value) {
|
|
|
|
|
case 'zh-CN':
|
|
|
|
|
return zhCN;
|
|
|
|
|
case 'en-US':
|
|
|
|
|
return enUS;
|
|
|
|
|
default:
|
|
|
|
|
return zhCN;
|
|
|
|
|
}
|
|
|
|
|
});
|
2023-07-28 16:34:32 +08:00
|
|
|
|
|
2023-08-07 13:47:04 +08:00
|
|
|
|
// 初始化平台风格和主题色
|
|
|
|
|
watchStyle(appStore.pageConfig.style, appStore.pageConfig);
|
|
|
|
|
watchTheme(appStore.pageConfig.theme, appStore.pageConfig);
|
|
|
|
|
window.document.title = appStore.pageConfig.title;
|
2023-08-08 16:28:44 +08:00
|
|
|
|
setFavicon(GetPlatformIconUrl);
|
2023-08-07 13:47:04 +08:00
|
|
|
|
|
2023-07-28 16:34:32 +08:00
|
|
|
|
onBeforeMount(async () => {
|
|
|
|
|
try {
|
2023-08-02 14:18:24 +08:00
|
|
|
|
appStore.initSystemversion(); // 初始化系统版本
|
|
|
|
|
appStore.initPageConfig(); // 初始化页面配置
|
2023-08-18 15:55:25 +08:00
|
|
|
|
licenseStore.getValidateLicense(); // 初始化校验license
|
2023-08-02 14:18:24 +08:00
|
|
|
|
// 项目初始化时需要获取基础设置信息,看当前站点 url是否为系统内置默认地址,如果是需要替换为当前项目部署的 url 地址
|
2023-07-28 16:34:32 +08:00
|
|
|
|
const isInitUrl = getLocalStorage('isInitUrl'); // 是否已经初始化过 url
|
|
|
|
|
if (isInitUrl === 'true') return;
|
|
|
|
|
const res = await getBaseInfo();
|
|
|
|
|
if (res.url === 'http://127.0.0.1:8081') {
|
|
|
|
|
await saveBaseInfo([
|
|
|
|
|
{
|
|
|
|
|
paramKey: 'base.url',
|
|
|
|
|
paramValue: window.location.origin,
|
|
|
|
|
type: 'string',
|
|
|
|
|
},
|
|
|
|
|
]);
|
|
|
|
|
setLocalStorage('isInitUrl', 'true'); // 设置已经初始化过 url,避免重复初始化
|
2023-08-09 10:07:00 +08:00
|
|
|
|
} else {
|
|
|
|
|
setLocalStorage('isInitUrl', 'true'); // 设置已经初始化过 url,避免重复初始化
|
2023-07-28 16:34:32 +08:00
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
}
|
|
|
|
|
});
|
2023-05-24 11:08:08 +08:00
|
|
|
|
</script>
|