diff --git a/core/package.json b/core/package.json index 531dda9..8b65ec6 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@cool-midway/core", - "version": "7.1.23", + "version": "7.1.24", "description": "", "main": "dist/index.js", "typings": "index.d.ts", diff --git a/core/src/decorator/controller.ts b/core/src/decorator/controller.ts index d22f502..b0166b7 100644 --- a/core/src/decorator/controller.ts +++ b/core/src/decorator/controller.ts @@ -11,7 +11,6 @@ import { } from "@midwayjs/decorator"; import * as fs from "fs"; import * as _ from "lodash"; -import * as os from "os"; import location from "../util/location"; export type ApiTypes = "add" | "delete" | "update" | "page" | "info" | "list"; @@ -152,12 +151,7 @@ export function CoolController( pathArr.reverse(); pathArr.splice(1, 0, module); // 追加模块中间件 - let path = `${ - res.path.split(`modules/${module}`)[0] - }modules/${module}/config.${_.endsWith(res.path, "ts") ? "ts" : "js"}`; - if (os.type() == "Windows_NT") { - path = path.substring(1); - } + let path = `${res.path.split(new RegExp(`modules[/\\\\]${module}`))[0]}modules/${module}/config.${_.endsWith(res.path, "ts") ? "ts" : "js"}`; if (fs.existsSync(path)) { const config: ModuleConfig = require(path).default(); routerOptions.middleware = (config.middlewares || []).concat( diff --git a/core/src/package.json b/core/src/package.json index 718fa92..1c58050 100644 --- a/core/src/package.json +++ b/core/src/package.json @@ -1,6 +1,6 @@ { "name": "@cool-midway/core", - "version": "7.1.23", + "version": "7.1.24", "description": "", "main": "index.js", "typings": "index.d.ts",