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();
+1 -1
View File
@@ -59,6 +59,6 @@ function renderInline(text) {
return md.renderInline(text);
}
global.Hydro.lib.markdown = module.exports = {
module.exports = {
md, plugin, render, renderInline,
};
@@ -133,7 +133,6 @@ class Nunjucks extends nunjucks.Environment {
this.addGlobal('utils', { status });
this.addGlobal('avatarUrl', avatar);
this.addGlobal('formatSeconds', misc.formatSeconds);
this.addGlobal('lib', global.Hydro.lib);
this.addGlobal('model', global.Hydro.model);
this.addGlobal('ui', global.Hydro.ui);
this.addGlobal('isIE', (str) => {