core: drop global.Hydro.lib

This commit is contained in:
undefined committed 2025-03-10 12:31:25 +08:00
1 parent 1165bfff5b
commit 6ff66f2efc
17 files changed
+31 -45

No files matched your search

+2 -2
View File
@@ -3,7 +3,6 @@ import {
Context, fs, Handler, Logger, NotFoundError, param, SettingModel, sha1,
size, SystemModel, Types, UiContextBase,
} from 'hydrooj';
import { debounce } from 'lodash';
import { tmpdir } from 'os';
import {
basename, join, relative, resolve,
@@ -118,6 +117,7 @@ export async function buildUI() {
}
for (const lang in global.Hydro.locales) {
if (!/^[a-zA-Z_]+$/.test(lang)) continue;
if (!global.Hydro.locales[lang].__interface) continue;
const str = `window.LOCALES=${JSON.stringify(global.Hydro.locales[lang][Symbol.for('iterate')])};`;
addFile(`lang-${lang}.js`, str);
}
@@ -160,7 +160,7 @@ export async function apply(ctx: Context) {
ctx.Route('constant', '/lazy/:version/:name', UiConstantsHandler);
ctx.Route('constant', '/resource/:version/:name', UiConstantsHandler);
ctx.on('app/started', buildUI);
const debouncedBuildUI = debounce(buildUI, 2000, { trailing: true });
const debouncedBuildUI = ctx.debounce(buildUI, 2000);
const triggerHotUpdate = (path?: string) => {
if (path && !path.includes('/ui-default/') && !path.includes('/public/') && !path.includes('/frontend/')) return;
debouncedBuildUI();