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
b526c75161
commit
fc23c816b2
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@cool-midway/plugin-cli",
|
||||
"version": "7.1.8",
|
||||
"version": "7.1.9",
|
||||
"description": "cool-admin midway plugin",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
@ -30,6 +30,7 @@
|
||||
"esbuild-plugin-copy": "^2.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.12.7",
|
||||
"typescript": "^5.3.3"
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,6 +52,8 @@ export abstract class BasePlugin {
|
||||
cache: FsCacheStore | MidwayCache;
|
||||
/** 插件 */
|
||||
pluginService: PluginService;
|
||||
/** 基础目录位置 */
|
||||
baseDir: string;
|
||||
|
||||
setCtx(ctx: IMidwayContext) {
|
||||
this.ctx = ctx;
|
||||
@ -59,6 +61,8 @@ export abstract class BasePlugin {
|
||||
|
||||
setApp(app: IMidwayApplication) {
|
||||
this.app = app;
|
||||
this.baseDir = app.getBaseDir();
|
||||
this.configDir();
|
||||
}
|
||||
|
||||
constructor() {}
|
||||
@ -96,6 +100,11 @@ export abstract class BasePlugin {
|
||||
this.pluginInfo = pluginInfo;
|
||||
this.ctx = ctx;
|
||||
this.app = app;
|
||||
this.baseDir = process.cwd();
|
||||
if (this.app) {
|
||||
this.baseDir = this.app?.getBaseDir();
|
||||
}
|
||||
this.configDir();
|
||||
this.cache = CoolCacheStore({});
|
||||
if (other) {
|
||||
this.cache = other.cache;
|
||||
@ -104,6 +113,19 @@ export abstract class BasePlugin {
|
||||
await this.ready();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理配置目录
|
||||
*/
|
||||
private configDir() {
|
||||
// 替换\为/
|
||||
this.baseDir = this.baseDir.replace(/\\/g, "/");
|
||||
let config = this.pluginInfo.config || {};
|
||||
config = JSON.stringify(config);
|
||||
this.pluginInfo.config = JSON.parse(
|
||||
config.replace(/@baseDir/g, this.baseDir)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 插件就绪
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user