This commit is contained in:
张成
2025-10-08 19:20:24 +08:00
parent 845658f193
commit 7e888970d3
11 changed files with 1726 additions and 68 deletions

View File

@@ -9,22 +9,21 @@
</template>
<script>
import { mapGetters } from 'vuex'
import Terminal from './terminal.vue'
import asyncModal from '@/components/asyncModal'
export default {
components: {
Terminal
Terminal,
asyncModal
},
computed: {
...mapGetters({
isServerRun: 'isServerRun'
}),
iconclass() {
let curClass = 'terminal-icon ml10 '
if (this.isServerRun) {
curClass += ' run'
}
let curClass = 'terminal-icon ml10'
// Terminal 功能暂时禁用
// if (this.isServerRun) {
// curClass += ' run'
// }
return curClass
}
},

View File

@@ -20,9 +20,10 @@ export default {
},
mounted() {},
computed: {
...mapGetters({
infoMsg: 'infoMsg'
})
infoMsg() {
// Terminal 功能暂时禁用
return '终端功能暂未启用'
}
},
watch: {
@@ -34,10 +35,12 @@ export default {
},
methods: {
clearLog() {
this.$store.commit('clearInfoMsg')
// Terminal 功能暂时禁用
this.$Message.info('终端功能暂未启用')
},
reloadLog() {
this.$store.dispatch('setInteverLog')
// Terminal 功能暂时禁用
this.$Message.info('终端功能暂未启用')
},
scrollEnd() {
setTimeout(() => {

View File

@@ -88,7 +88,8 @@ export default {
},
methods: {
async init() {
await this.$store.dispatch('getSysTitle')
// 获取系统标题(已在 main.js 中调用,这里不需要重复调用)
// await this.$store.dispatch('app/getSysTitle')
},
collpasedChange(collapsed) {
this.collapsed = collapsed

View File

@@ -156,8 +156,8 @@ class AdminFramework {
// 如果提供了 VueRouter自动创建 Router
if (VueRouter && !this.router) {
// 获取主路由配置(包含 home
const mainRoute = this.getRoutes({ Main, ParentView, Page404, HomePage })
// 获取主路由配置(从后端权限菜单生成
const mainRoute = this.getRoutes({ Main, ParentView, Page404 })
this.router = this.createRouter(VueRouter, {
Main,
@@ -259,14 +259,14 @@ class AdminFramework {
* @returns {Object} 主路由配置
*/
getRoutes(components = {}) {
const { Main, ParentView, Page404, HomePage } = components
const { Main, ParentView, Page404 } = components
if (!Main || !ParentView || !Page404) {
console.error('Missing required layout components')
return null
}
return uiTool.getRoutes(Main, ParentView, Page404, HomePage)
return uiTool.getRoutes(Main, ParentView, Page404)
}
/**

View File

@@ -25,25 +25,34 @@ export default {
}
},
actions: {
async getSysTitle({ state, commit }, { defaultTitle = '智能代码平台', defaultLogo = '' }) {
async getSysTitle({ state, commit, rootState }, { defaultTitle = '智能代码平台', defaultLogo = '' }) {
let formModel = {
title: defaultTitle,
logoUrl: defaultLogo
}
try {
let res1 = await paramSetupServer.getOne('sys_title')
if (res1 && res1.data) {
formModel.title = res1.data.value
document.title = res1.data.value
// 检查是否已登录(有 token
const token = rootState.user.token
if (token) {
// 已登录,尝试从后端获取系统标题
try {
let res1 = await paramSetupServer.getOne('sys_title')
if (res1 && res1.data) {
formModel.title = res1.data.value
document.title = res1.data.value
}
let res2 = await paramSetupServer.getOne('sys_logo')
if (res2 && res2.data) {
formModel.logoUrl = res2.data.value
}
} catch (error) {
console.warn('获取系统标题失败,使用默认标题:', error || '接口调用失败')
// 使用默认标题
document.title = formModel.title
}
let res2 = await paramSetupServer.getOne('sys_logo')
if (res2 && res2.data) {
formModel.logoUrl = res2.data.value
}
} catch (error) {
console.warn('获取系统标题失败,使用默认标题:', error || '接口调用失败')
// 使用默认标题
} else {
// 未登录,直接使用默认标题
document.title = formModel.title
}

View File

@@ -168,26 +168,17 @@ export default class uiTool {
return []
}
static getRoutes(Main, ParentView, Page404, HomePage) {
static getRoutes(Main, ParentView, Page404) {
let mainRoute = {
path: '/',
name: '主视图',
redirect: '/home',
component: Main,
meta: { title: '首页', notCache: true },
children: [
// 默认 home 路由,确保登录后能跳转
{
path: '/home',
name: 'home',
meta: { title: '首页', notCache: true },
component: HomePage || {
render: h => h('div', { style: { padding: '20px' } }, '欢迎使用管理系统')
}
}
]
children: []
}
// 从 localStorage 读取权限菜单
if (
localStorage.authorityMenus &&
localStorage.authorityMenus !== 'undefined'
@@ -198,17 +189,8 @@ export default class uiTool {
let menus = uiTool.transformTree(authorityMenus)
let curRoutes = uiTool.menuToRoute(menus, ParentView, Page404)
// 合并权限路由,保留默认 home 路由
const homeRoute = mainRoute.children.find(r => r.name === 'home')
const hasHome = curRoutes.some(r => r.name === 'home')
if (hasHome) {
// 如果权限路由中有 home使用权限路由的 home
mainRoute.children = curRoutes
} else {
// 如果权限路由中没有 home保留默认 home 并添加其他路由
mainRoute.children = [homeRoute, ...curRoutes]
}
// 使用后端返回的路由(包括首页)
mainRoute.children = curRoutes
}
}