1
This commit is contained in:
@@ -44,6 +44,12 @@ const app = new Vue({
|
||||
console.log('框架版本:', AdminFramework.version)
|
||||
console.log('配置信息:', this.$config)
|
||||
|
||||
// 设置系统标题
|
||||
await this.$store.dispatch('app/getSysTitle', {
|
||||
defaultTitle: this.$config.title,
|
||||
defaultLogo: ''
|
||||
})
|
||||
|
||||
// 刷新时恢复菜单
|
||||
const token = this.$store.state.user.token
|
||||
const authorityMenus = localStorage.getItem('authorityMenus')
|
||||
|
||||
@@ -25,7 +25,14 @@ export default {
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async getSysTitle({ state, commit, rootState }, { defaultTitle = '智能代码平台', defaultLogo = '' }) {
|
||||
async getSysTitle({ state, commit, rootState }, { defaultTitle, defaultLogo = '' } = {}) {
|
||||
// 如果没有传入 defaultTitle,尝试从 Vue 实例的配置中获取
|
||||
if (!defaultTitle && window.rootVue && window.rootVue.$config) {
|
||||
defaultTitle = window.rootVue.$config.title || '智能代码平台'
|
||||
} else if (!defaultTitle) {
|
||||
defaultTitle = '智能代码平台'
|
||||
}
|
||||
|
||||
let formModel = {
|
||||
title: defaultTitle,
|
||||
logoUrl: defaultLogo
|
||||
@@ -37,22 +44,31 @@ export default {
|
||||
if (token) {
|
||||
// 已登录,尝试从后端获取系统标题
|
||||
try {
|
||||
console.log('开始获取系统标题...')
|
||||
let res1 = await paramSetupServer.getOne('sys_title')
|
||||
if (res1 && res1.data) {
|
||||
console.log('获取系统标题返回:', res1)
|
||||
|
||||
if (res1 && res1.code === 0 && res1.data && res1.data.value) {
|
||||
formModel.title = res1.data.value
|
||||
document.title = res1.data.value
|
||||
console.log('系统标题已更新为:', res1.data.value)
|
||||
} else {
|
||||
console.warn('后端未返回有效的系统标题,使用默认标题:', defaultTitle)
|
||||
document.title = formModel.title
|
||||
}
|
||||
|
||||
let res2 = await paramSetupServer.getOne('sys_logo')
|
||||
if (res2 && res2.data) {
|
||||
if (res2 && res2.code === 0 && res2.data && res2.data.value) {
|
||||
formModel.logoUrl = res2.data.value
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('获取系统标题失败,使用默认标题:', error || '接口调用失败')
|
||||
console.warn('获取系统标题失败,使用默认标题:', error.message || error)
|
||||
// 使用默认标题
|
||||
document.title = formModel.title
|
||||
}
|
||||
} else {
|
||||
// 未登录,直接使用默认标题
|
||||
console.log('未登录,使用默认标题:', defaultTitle)
|
||||
document.title = formModel.title
|
||||
}
|
||||
|
||||
|
||||
@@ -165,6 +165,9 @@ export default {
|
||||
menuIds
|
||||
})
|
||||
|
||||
// 登录成功后获取系统标题
|
||||
await dispatch('app/getSysTitle', {}, { root: true })
|
||||
|
||||
return res
|
||||
} catch (error) {
|
||||
console.error('登录失败:', error)
|
||||
|
||||
Reference in New Issue
Block a user