mirror of
https://github.com/cool-team-official/cool-admin-midway-packages.git
synced 2025-12-14 15:32:51 +00:00
完善cli
This commit is contained in:
parent
ce91a3f16d
commit
67184a365b
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@cool-midway/plugin-cli",
|
"name": "@cool-midway/plugin-cli",
|
||||||
"version": "7.1.4",
|
"version": "7.1.7",
|
||||||
"description": "cool-admin midway plugin",
|
"description": "cool-admin midway plugin",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -22,6 +22,7 @@
|
|||||||
"readme": "README.md",
|
"readme": "README.md",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@cool-midway/cache-manager-fs-hash": "^7.0.0",
|
||||||
"@midwayjs/cache-manager": "^3.15.2",
|
"@midwayjs/cache-manager": "^3.15.2",
|
||||||
"@midwayjs/core": "^3.15.0",
|
"@midwayjs/core": "^3.15.0",
|
||||||
"archiver": "^6.0.1",
|
"archiver": "^6.0.1",
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { MidwayCache } from "@midwayjs/cache-manager";
|
import { MidwayCache } from "@midwayjs/cache-manager";
|
||||||
import { IMidwayContext, IMidwayApplication } from "@midwayjs/core";
|
import { IMidwayContext, IMidwayApplication } from "@midwayjs/core";
|
||||||
|
import { CoolCacheStore, FsCacheStore } from "./cache/store";
|
||||||
|
|
||||||
// 文件上传
|
// 文件上传
|
||||||
export * from "./hook/upload";
|
export * from "./hook/upload";
|
||||||
@ -48,7 +49,9 @@ export abstract class BasePlugin {
|
|||||||
/** 应用实例,用到此项无法本地调试,需安装到cool-admin中才能调试 */
|
/** 应用实例,用到此项无法本地调试,需安装到cool-admin中才能调试 */
|
||||||
app: IMidwayApplication;
|
app: IMidwayApplication;
|
||||||
/** 缓存 */
|
/** 缓存 */
|
||||||
cache: MidwayCache;
|
cache: FsCacheStore | MidwayCache;
|
||||||
|
/** 插件 */
|
||||||
|
pluginService: PluginService;
|
||||||
|
|
||||||
setCtx(ctx: IMidwayContext) {
|
setCtx(ctx: IMidwayContext) {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
@ -60,6 +63,24 @@ export abstract class BasePlugin {
|
|||||||
|
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得App级别的实例
|
||||||
|
* @param name
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
async getAppInstance(name: string) {
|
||||||
|
return await this.app.getApplicationContext().getAsync(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得请求级别的实例
|
||||||
|
* @param name
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
async getCtxInstance(name: string) {
|
||||||
|
return await this.ctx.requestContext.getAsync(name);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化插件
|
* 初始化插件
|
||||||
* @param pluginInfo
|
* @param pluginInfo
|
||||||
@ -75,8 +96,32 @@ export abstract class BasePlugin {
|
|||||||
this.pluginInfo = pluginInfo;
|
this.pluginInfo = pluginInfo;
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
this.cache = CoolCacheStore({});
|
||||||
if (other) {
|
if (other) {
|
||||||
this.cache = other.cache;
|
this.cache = other.cache;
|
||||||
|
this.pluginService = other.pluginService;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export declare class PluginService {
|
||||||
|
/**
|
||||||
|
* 调用插件
|
||||||
|
* @param key 插件key
|
||||||
|
* @param method 方法
|
||||||
|
* @param params 参数
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
invoke(key: string, method: string, ...params: any[]): Promise<any>;
|
||||||
|
/**
|
||||||
|
* 获得插件实例
|
||||||
|
* @param key
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getInstance(key: string): Promise<any>;
|
||||||
|
/**
|
||||||
|
* 检查状态
|
||||||
|
* @param key
|
||||||
|
*/
|
||||||
|
checkStatus(key: string): Promise<void>;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user