From 32a6d2de1387a64b0d4e8f52a520d937cf131034 Mon Sep 17 00:00:00 2001 From: undefined Date: Sun, 2 Aug 2020 12:53:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96loader?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hydro/entry/common.ts | 12 ++++++++--- hydro/loader.ts | 46 ++++++++++++++++++++++--------------------- locales/zh_CN.yaml | 1 + package.json | 2 +- 4 files changed, 35 insertions(+), 26 deletions(-) diff --git a/hydro/entry/common.ts b/hydro/entry/common.ts index 8de79482..16bf59ea 100644 --- a/hydro/entry/common.ts +++ b/hydro/entry/common.ts @@ -3,6 +3,7 @@ import fs from 'fs'; import path from 'path'; import yaml from 'js-yaml'; +import { argv } from 'yargs'; export const builtinLib = [ 'jwt', 'download', 'i18n', 'mail', 'useragent', @@ -53,6 +54,7 @@ export async function handler(pending: string[], fail: string[]) { } catch (e) { fail.push(i); console.error(`Handler Load Fail: ${i}`); + if (argv.debug) console.error(e); } } } @@ -75,6 +77,7 @@ export async function locale(pending: string[], fail: string[]) { } catch (e) { fail.push(i); console.error(`Locale Load Fail: ${i}`); + if (argv.debug) console.error(e); } } } @@ -104,6 +107,7 @@ export async function setting(pending: string[], fail: string[], modelSetting: t } } catch (e) { console.error(`Config Load Fail: ${i}`); + if (argv.debug) console.error(e); } } } @@ -125,6 +129,7 @@ export async function template(pending: string[], fail: string[]) { } catch (e) { fail.push(i); console.error(`Template Load Fail: ${i}`); + if (argv.debug) console.error(e); } } } @@ -155,6 +160,7 @@ export async function model(pending: string[], fail: string[]) { } catch (e) { fail.push(i); console.error(`Model Load Fail: ${i}`); + if (argv.debug) console.error(e); } } } @@ -172,7 +178,7 @@ export async function lib(pending: string[], fail: string[]) { } catch (e) { fail.push(i); console.error(`Lib Load Fail: ${i}`); - console.error(e); + if (argv.debug) console.error(e); } } } @@ -190,7 +196,7 @@ export async function service(pending: string[], fail: string[]) { } catch (e) { fail.push(i); console.error(`Service Load Fail: ${i}`); - console.error(e); + if (argv.debug) console.error(e); } } } @@ -207,7 +213,7 @@ export async function script(pending: string[], fail: string[], active: string[] } catch (e) { fail.push(i); console.error(`Script Load Fail: ${i}`); - console.error(e); + if (argv.debug) console.error(e); } } active.push(i); diff --git a/hydro/loader.ts b/hydro/loader.ts index b3a15960..24af4ad6 100644 --- a/hydro/loader.ts +++ b/hydro/loader.ts @@ -12,28 +12,30 @@ import AdmZip from 'adm-zip'; export * from './interface'; -global.Hydro = { - stat: { reqCount: 0 }, - handler: {}, - // @ts-ignore - service: {}, - // @ts-ignore - model: {}, - script: {}, - // @ts-ignore - lib: {}, - ui: { - manifest: {}, - nav: [], - template: {}, - }, - // @ts-ignore - error: {}, - locales: {}, - postInit: [], -}; -global.onDestory = []; -global.addons = []; +if (!global.Hydro) { + global.Hydro = { + stat: { reqCount: 0 }, + handler: {}, + // @ts-ignore + service: {}, + // @ts-ignore + model: {}, + script: {}, + // @ts-ignore + lib: {}, + ui: { + manifest: {}, + nav: [], + template: {}, + }, + // @ts-ignore + error: {}, + locales: {}, + postInit: [], + }; + global.onDestory = []; + global.addons = []; +} if (argv.debug) { console.log(process.argv); diff --git a/locales/zh_CN.yaml b/locales/zh_CN.yaml index 0df07cb5..17336880 100644 --- a/locales/zh_CN.yaml +++ b/locales/zh_CN.yaml @@ -524,6 +524,7 @@ Problem Solution: 题解列表 Problem Tags Visibility: 题目标签可见性 problem_create: 创建题目 problem_detail: 题目详情 +problem_detail: 题目详情 problem_edit: 编辑题目 problem_import: 导入题目 problem_main: 题库 diff --git a/package.json b/package.json index eff84654..be13aca7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "2.11.8", + "version": "2.11.9", "main": "dist/loader.js", "bin": "bin/hydrooj.js", "repository": "https://github.com/hydro-dev/Hydro.git",