From 910992e1928d6b584d1fc34d60543aba0682277d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=88=90?= Date: Thu, 9 Oct 2025 18:43:34 +0800 Subject: [PATCH] 1 --- src/store/user.js | 6 ++++-- src/utils/uiTool.js | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/store/user.js b/src/store/user.js index d387b32..e8d5c50 100644 --- a/src/store/user.js +++ b/src/store/user.js @@ -94,8 +94,10 @@ export default { // 保存权限菜单 commit('setAuthorityMenus', JSON.stringify(menus)) - // 生成路由菜单 - let mainMenu = uiTool.getRoutes(Main, ParentView, Page404) + // 生成路由菜单(传递 HomePage 组件) + // 从框架导出的组件中获取 HomePage + const HomePage = window.framework && window.framework.HomePage ? window.framework.HomePage : null + let mainMenu = uiTool.getRoutes(Main, ParentView, Page404, HomePage) console.log('生成的主菜单:', mainMenu) if (mainMenu && mainMenu.children) { diff --git a/src/utils/uiTool.js b/src/utils/uiTool.js index 4ec9ef0..789d673 100644 --- a/src/utils/uiTool.js +++ b/src/utils/uiTool.js @@ -214,6 +214,39 @@ export default class uiTool { } static getRoutes(Main, ParentView, Page404, HomePage) { + // 如果没有传入 HomePage,使用默认的欢迎页面 + const defaultHomePage = { + render: h => h('div', { + style: { + padding: '20px', + display: 'flex', + justifyContent: 'center', + alignItems: 'center', + height: 'calc(100vh - 200px)' + } + }, [ + h('div', { + style: { + textAlign: 'center' + } + }, [ + h('h1', { + style: { + fontSize: '30px', + color: '#2d8cf0', + marginBottom: '20px' + } + }, '欢迎使用管理系统'), + h('p', { + style: { + fontSize: '16px', + color: '#666' + } + }, '请从左侧菜单选择功能模块') + ]) + ]) + } + let mainRoute = { path: '/', name: '主视图', @@ -224,10 +257,9 @@ export default class uiTool { { path: '/home', name: '首页', - component: HomePage, + component: HomePage || defaultHomePage, meta: { title: '首页', notCache: true } } - ] }