提交 408c7c72 authored 作者: 王鹏飞's avatar 王鹏飞

chore: update

上级 40e3ffa1
<script setup> <script setup>
import { useHead } from '@unhead/vue' import { useHead } from '@unhead/vue'
import { useUserStore } from '@/stores/user'
import { useAppConfig } from '@/composables/useAppConfig' import { useAppConfig } from '@/composables/useAppConfig'
const appConfig = useAppConfig() const userStore = useUserStore()
const appConfig = computed(() => useAppConfig(userStore.user?.mobile))
useHead({ useHead(() => ({
title: appConfig.title, title: appConfig.value.title,
link: [ link: [
{ {
rel: 'icon', rel: 'icon',
key: 'favicon', key: 'favicon',
href: appConfig.favicon || '/images/favicon.ico', href: appConfig.value.favicon || '/images/favicon.ico',
}, },
], ],
}) }))
const className = computed(() => { const className = computed(() => {
return `system-${appConfig.system || 'default'}` return `system-${appConfig.value.system || 'default'}`
}) })
</script> </script>
......
...@@ -9,7 +9,8 @@ import { useUserStore } from '@/stores/user' ...@@ -9,7 +9,8 @@ import { useUserStore } from '@/stores/user'
import { useMenuStore } from '@/stores/menu' import { useMenuStore } from '@/stores/menu'
import { useAppConfig } from '@/composables/useAppConfig' import { useAppConfig } from '@/composables/useAppConfig'
import { urls } from '@/utils/env' import { urls } from '@/utils/env'
const appConfig = useAppConfig() const userStore = useUserStore()
const appConfig = computed(() => useAppConfig(userStore.user?.mobile))
const route = useRoute() const route = useRoute()
const router = useRouter() const router = useRouter()
...@@ -17,13 +18,12 @@ const mobileMenuVisible = ref(false) ...@@ -17,13 +18,12 @@ const mobileMenuVisible = ref(false)
const toggleMobileMenu = () => { mobileMenuVisible.value = !mobileMenuVisible.value } const toggleMobileMenu = () => { mobileMenuVisible.value = !mobileMenuVisible.value }
const closeMobileMenu = () => { mobileMenuVisible.value = false } const closeMobileMenu = () => { mobileMenuVisible.value = false }
const userStore = useUserStore()
const userInfo = userStore.user const userInfo = userStore.user
const menuStore = useMenuStore() const menuStore = useMenuStore()
const menus = $computed(() => { const menus = $computed(() => {
// 大赛系统隐藏学生端、教师端的菜单 // 大赛系统隐藏学生端、教师端的菜单
if (appConfig.system === 'game' && userStore.role?.id !== 6) { if (appConfig.value.system === 'game' && userStore.role?.id !== 6) {
return [] return []
} else { } else {
return menuStore.menus return menuStore.menus
...@@ -46,7 +46,7 @@ const defaultActive = computed(() => { ...@@ -46,7 +46,7 @@ const defaultActive = computed(() => {
}) })
const logout = async () => { const logout = async () => {
await userStore.logout() await userStore.logout()
location.href = `${appConfig.loginURL || urls.login}?rd=${encodeURIComponent(location.origin)}` location.href = `${appConfig.value.loginURL || urls.login}?rd=${encodeURIComponent(location.origin)}`
} }
function isUrl(path: string) { function isUrl(path: string) {
......
import { urls } from '@/utils/env' import { urls } from '@/utils/env'
export function useAppConfig() { const appConfigList = [
const appConfigList = [
{ {
system: 'dml', system: 'dml',
title: '数字技能实践教学平台', title: '数字技能实践教学平台',
...@@ -168,10 +167,12 @@ export function useAppConfig() { ...@@ -168,10 +167,12 @@ export function useAppConfig() {
homeUrl: '/student/lab/competition', homeUrl: '/student/lab/competition',
liveMonitor: true, liveMonitor: true,
}, },
] ]
// 长春金专大赛支持 // 长春金专大赛支持
const digitalFinanceMarketingMobiles = new Set(['15526552767', '18345542466', '14743833355', '18946639603']) const digitalFinanceMarketingMobiles = new Set(['15526552767', '18345542466', '14743833355', '18946639603'])
export function useAppConfig(mobile?: string) {
// 如果定义了 VITE_SYSTEM,直接用;否则通过域名 hosts 匹配 // 如果定义了 VITE_SYSTEM,直接用;否则通过域名 hosts 匹配
const found = import.meta.env.VITE_SYSTEM const found = import.meta.env.VITE_SYSTEM
? appConfigList.find((item) => item.system === import.meta.env.VITE_SYSTEM) || appConfigList[0] ? appConfigList.find((item) => item.system === import.meta.env.VITE_SYSTEM) || appConfigList[0]
...@@ -182,13 +183,9 @@ export function useAppConfig() { ...@@ -182,13 +183,9 @@ export function useAppConfig() {
const appConfig = found || appConfigList[0] const appConfig = found || appConfigList[0]
const config = { ...appConfig } const config = { ...appConfig }
const user = localStorage.getItem('user') if (mobile && digitalFinanceMarketingMobiles.has(mobile)) {
if (user) {
const userInfo = JSON.parse(user)
if (userInfo?.mobile && digitalFinanceMarketingMobiles.has(userInfo.mobile)) {
config.title = '数字金融营销平台' config.title = '数字金融营销平台'
} }
}
return config return config
} }
...@@ -40,13 +40,11 @@ export const useUserStore = defineStore('user', { ...@@ -40,13 +40,11 @@ export const useUserStore = defineStore('user', {
this.project = project this.project = project
this.roles = roles this.roles = roles
this.permissions = permissions this.permissions = permissions
localStorage.setItem('user', JSON.stringify(info))
await useMapStore().getMapList() await useMapStore().getMapList()
}, },
async logout() { async logout() {
await logout() await logout()
this.user = null this.user = null
localStorage.removeItem('user')
}, },
}, },
}) })
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论