Files
art-design/src/App.vue
T
2025-07-24 17:28:51 +08:00

117 lines
2.8 KiB
Vue

<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)
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 备份
}
}
const locales = {
zh: zh,
en: en
}
onBeforeMount(() => {
setThemeTransitionClass(true)
setCompanyFromUrl()
})
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>
<style>
.boxshadow {
border-radius: 8px;
box-shadow: 0 2px 12px 0 rgba(0, 10, 118, 0.1);
background: var(--art-main-bg-color);
padding: 10px;
margin-bottom: 10px;
}
.border {
width: 6px;
height: 22px;
border-radius: 3px;
background: #3471FF;
display: inline-block;
vertical-align: bottom;
}
.el-dialog {
position: relative;
overflow: hidden;
}
.el-dialog::before {
content: '';
position: absolute;
inset: 0;
z-index: 0;
background: linear-gradient(180deg, #E4ECFF 0%, #FFFFFF 50%);
pointer-events: none;
}
.el-dialog__header,
.el-dialog__body,
.el-dialog__footer {
background: transparent !important;
position: relative;
z-index: 1;
}
.el-dialog__header {
display: flex;
align-items: center;
justify-content: center;
position: relative;
padding-right: 40px;
}
.el-dialog__title {
flex: 1;
text-align: center;
font-size: 18px;
font-weight: bold;
}
.el-dialog__headerbtn {
position: absolute;
right: 16px;
top: 50%;
transform: translateY(-50%);
}
</style>