refactor: 悦码项目重构
This commit is contained in:
8
apps/y-code-v1/src/router/guards.ts
Normal file
8
apps/y-code-v1/src/router/guards.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import type { NavigationGuardWithThis } from 'vue-router';
|
||||
|
||||
const titleGuard: NavigationGuardWithThis<undefined> = (to, from, next) => {
|
||||
next();
|
||||
document.title = to.meta.title ? `${to.meta.title} | 悦码` : '悦码';
|
||||
};
|
||||
|
||||
export { titleGuard };
|
||||
19
apps/y-code-v1/src/router/index.ts
Normal file
19
apps/y-code-v1/src/router/index.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { createRouter, createWebHistory, type Router } from 'vue-router';
|
||||
import { titleGuard } from './guards';
|
||||
import routeList from './routes';
|
||||
import { qiankunWindow } from 'vite-plugin-qiankun/dist/helper'
|
||||
|
||||
let router: Router | null = null
|
||||
export const createProjectRouter = (base = '') => {
|
||||
const __POWERED_BY_QIANKUN__ = qiankunWindow.__POWERED_BY_QIANKUN__ || window.proxy?.__POWERED_BY_QIANKUN__
|
||||
router = createRouter({
|
||||
history: createWebHistory(base || (__POWERED_BY_QIANKUN__ ? '/y-code-app/' : '')),
|
||||
routes: routeList,
|
||||
})
|
||||
|
||||
// 全局前置守卫
|
||||
router.beforeEach(titleGuard)
|
||||
return router
|
||||
}
|
||||
|
||||
export default router;
|
||||
117
apps/y-code-v1/src/router/routes.ts
Normal file
117
apps/y-code-v1/src/router/routes.ts
Normal file
@@ -0,0 +1,117 @@
|
||||
import Layout from "@/layout/index.vue";
|
||||
import {
|
||||
HomeOutlined,
|
||||
BarChartOutlined,
|
||||
AppstoreOutlined,
|
||||
} from "@ant-design/icons-vue";
|
||||
import { h } from "vue";
|
||||
import type { VNode, RendererNode, RendererElement } from "vue";
|
||||
|
||||
export interface RouteType {
|
||||
path: string;
|
||||
name: string;
|
||||
component?: any;
|
||||
meta: { title?: string };
|
||||
isMenu?: boolean;
|
||||
redirect?: string;
|
||||
children: RouteType[];
|
||||
icon?: () => VNode<
|
||||
RendererNode,
|
||||
RendererElement,
|
||||
{
|
||||
[key: string]: any;
|
||||
}
|
||||
>;
|
||||
}
|
||||
|
||||
const routeList: RouteType[] = [
|
||||
{
|
||||
path: "/",
|
||||
name: "layout",
|
||||
component: Layout,
|
||||
meta: { title: "首页" },
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
name: "-",
|
||||
meta: {},
|
||||
children: [],
|
||||
redirect: "/config-manage/project-cfg",
|
||||
},
|
||||
{
|
||||
path: "/config-manage",
|
||||
name: "config-manage",
|
||||
isMenu: true,
|
||||
meta: { title: "配置管理" },
|
||||
icon: () => h(HomeOutlined),
|
||||
children: [
|
||||
{
|
||||
path: "project-cfg",
|
||||
name: "project-cfg",
|
||||
component: () =>
|
||||
import("@/views/config-manage/project-cfg/index.vue"),
|
||||
meta: { title: "项目配置" },
|
||||
isMenu: true,
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
path: "module-cfg",
|
||||
name: "module-cfg",
|
||||
component: () =>
|
||||
import("@/views/config-manage/module-cfg/index.vue"),
|
||||
meta: { title: "数据来源配置" },
|
||||
isMenu: true,
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "/view-all-manage",
|
||||
name: "view-all-manage",
|
||||
isMenu: true,
|
||||
meta: { title: "视图管理" },
|
||||
icon: () => h(BarChartOutlined),
|
||||
children: [
|
||||
{
|
||||
path: "view-list",
|
||||
name: "view-list",
|
||||
component: () =>
|
||||
import("@/views/view-all-manage/view-list/index.vue"),
|
||||
meta: { title: "视图列表" },
|
||||
isMenu: true,
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
path: "create-view",
|
||||
name: "create-view",
|
||||
component: () =>
|
||||
import("@/views/view-all-manage/create-view/index.vue"),
|
||||
meta: { title: "创建视图" },
|
||||
isMenu: true,
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "/page-show-info",
|
||||
name: "page-show-info",
|
||||
isMenu: true,
|
||||
meta: { title: "视图预览" },
|
||||
icon: () => h(AppstoreOutlined),
|
||||
children: [
|
||||
{
|
||||
path: "page-info",
|
||||
name: "page-info",
|
||||
component: () =>
|
||||
import("@/views/page-show-info/page-info/index.vue"),
|
||||
meta: { title: "项目报表" },
|
||||
isMenu: true,
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
export default routeList;
|
||||
Reference in New Issue
Block a user