feat(config): 添加自定义首页配置并优化导航功能

-增加自定义首页配置项,支持设置不同的首页组件
-优化导航功能,添加固定首页到导航栏
- 重构路由生成逻辑,支持自定义签到页和首页
- 更新组件以适应新的导航结构
This commit is contained in:
aixianling
2024-12-23 14:19:00 +08:00
parent 9ff89c19f3
commit b7c0350134
5 changed files with 17 additions and 13 deletions

View File

@@ -39,11 +39,14 @@ const createRoutes = (config = {}) => {
const routes = []
// 获取签到页面的路径,如果未指定,则使用默认路径
let signPage = '../views/sign'
let {signPage: sign, homePage: home = "console"} = config.extra || {}
if (config.extra?.signPage) {
const sign = config.extra.signPage
signPage = `../apps/custom/${sign}/${sign}`
}
let homePage = `../views/console`
if (config.extra?.homePage) {
homePage = `../apps/custom/${home}/${home}`
}
// 查找并处理所有应用,将它们的信息添加到路由中
return findApp("src/apps", app => getAppInfo(app, routes)).then(() => {
// 生成并输出apps.js文件定义所有应用的路由
@@ -52,7 +55,8 @@ const createRoutes = (config = {}) => {
{path: '/dv', name: '数据大屏入口', component: () => import('../views/dvIndex')},
{path: '/v', name: 'Home', component: () => import('../views/home'), children: [
{path:'/',name:'mainEntry', component:()=>import('../views/mainEntry'),children:[
${routes.map(e => {
{name: "工作台", path: "${home}", component: () => import('${homePage}')},
${routes.filter(e => ![sign, home].includes(e.name)).map(e => {
// 解构每个路由的属性,用于生成路由配置
const {name, label, esm} = e
// 生成单个路由配置的字符串表示