feat: 项目加载优化
This commit is contained in:
@@ -1,10 +1,22 @@
|
||||
import type { RouteRecordRaw } from 'vue-router';
|
||||
|
||||
// 预加载辅助函数
|
||||
function preloadComponent(importFn: () => Promise<any>) {
|
||||
return () => {
|
||||
// 在开发环境下直接返回
|
||||
if (import.meta.env.DEV) {
|
||||
return importFn();
|
||||
}
|
||||
// 生产环境下可以添加缓存逻辑
|
||||
return importFn();
|
||||
};
|
||||
}
|
||||
|
||||
// LayoutRouter[布局路由]
|
||||
export const layoutRouter: RouteRecordRaw[] = [
|
||||
{
|
||||
path: '/',
|
||||
component: () => import('@/layouts/index.vue'),
|
||||
component: preloadComponent(() => import('@/layouts/index.vue')),
|
||||
children: [
|
||||
// 将首页重定向逻辑放在这里
|
||||
{
|
||||
@@ -17,16 +29,12 @@ export const layoutRouter: RouteRecordRaw[] = [
|
||||
path: 'chat',
|
||||
name: 'chat',
|
||||
component: () => import('@/pages/chat/index.vue'),
|
||||
redirect: '/chat/conversation',
|
||||
meta: {
|
||||
title: 'AI应用',
|
||||
icon: 'HomeFilled',
|
||||
},
|
||||
children: [
|
||||
// chat 根路径重定向到 conversation
|
||||
{
|
||||
path: '',
|
||||
redirect: '/chat/conversation',
|
||||
},
|
||||
{
|
||||
path: 'conversation',
|
||||
name: 'chatConversation',
|
||||
@@ -140,17 +148,13 @@ export const layoutRouter: RouteRecordRaw[] = [
|
||||
path: 'console',
|
||||
name: 'console',
|
||||
component: () => import('@/pages/console/index.vue'),
|
||||
redirect: '/console/user',
|
||||
meta: {
|
||||
title: '意心Ai-控制台',
|
||||
icon: 'Setting',
|
||||
layout: 'default',
|
||||
},
|
||||
children: [
|
||||
// console 根路径重定向到 user
|
||||
{
|
||||
path: '',
|
||||
redirect: '/console/user',
|
||||
},
|
||||
{
|
||||
path: 'user',
|
||||
name: 'consoleUser',
|
||||
@@ -244,8 +248,18 @@ export const layoutRouter: RouteRecordRaw[] = [
|
||||
],
|
||||
},
|
||||
];
|
||||
// staticRouter[静态路由] 预留
|
||||
export const staticRouter: RouteRecordRaw[] = [];
|
||||
// staticRouter[静态路由]
|
||||
export const staticRouter: RouteRecordRaw[] = [
|
||||
// FontAwesome 测试页面
|
||||
{
|
||||
path: '/test/fontawesome',
|
||||
name: 'testFontAwesome',
|
||||
component: () => import('@/pages/test/fontawesome.vue'),
|
||||
meta: {
|
||||
title: 'FontAwesome图标测试',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
// errorRouter (错误页面路由)
|
||||
export const errorRouter = [
|
||||
|
||||
Reference in New Issue
Block a user