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