mirror of
https://github.com/cool-team-official/cool-admin-midway-packages.git
synced 2025-12-11 05:42:49 +00:00
更高效的自动路由方式
This commit is contained in:
parent
e94ee25d8d
commit
a0efb2bd39
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@cool-midway/core",
|
||||
"version": "7.1.22",
|
||||
"version": "7.1.23",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"typings": "index.d.ts",
|
||||
|
||||
@ -104,7 +104,7 @@ export interface RouterOptions {
|
||||
description?: string;
|
||||
tagName?: string;
|
||||
ignoreGlobalPrefix?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
// COOL的装饰器
|
||||
export function CoolController(
|
||||
@ -115,22 +115,22 @@ export function CoolController(
|
||||
// 将装饰的类,绑定到该装饰器,用于后续能获取到 class
|
||||
saveModule(CONTROLLER_KEY, target);
|
||||
let prefix;
|
||||
if(curdOption){
|
||||
if (curdOption) {
|
||||
// 判断 curdOption 的类型
|
||||
if (typeof curdOption === "string") {
|
||||
prefix = curdOption;
|
||||
} else if (curdOption && 'api' in curdOption) {
|
||||
} else if (curdOption && "api" in curdOption) {
|
||||
// curdOption 是 CurdOption 类型
|
||||
prefix = curdOption.prefix || "";
|
||||
} else {
|
||||
// curdOption 是 RouterOptions 类型 合并到 routerOptions
|
||||
routerOptions = { ...curdOption , ...routerOptions, };
|
||||
routerOptions = { ...curdOption, ...routerOptions };
|
||||
}
|
||||
}
|
||||
// 如果不存在路由前缀,那么自动根据当前文件夹路径
|
||||
location.scriptPath(target).then(async (res: any) => {
|
||||
const pathSps = res.path.split(".");
|
||||
const paths = pathSps[pathSps.length - 2].split("/");
|
||||
const paths = pathSps[pathSps.length - 2].split(/[/\\]/);
|
||||
const pathArr = [];
|
||||
let module = null;
|
||||
for (const path of paths.reverse()) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@cool-midway/core",
|
||||
"version": "7.1.22",
|
||||
"version": "7.1.23",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"typings": "index.d.ts",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user