mirror of
https://github.com/cool-team-official/cool-admin-midway-packages.git
synced 2025-12-13 14:52:49 +00:00
fix新的自动路由导致模块中间件失效
This commit is contained in:
parent
a0efb2bd39
commit
b670e8ead7
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@cool-midway/core",
|
"name": "@cool-midway/core",
|
||||||
"version": "7.1.23",
|
"version": "7.1.24",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "index.d.ts",
|
"typings": "index.d.ts",
|
||||||
|
|||||||
@ -11,7 +11,6 @@ import {
|
|||||||
} from "@midwayjs/decorator";
|
} from "@midwayjs/decorator";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import * as _ from "lodash";
|
import * as _ from "lodash";
|
||||||
import * as os from "os";
|
|
||||||
import location from "../util/location";
|
import location from "../util/location";
|
||||||
|
|
||||||
export type ApiTypes = "add" | "delete" | "update" | "page" | "info" | "list";
|
export type ApiTypes = "add" | "delete" | "update" | "page" | "info" | "list";
|
||||||
@ -152,12 +151,7 @@ export function CoolController(
|
|||||||
pathArr.reverse();
|
pathArr.reverse();
|
||||||
pathArr.splice(1, 0, module);
|
pathArr.splice(1, 0, module);
|
||||||
// 追加模块中间件
|
// 追加模块中间件
|
||||||
let path = `${
|
let path = `${res.path.split(new RegExp(`modules[/\\\\]${module}`))[0]}modules/${module}/config.${_.endsWith(res.path, "ts") ? "ts" : "js"}`;
|
||||||
res.path.split(`modules/${module}`)[0]
|
|
||||||
}modules/${module}/config.${_.endsWith(res.path, "ts") ? "ts" : "js"}`;
|
|
||||||
if (os.type() == "Windows_NT") {
|
|
||||||
path = path.substring(1);
|
|
||||||
}
|
|
||||||
if (fs.existsSync(path)) {
|
if (fs.existsSync(path)) {
|
||||||
const config: ModuleConfig = require(path).default();
|
const config: ModuleConfig = require(path).default();
|
||||||
routerOptions.middleware = (config.middlewares || []).concat(
|
routerOptions.middleware = (config.middlewares || []).concat(
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@cool-midway/core",
|
"name": "@cool-midway/core",
|
||||||
"version": "7.1.23",
|
"version": "7.1.24",
|
||||||
"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