Commit 8e76a55f authored by nanahira's avatar nanahira

add constructor in config schema

parent 9ee11ba0
......@@ -3,6 +3,7 @@ import { DefineSchema, RegisterSchema } from 'schemastery-gen';
@RegisterSchema()
export class MyPluginConfig {
constructor(config: Partial<MyPluginConfig>) {}
@DefineSchema({
description: '词库本地路径或 URL。',
default:
......
......@@ -147,7 +147,8 @@ export class MyPlugin {
this.ctx = ctx;
this.config = config;
ctx.on('service', (name) => {
if (this.config.useDatabase && name === 'database') this.useDatabase = !!ctx.database;
if (this.config.useDatabase && name === 'database')
this.useDatabase = !!ctx.database;
});
ctx.on('service', (name) => {
if (!ctx.cache || name !== 'cache') {
......@@ -156,7 +157,7 @@ export class MyPlugin {
ctx.cache.table('thesaurusChatSession', {
maxAge: this.config.chatTimeout,
});
})
});
await this.loadWords();
ctx.middleware(async (session, next) => {
const sessionId = `${session.platform}.${session.selfId}.${session.userId}`;
......
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