提交 40e3ffa1 authored 作者: 王鹏飞's avatar 王鹏飞

feat: 更新useAppConfig函数,支持从localStorage获取用户信息并动态配置应用标题

上级 2279cb6c
import { urls } from '@/utils/env' import { urls } from '@/utils/env'
import { useUserStore } from '@/stores/user'
export function useAppConfig(hasUser = true) { export function useAppConfig() {
const appConfigList = [ const appConfigList = [
{ {
system: 'dml', system: 'dml',
...@@ -183,9 +182,10 @@ export function useAppConfig(hasUser = true) { ...@@ -183,9 +182,10 @@ export function useAppConfig(hasUser = true) {
const appConfig = found || appConfigList[0] const appConfig = found || appConfigList[0]
const config = { ...appConfig } const config = { ...appConfig }
if (hasUser) { const user = localStorage.getItem('user')
const mobile = useUserStore().user?.mobile if (user) {
if (mobile && digitalFinanceMarketingMobiles.has(mobile)) { const userInfo = JSON.parse(user)
if (userInfo?.mobile && digitalFinanceMarketingMobiles.has(userInfo.mobile)) {
config.title = '数字金融营销平台' config.title = '数字金融营销平台'
} }
} }
......
...@@ -40,11 +40,13 @@ export const useUserStore = defineStore('user', { ...@@ -40,11 +40,13 @@ 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')
}, },
}, },
}) })
...@@ -3,7 +3,7 @@ import { ElMessage } from 'element-plus' ...@@ -3,7 +3,7 @@ import { ElMessage } from 'element-plus'
import router from '@/router' import router from '@/router'
import { useAppConfig } from '@/composables/useAppConfig' import { useAppConfig } from '@/composables/useAppConfig'
import { urls } from '@/utils/env' import { urls } from '@/utils/env'
const appConfig = useAppConfig(false) const appConfig = useAppConfig()
const httpRequest = axios.create({ const httpRequest = axios.create({
withCredentials: true, withCredentials: true,
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论