mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: loader: add missing inject
This commit is contained in:
5 files changed
+15
-14
No files matched your search
@@ -115,7 +115,7 @@ export async function load(ctx: Context) {
|
|||||||
await ctx.plugin(ConfigService);
|
await ctx.plugin(ConfigService);
|
||||||
await require('../model/system').runConfig();
|
await require('../model/system').runConfig();
|
||||||
ctx = await new Promise((resolve) => {
|
ctx = await new Promise((resolve) => {
|
||||||
ctx.inject(['loader'], (c) => {
|
ctx.inject(['loader', 'config'], (c) => {
|
||||||
resolve(c);
|
resolve(c);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -39,14 +39,16 @@ export async function apply(ctx: Context) {
|
|||||||
const modelSystem = require('../model/system');
|
const modelSystem = require('../model/system');
|
||||||
await modelSystem.runConfig();
|
await modelSystem.runConfig();
|
||||||
ctx = await new Promise((resolve) => {
|
ctx = await new Promise((resolve) => {
|
||||||
ctx.inject(['loader'], (c) => {
|
ctx.inject(['loader', 'config'], (c) => {
|
||||||
resolve(c);
|
resolve(c);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
await ctx.loader.reloadPlugin(require.resolve('../service/storage'), 'file', 'hydrooj/service/storage');
|
|
||||||
await ctx.plugin(require('../service/hmr').default, { watch: argv.options.watch });
|
await ctx.plugin(require('../service/hmr').default, { watch: argv.options.watch });
|
||||||
await require('../service/worker').apply(ctx);
|
await Promise.all([
|
||||||
await require('../service/server').apply(ctx);
|
ctx.loader.reloadPlugin(require.resolve('../service/storage'), 'file', 'hydrooj/service/storage'),
|
||||||
|
ctx.loader.reloadPlugin(require.resolve('../service/worker'), 'worker', 'hydrooj/service/worker'),
|
||||||
|
ctx.loader.reloadPlugin(require.resolve('../service/server'), 'server', 'hydrooj/service/server'),
|
||||||
|
]);
|
||||||
ctx = await new Promise((resolve) => {
|
ctx = await new Promise((resolve) => {
|
||||||
ctx.inject(['server'], (c) => {
|
ctx.inject(['server'], (c) => {
|
||||||
resolve(c);
|
resolve(c);
|
||||||
|
|||||||
@@ -183,12 +183,12 @@ class SystemConfigHandler extends SystemHandler {
|
|||||||
@requireSudo
|
@requireSudo
|
||||||
async get() {
|
async get() {
|
||||||
this.response.template = 'manage_config.html';
|
this.response.template = 'manage_config.html';
|
||||||
let value = this.ctx.get('config').configSource;
|
let value = this.ctx.config.configSource;
|
||||||
try {
|
try {
|
||||||
value = yaml.dump(Schema.intersect(this.ctx.get('config').settings)(yaml.load(value)));
|
value = yaml.dump(Schema.intersect(this.ctx.config.settings)(yaml.load(value)));
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
this.response.body = {
|
this.response.body = {
|
||||||
schema: Schema.intersect(this.ctx.get('config').settings).toJSON(),
|
schema: Schema.intersect(this.ctx.config.settings).toJSON(),
|
||||||
value,
|
value,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -202,7 +202,7 @@ class SystemConfigHandler extends SystemHandler {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new ValidationError('value');
|
throw new ValidationError('value');
|
||||||
}
|
}
|
||||||
await this.ctx.get('config').saveConfig(config);
|
await this.ctx.config.saveConfig(config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class WikiAboutHandler extends Handler {
|
|||||||
// TODO template engine
|
// TODO template engine
|
||||||
raw = raw.replace(/{{ name }}/g, this.domain.ui?.name || SystemModel.get('server.name')).trim();
|
raw = raw.replace(/{{ name }}/g, this.domain.ui?.name || SystemModel.get('server.name')).trim();
|
||||||
const lines = raw.split('\n');
|
const lines = raw.split('\n');
|
||||||
const sections = [];
|
const sections: { id: string, title: string, content: string }[] = [];
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
if (line.startsWith('# ')) {
|
if (line.startsWith('# ')) {
|
||||||
const id = line.split(' ')[1];
|
const id = line.split(' ')[1];
|
||||||
@@ -53,7 +53,7 @@ class LegacyModeHandler extends Handler {
|
|||||||
|
|
||||||
@param('legacy', Types.Boolean)
|
@param('legacy', Types.Boolean)
|
||||||
@param('nohint', Types.Boolean)
|
@param('nohint', Types.Boolean)
|
||||||
async get(domainId: string, legacy = false, nohint = false) {
|
async get({ }, legacy = false, nohint = false) {
|
||||||
this.session.legacy = legacy;
|
this.session.legacy = legacy;
|
||||||
this.session.nohint = nohint;
|
this.session.nohint = nohint;
|
||||||
this.back();
|
this.back();
|
||||||
@@ -74,7 +74,7 @@ class MarkdownHandler extends Handler {
|
|||||||
|
|
||||||
class SystemConfigSchemaHandler extends Handler {
|
class SystemConfigSchemaHandler extends Handler {
|
||||||
async get() {
|
async get() {
|
||||||
const schema = convert(Schema.intersect(this.ctx.get('config')!.settings) as any, true);
|
const schema = convert(Schema.intersect(this.ctx.config.settings) as any, true);
|
||||||
this.response.body = schema;
|
this.response.body = schema;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,7 @@ class RichMediaHandler extends Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async post({ domainId, items }) {
|
async post({ domainId, items }) {
|
||||||
const res = [];
|
const res: any[] = [];
|
||||||
for (const item of items || []) {
|
for (const item of items || []) {
|
||||||
if (item.domainId && item.domainId === domainId) delete item.domainId;
|
if (item.domainId && item.domainId === domainId) delete item.domainId;
|
||||||
if (item.type === 'user') res.push(this.renderUser(domainId, item).catch(() => ''));
|
if (item.type === 'user') res.push(this.renderUser(domainId, item).catch(() => ''));
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import path from 'path';
|
|||||||
import importMetaUrlPlugin from '@codingame/esbuild-import-meta-url-plugin';
|
import importMetaUrlPlugin from '@codingame/esbuild-import-meta-url-plugin';
|
||||||
import react from '@vitejs/plugin-react-swc';
|
import react from '@vitejs/plugin-react-swc';
|
||||||
import c2k from 'koa2-connect';
|
import c2k from 'koa2-connect';
|
||||||
import _ from 'lodash';
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { createServer } from 'vite';
|
import { createServer } from 'vite';
|
||||||
import { } from '@hydrooj/framework';
|
import { } from '@hydrooj/framework';
|
||||||
|
|||||||
Reference in new issue
Block a user