Commit 7827eb3f authored by nanahira's avatar nanahira

default as reusable picsource

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