Commit 642400f0 by Lin

feat: 微前端项目打包构建配置修改

1 parent aba1cf3b
// 此文件由 auto-routes 插件自动生成,请勿手动编辑
// 如需自定义路由,请在 vite.config.ts 中配置 customRules
// 生成时间: 2026/1/22 14:14:23
// 生成时间: 2026/1/23 10:58:16
import type { RouteRecordRaw } from 'vue-router';
......@@ -10,7 +10,7 @@ export const autoRoutes: RouteRecordRaw[] = [
id: "assistant",
title: "Assistant",
icon: "",
level: 0,
level: 1,
hidden: false,
meta: {
"authority": "assistant",
......@@ -41,7 +41,7 @@ export const autoRoutes: RouteRecordRaw[] = [
id: "manage-agentic",
title: "ManageAgentic",
icon: "",
level: 0,
level: 1,
hidden: false,
meta: {
"authority": "manage-agentic",
......@@ -55,7 +55,7 @@ export const autoRoutes: RouteRecordRaw[] = [
id: "manage-konw",
title: "ManageKonw",
icon: "",
level: 0,
level: 1,
hidden: false,
meta: {
"authority": "manage-konw",
......
import type { Router, RouteRecordRaw } from 'vue-router';
import type { Router, RouteRecordRaw, RouterOptions } from 'vue-router';
import { createRouter as _createRouter, createWebHistory } from 'vue-router';
// 导入自动生成的路由
// 注意:使用动态导入以避免构建时错误
let autoRoutes: RouteRecordRaw[] = [];
// 使用同步方式导入(在构建时生成的文件)
// 由于项目使用 ES 模块,这里使用条件导入
try {
// @ts-ignore - 动态导入可能不存在,使用同步导入
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
const autoRoutesModule = require('./auto-routes');
autoRoutes = autoRoutesModule.autoRoutes || [];
} catch (error) {
// 如果自动生成的路由文件不存在,使用手动配置的路由
console.warn('[router] 自动路由文件不存在,使用手动配置的路由');
// 手动配置的路由(作为后备方案)
autoRoutes = [
{
path: '/',
name: 'Home',
component: () => import('@/views/Home.vue'),
meta: {
title: '首页',
},
},
{
path: '/managekonw',
name: 'ManageKonw',
component: () => import('@/views/ManageKonw/index.vue'),
meta: {
title: '知识管理',
},
// 手动配置的路由
// 注意:auto-routes.ts 文件仅作为示例,不在项目中使用
const routes: RouteRecordRaw[] = [
{
path: '/',
name: 'Home',
component: () => import('@/views/Home.vue'),
meta: {
title: '首页',
},
{
path: '/assistant',
name: 'Assistant',
component: () => import('@/views/Assistant/index.vue'),
meta: {
title: '岗位助理配置',
},
},
{
path: '/managekonw',
name: 'ManageKonw',
component: () => import('@/views/ManageKonw/index.vue'),
meta: {
title: '知识管理',
},
{
path: '/manageagentic',
name: 'ManageAgentic',
component: () => import('@/views/ManageAgentic/index.vue'),
meta: {
title: '智能体管理',
},
},
{
path: '/assistant',
name: 'Assistant',
component: () => import('@/views/Assistant/index.vue'),
meta: {
title: '岗位助理配置',
},
{
path: '/assistant/add',
name: 'AssistantAdd',
component: () => import('@/views/Assistant/addUpdate.vue'),
meta: {
title: '新增智能体',
},
},
{
path: '/manageagentic',
name: 'ManageAgentic',
component: () => import('@/views/ManageAgentic/index.vue'),
meta: {
title: '智能体管理',
},
{
path: '/assistant/edit/:id',
name: 'AssistantEdit',
component: () => import('@/views/Assistant/addUpdate.vue'),
meta: {
title: '编辑',
},
},
{
path: '/assistant/add',
name: 'AssistantAdd',
component: () => import('@/views/Assistant/addUpdate.vue'),
meta: {
title: '新增智能体',
},
{
path: '/user',
name: 'User',
component: () => import('@/views/User.vue'),
meta: {
title: '用户管理',
},
},
{
path: '/assistant/edit/:id',
name: 'AssistantEdit',
component: () => import('@/views/Assistant/addUpdate.vue'),
meta: {
title: '编辑',
},
{
path: '/settings',
name: 'Settings',
component: () => import('@/views/Settings.vue'),
meta: {
title: '系统设置',
},
},
{
path: '/user',
name: 'User',
component: () => import('@/views/User.vue'),
meta: {
title: '用户管理',
},
{
path: '/communication',
name: 'Communication',
component: () => import('@/views/Communication.vue'),
meta: {
title: '通信示例',
},
},
{
path: '/settings',
name: 'Settings',
component: () => import('@/views/Settings.vue'),
meta: {
title: '系统设置',
},
{
path: '/:pathMatch(.*)*',
name: 'NotFound',
component: () => import('@/views/NotFound.vue'),
},
{
path: '/communication',
name: 'Communication',
component: () => import('@/views/Communication.vue'),
meta: {
title: '通信示例',
},
];
}
// 手动配置的路由(用于覆盖或补充自动生成的路由)
// 手动配置的路由优先级更高,会覆盖自动生成的路由
const manualRoutes: RouteRecordRaw[] = [
// 可以在这里添加需要手动配置的特殊路由
// 例如:需要特殊权限、动态参数等的路由
// {
// path: '/custom',
// name: 'Custom',
// component: () => import('@/views/Custom.vue'),
// meta: {
// title: '自定义路由',
// },
// },
},
{
path: '/:pathMatch(.*)*',
name: 'NotFound',
component: () => import('@/views/NotFound.vue'),
},
];
// 合并路由:手动配置的路由优先
const routes: RouteRecordRaw[] = [
...manualRoutes,
...autoRoutes.filter(
(autoRoute) => !manualRoutes.some((manualRoute) => manualRoute.path === autoRoute.path)
),
];
// 转换为 RouterOptions 需要的类型
const routerRoutes = routes as unknown as RouterOptions['routes'];
/**
* 创建路由实例
......@@ -129,7 +94,7 @@ const routes: RouteRecordRaw[] = [
export function createRouter(base: string = '/'): Router {
const router = _createRouter({
history: createWebHistory(base),
routes,
routes: routerRoutes,
});
// 路由守卫
......
......@@ -31,7 +31,6 @@
"include": [
"env.d.ts",
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.tsx",
"src/**/*.vue",
"src/**/*.js"
......
......@@ -35,7 +35,6 @@
"include": [
"env.d.ts",
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.tsx",
"src/**/*.vue",
"src/**/*.js"
......
......@@ -10,5 +10,5 @@
"allowSyntheticDefaultImports": true,
"skipLibCheck": true
},
"include": ["vite.config.ts", "src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
"include": ["vite.config.ts"]
}
......@@ -27,7 +27,6 @@
},
"include": [
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.tsx",
"src/**/*.vue",
"src/**/*.js"
......
......@@ -27,5 +27,5 @@
"skipLibCheck": true
},
"references": [{ "path": "./tsconfig.node.json" }],
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue", "env.d.ts"]
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue", "env.d.ts"]
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!