mirror of
https://github.com/cool-team-official/cool-admin-midway-packages.git
synced 2025-12-14 15:32:51 +00:00
新增路径配置
This commit is contained in:
parent
b526c75161
commit
fc23c816b2
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@cool-midway/plugin-cli",
|
"name": "@cool-midway/plugin-cli",
|
||||||
"version": "7.1.8",
|
"version": "7.1.9",
|
||||||
"description": "cool-admin midway plugin",
|
"description": "cool-admin midway plugin",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -30,6 +30,7 @@
|
|||||||
"esbuild-plugin-copy": "^2.1.1"
|
"esbuild-plugin-copy": "^2.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/node": "^20.12.7",
|
||||||
"typescript": "^5.3.3"
|
"typescript": "^5.3.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,6 +52,8 @@ export abstract class BasePlugin {
|
|||||||
cache: FsCacheStore | MidwayCache;
|
cache: FsCacheStore | MidwayCache;
|
||||||
/** 插件 */
|
/** 插件 */
|
||||||
pluginService: PluginService;
|
pluginService: PluginService;
|
||||||
|
/** 基础目录位置 */
|
||||||
|
baseDir: string;
|
||||||
|
|
||||||
setCtx(ctx: IMidwayContext) {
|
setCtx(ctx: IMidwayContext) {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
@ -59,6 +61,8 @@ export abstract class BasePlugin {
|
|||||||
|
|
||||||
setApp(app: IMidwayApplication) {
|
setApp(app: IMidwayApplication) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
this.baseDir = app.getBaseDir();
|
||||||
|
this.configDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor() {}
|
constructor() {}
|
||||||
@ -96,6 +100,11 @@ export abstract class BasePlugin {
|
|||||||
this.pluginInfo = pluginInfo;
|
this.pluginInfo = pluginInfo;
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
this.baseDir = process.cwd();
|
||||||
|
if (this.app) {
|
||||||
|
this.baseDir = this.app?.getBaseDir();
|
||||||
|
}
|
||||||
|
this.configDir();
|
||||||
this.cache = CoolCacheStore({});
|
this.cache = CoolCacheStore({});
|
||||||
if (other) {
|
if (other) {
|
||||||
this.cache = other.cache;
|
this.cache = other.cache;
|
||||||
@ -104,6 +113,19 @@ export abstract class BasePlugin {
|
|||||||
await this.ready();
|
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