From b670e8ead794660ade2a23de6753fb667201260d Mon Sep 17 00:00:00 2001 From: COOL Date: Mon, 30 Dec 2024 13:02:53 +0800 Subject: [PATCH] =?UTF-8?q?fix=E6=96=B0=E7=9A=84=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=E5=AF=BC=E8=87=B4=E6=A8=A1=E5=9D=97=E4=B8=AD?= =?UTF-8?q?=E9=97=B4=E4=BB=B6=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/package.json | 2 +- core/src/decorator/controller.ts | 8 +------- core/src/package.json | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) 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",