refactor: 悦码项目重构

This commit is contained in:
wangxuefeng
2025-02-19 13:42:56 +08:00
parent c8c9406fd5
commit eab709f94f
494 changed files with 50986 additions and 27639 deletions

View 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 };

View 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;

View 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;