Commit 7827eb3f authored by nanahira's avatar nanahira

default as reusable picsource

parent 0fcd1a07
......@@ -9,7 +9,7 @@
"version": "9.4.0",
"license": "MIT",
"dependencies": {
"koishi-thirdeye": "^10.3.0",
"koishi-thirdeye": "^10.3.1",
"lodash": "^4.17.21"
},
"devDependencies": {
......@@ -5260,9 +5260,9 @@
}
},
"node_modules/koishi-thirdeye": {
"version": "10.3.0",
"resolved": "https://registry.npmjs.org/koishi-thirdeye/-/koishi-thirdeye-10.3.0.tgz",
"integrity": "sha512-kronZq9g0kgAfdYftrFIOOHgX96xtO1BX5HXn1QmggLG7+v6Fvr72d+V4k/u3Aif1VvIf5AmonEbbqWDIPWhsQ==",
"version": "10.3.1",
"resolved": "https://registry.npmjs.org/koishi-thirdeye/-/koishi-thirdeye-10.3.1.tgz",
"integrity": "sha512-MEppegxBnl9MgwHxjXzItsgzmMnizewllJsuFGRyWasacOHrXieHTG07yGEVKhc8yWJT2JuqS79WI7excXcBXQ==",
"dependencies": {
"@types/koa": "^2.13.4",
"@types/koa__router": "^8.0.11",
......@@ -11891,9 +11891,9 @@
}
},
"koishi-thirdeye": {
"version": "10.3.0",
"resolved": "https://registry.npmjs.org/koishi-thirdeye/-/koishi-thirdeye-10.3.0.tgz",
"integrity": "sha512-kronZq9g0kgAfdYftrFIOOHgX96xtO1BX5HXn1QmggLG7+v6Fvr72d+V4k/u3Aif1VvIf5AmonEbbqWDIPWhsQ==",
"version": "10.3.1",
"resolved": "https://registry.npmjs.org/koishi-thirdeye/-/koishi-thirdeye-10.3.1.tgz",
"integrity": "sha512-MEppegxBnl9MgwHxjXzItsgzmMnizewllJsuFGRyWasacOHrXieHTG07yGEVKhc8yWJT2JuqS79WI7excXcBXQ==",
"requires": {
"@types/koa": "^2.13.4",
"@types/koa__router": "^8.0.11",
......
......@@ -27,7 +27,7 @@
},
"homepage": "https://github.com/koishijs/koishi-plugin-pics",
"dependencies": {
"koishi-thirdeye": "^10.3.0",
"koishi-thirdeye": "^10.3.1",
"lodash": "^4.17.21"
},
"devDependencies": {
......
......@@ -7,11 +7,13 @@ import {
InjectLogger,
LifecycleEvents,
PartialDeep,
Reusable,
schemaFromClass,
} from 'koishi-thirdeye';
import PicsContainer, { PicMiddlewareInfo } from './index';
import { PicMiddleware, PicNext } from './def';
@Reusable()
export class BasePicMiddlewarePlugin
extends BasePlugin<PicMiddlewareConfig>
implements PicMiddleware, LifecycleEvents
......@@ -51,6 +53,7 @@ export function PlainPicMiddlewarePlugin<C>(dict: {
config: PicMiddlewareInfo & C;
static Config = Config;
static using = ['pics'] as const;
static reusable = true;
constructor(
public ctx: Context,
config: PartialDeep<C & PicMiddlewareInfo>,
......
......@@ -6,6 +6,8 @@ import {
InjectLogger,
CreatePluginFactory,
schemaFromClass,
Apply,
Reusable,
} from 'koishi-thirdeye';
import PicsContainer from '.';
import { PicSourceConfig } from './config';
......@@ -50,6 +52,7 @@ export class PicSource implements PicSourceInfo {
}
}
@Reusable()
export class BasePicSourcePlugin extends PicSource {
constructor(ctx: Context, config: PartialDeep<PicSourceConfig>) {
super(ctx);
......@@ -64,7 +67,8 @@ export class BasePicSourcePlugin extends PicSource {
@InjectLogger()
logger: Logger;
onApply() {
@Apply()
initializeSource() {
this.config.applyTo(this);
this.pics.addSource(this);
}
......@@ -93,5 +97,6 @@ export function PlainPicSourcePlugin<C>(dict: {
}
static Config = Config;
static using = ['pics'] as const;
static reusable = true;
};
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment