mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: drop global.Hydro.lib
This commit is contained in:
17 files changed
+31
-45
No files matched your search
@@ -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();
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in new issue
Block a user