mirror of
https://github.com/certd/certd.git
synced 2026-04-24 04:17:25 +08:00
🔱: [client] sync upgrade with 6 commits [trident-sync]
chore: chore: fix: 修复无法嵌套路由的bug build: publish success build: publish success
This commit is contained in:
@@ -6,7 +6,7 @@ import { frameworkResource } from "./source/framework";
|
||||
const modules = import.meta.glob("/src/views/**/*.vue");
|
||||
|
||||
let index = 0;
|
||||
function transformOneResource(resource: any) {
|
||||
function transformOneResource(resource: any, parent: any) {
|
||||
let menu: any = null;
|
||||
if (resource.meta == null) {
|
||||
resource.meta = {};
|
||||
@@ -21,58 +21,58 @@ function transformOneResource(resource: any) {
|
||||
} else {
|
||||
menu = _.cloneDeep(resource);
|
||||
delete menu.component;
|
||||
}
|
||||
let route;
|
||||
if (resource.type !== "menu") {
|
||||
if (resource.path == null || resource.path.startsWith("https://") || resource.path.startsWith("http://")) {
|
||||
//没有route
|
||||
route = null;
|
||||
if (menu.path?.startsWith("/")) {
|
||||
menu.fullPath = menu.path;
|
||||
} else {
|
||||
route = _.cloneDeep(resource);
|
||||
if (route.component && typeof route.component === "string") {
|
||||
const path = "/src/views" + route.component;
|
||||
route.component = modules[path];
|
||||
}
|
||||
if (route.component == null) {
|
||||
route.component = LayoutPass;
|
||||
}
|
||||
menu.fullPath = (parent?.fullPath || "") + "/" + menu.path;
|
||||
}
|
||||
}
|
||||
let route;
|
||||
if (meta.isRoute === false || resource.path == null || resource.path.startsWith("https://") || resource.path.startsWith("http://")) {
|
||||
//没有route
|
||||
route = null;
|
||||
} else {
|
||||
route = _.cloneDeep(resource);
|
||||
if (route.component && typeof route.component === "string") {
|
||||
const path = "/src/views" + route.component;
|
||||
route.component = modules[path];
|
||||
}
|
||||
if (route.component == null) {
|
||||
route.component = LayoutPass;
|
||||
}
|
||||
if (route?.meta?.cache !== false) {
|
||||
if (route.meta == null) {
|
||||
route.meta = {};
|
||||
}
|
||||
route.meta.cache = true;
|
||||
}
|
||||
}
|
||||
if (resource.children) {
|
||||
const { menus, routes } = buildMenusAndRouters(resource.children, resource);
|
||||
if (menu) {
|
||||
menu.children = menus;
|
||||
}
|
||||
if (route) {
|
||||
route.children = routes;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
menu,
|
||||
route
|
||||
};
|
||||
}
|
||||
|
||||
export const buildMenusAndRouters = (resources: any) => {
|
||||
export const buildMenusAndRouters = (resources: any, parent: any = null) => {
|
||||
const routes: Array<any> = [];
|
||||
const menus: Array<any> = [];
|
||||
for (const item of resources) {
|
||||
const { menu, route } = transformOneResource(item);
|
||||
let menuChildren;
|
||||
let routeChildren;
|
||||
if (item.children) {
|
||||
if (item.children.length > 0) {
|
||||
const ret = buildMenusAndRouters(item.children);
|
||||
menuChildren = ret.menus;
|
||||
routeChildren = ret.routes;
|
||||
}
|
||||
}
|
||||
const { menu, route } = transformOneResource(item, parent);
|
||||
|
||||
if (menu) {
|
||||
menus.push(menu);
|
||||
menu.children = menuChildren;
|
||||
}
|
||||
if (route) {
|
||||
if (route?.meta?.cache !== false) {
|
||||
if (route.meta == null) {
|
||||
route.meta = {};
|
||||
}
|
||||
route.meta.cache = true;
|
||||
}
|
||||
routes.push(route);
|
||||
route.children = routeChildren;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ const outsideRet = buildMenusAndRouters(outsideResource);
|
||||
const headerRet = buildMenusAndRouters(headerResource);
|
||||
|
||||
const outsideRoutes = outsideRet.routes;
|
||||
const frameworkRoutes = flatSubRouters(frameworkRet.routes);
|
||||
const frameworkRoutes = frameworkRet.routes;
|
||||
const routes = [...outsideRoutes, ...frameworkRoutes];
|
||||
const frameworkMenus = frameworkRet.menus;
|
||||
const headerMenus = headerRet.menus;
|
||||
|
||||
@@ -48,18 +48,18 @@ export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOpti
|
||||
search: {
|
||||
//控制查询字段顺序
|
||||
show: true,
|
||||
//字段默认order为100,比100大的放最后面
|
||||
//字段默认order为1,比1大的放最后面
|
||||
order: 101
|
||||
},
|
||||
type: "text",
|
||||
column: {
|
||||
//控制列字段顺序
|
||||
//字段默认order为100,比100大的放最后面
|
||||
//字段默认order为1,比1大的放最后面
|
||||
order: 101
|
||||
},
|
||||
form: {
|
||||
//控制表单字段顺序
|
||||
//字段默认order为100,比100大的放最后面
|
||||
//字段默认order为1,比1大的放最后面
|
||||
order: 101
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user