优化loader

pull/10/head
undefined 4 years ago
parent 61c4d38521
commit 32a6d2de13

@ -3,6 +3,7 @@
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import yaml from 'js-yaml'; import yaml from 'js-yaml';
import { argv } from 'yargs';
export const builtinLib = [ export const builtinLib = [
'jwt', 'download', 'i18n', 'mail', 'useragent', 'jwt', 'download', 'i18n', 'mail', 'useragent',
@ -53,6 +54,7 @@ export async function handler(pending: string[], fail: string[]) {
} catch (e) { } catch (e) {
fail.push(i); fail.push(i);
console.error(`Handler Load Fail: ${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) { } catch (e) {
fail.push(i); fail.push(i);
console.error(`Locale Load Fail: ${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) { } catch (e) {
console.error(`Config Load Fail: ${i}`); 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) { } catch (e) {
fail.push(i); fail.push(i);
console.error(`Template Load Fail: ${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) { } catch (e) {
fail.push(i); fail.push(i);
console.error(`Model Load Fail: ${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) { } catch (e) {
fail.push(i); fail.push(i);
console.error(`Lib Load Fail: ${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) { } catch (e) {
fail.push(i); fail.push(i);
console.error(`Service Load Fail: ${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) { } catch (e) {
fail.push(i); fail.push(i);
console.error(`Script Load Fail: ${i}`); console.error(`Script Load Fail: ${i}`);
console.error(e); if (argv.debug) console.error(e);
} }
} }
active.push(i); active.push(i);

@ -12,28 +12,30 @@ import AdmZip from 'adm-zip';
export * from './interface'; export * from './interface';
global.Hydro = { if (!global.Hydro) {
stat: { reqCount: 0 }, global.Hydro = {
handler: {}, stat: { reqCount: 0 },
// @ts-ignore handler: {},
service: {}, // @ts-ignore
// @ts-ignore service: {},
model: {}, // @ts-ignore
script: {}, model: {},
// @ts-ignore script: {},
lib: {}, // @ts-ignore
ui: { lib: {},
manifest: {}, ui: {
nav: [], manifest: {},
template: {}, nav: [],
}, template: {},
// @ts-ignore },
error: {}, // @ts-ignore
locales: {}, error: {},
postInit: [], locales: {},
}; postInit: [],
global.onDestory = []; };
global.addons = []; global.onDestory = [];
global.addons = [];
}
if (argv.debug) { if (argv.debug) {
console.log(process.argv); console.log(process.argv);

@ -524,6 +524,7 @@ Problem Solution: 题解列表
Problem Tags Visibility: 题目标签可见性 Problem Tags Visibility: 题目标签可见性
problem_create: 创建题目 problem_create: 创建题目
problem_detail: 题目详情 problem_detail: 题目详情
problem_detail: 题目详情
problem_edit: 编辑题目 problem_edit: 编辑题目
problem_import: 导入题目 problem_import: 导入题目
problem_main: 题库 problem_main: 题库

@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "2.11.8", "version": "2.11.9",
"main": "dist/loader.js", "main": "dist/loader.js",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"repository": "https://github.com/hydro-dev/Hydro.git", "repository": "https://github.com/hydro-dev/Hydro.git",

Loading…
Cancel
Save