diff --git a/framework/framework/server.ts b/framework/framework/server.ts index b6fcbb561..00d83957f 100644 --- a/framework/framework/server.ts +++ b/framework/framework/server.ts @@ -313,7 +313,7 @@ function executeMiddlewareStack(context: any, middlewares: { name: string, func: return dispatch(0); } -interface WebServiceConfig { +export interface WebServiceConfig { keys: string[]; proxy: boolean; cors?: string; @@ -697,7 +697,7 @@ declare module 'cordis' { } } -export async function apply(ctx: Context, config) { +export async function apply(ctx: Context, config: WebServiceConfig) { ctx.provide('server', undefined, true); ctx.server = new WebService(ctx, config); } diff --git a/packages/hydrooj/src/lib/i18n.ts b/packages/hydrooj/src/lib/i18n.ts index ed1da6fd9..fa1a7959c 100644 --- a/packages/hydrooj/src/lib/i18n.ts +++ b/packages/hydrooj/src/lib/i18n.ts @@ -7,6 +7,11 @@ declare module '../context' { i18n: I18nService; } } +declare module '../service/bus' { + interface EventMap { + 'app/i18n/update': (lang: string) => void; + } +} declare global { interface String { translate: (...languages: string[]) => string; @@ -22,6 +27,7 @@ class I18nService extends Service { this.ctx.effect(() => { translations[lang] ||= []; translations[lang].unshift(content); + this.ctx.emit('app/i18n/update', lang); return () => { translations[lang] = translations[lang].filter((i) => i !== content); }; diff --git a/packages/ui-default/backendlib/builder.ts b/packages/ui-default/backendlib/builder.ts index f79137b0d..23fe6b739 100644 --- a/packages/ui-default/backendlib/builder.ts +++ b/packages/ui-default/backendlib/builder.ts @@ -145,5 +145,6 @@ export async function apply(ctx: Context) { ctx.on('system/setting', () => triggerHotUpdate()); ctx.on('app/watch/change', triggerHotUpdate); ctx.on('app/watch/unlink', triggerHotUpdate); + ctx.on('app/i18n/update', debouncedBuildUI); debouncedBuildUI(); }