2025-07-04 17:16:38 +08:00
|
|
|
<template>
|
|
|
|
|
<ElConfigProvider size="default" :locale="locales[language]" :z-index="3000">
|
|
|
|
|
<RouterView></RouterView>
|
|
|
|
|
</ElConfigProvider>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { useUserStore } from './store/modules/user'
|
|
|
|
|
import zh from 'element-plus/es/locale/lang/zh-cn'
|
|
|
|
|
import en from 'element-plus/es/locale/lang/en'
|
|
|
|
|
import { systemUpgrade } from './utils/sys'
|
|
|
|
|
import { UserService } from './api/usersApi'
|
|
|
|
|
import { setThemeTransitionClass } from './utils/theme/animation'
|
|
|
|
|
import { checkStorageCompatibility } from './utils/storage'
|
|
|
|
|
|
|
|
|
|
const userStore = useUserStore()
|
|
|
|
|
const { language } = storeToRefs(userStore)
|
2025-07-14 17:59:02 +08:00
|
|
|
function setCompanyFromUrl() {
|
|
|
|
|
const userStore = useUserStore()
|
|
|
|
|
const params = new URLSearchParams(window.location.search)
|
|
|
|
|
const companyid = params.get('corp_id')
|
|
|
|
|
const companyabbr = params.get('corp_abbr')
|
|
|
|
|
if (companyid) {
|
|
|
|
|
userStore.setCompany(companyid, companyabbr || '')
|
|
|
|
|
// 你也可以加 localStorage/sessionStorage 备份
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-07-04 17:16:38 +08:00
|
|
|
const locales = {
|
|
|
|
|
zh: zh,
|
|
|
|
|
en: en
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onBeforeMount(() => {
|
|
|
|
|
setThemeTransitionClass(true)
|
2025-07-14 17:59:02 +08:00
|
|
|
setCompanyFromUrl()
|
2025-07-11 18:37:16 +08:00
|
|
|
useUserStore().restoreTokenTimer()
|
2025-07-04 17:16:38 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
// 检查存储兼容性
|
|
|
|
|
checkStorageCompatibility()
|
|
|
|
|
// 提升暗黑主题下页面刷新视觉体验
|
|
|
|
|
setThemeTransitionClass(false)
|
|
|
|
|
// 系统升级
|
|
|
|
|
systemUpgrade()
|
|
|
|
|
// 获取用户信息
|
|
|
|
|
getUserInfo()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 获取用户信息
|
|
|
|
|
const getUserInfo = async () => {
|
|
|
|
|
if (userStore.isLogin) {
|
|
|
|
|
try {
|
|
|
|
|
const data = await UserService.getUserInfo()
|
|
|
|
|
userStore.setUserInfo(data)
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('获取用户信息失败', error)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|