mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +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 require('../model/system').runConfig();
|
||||
ctx = await new Promise((resolve) => {
|
||||
ctx.inject(['loader'], (c) => {
|
||||
ctx.inject(['loader', 'config'], (c) => {
|
||||
resolve(c);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -39,14 +39,16 @@ export async function apply(ctx: Context) {
|
||||
const modelSystem = require('../model/system');
|
||||
await modelSystem.runConfig();
|
||||
ctx = await new Promise((resolve) => {
|
||||
ctx.inject(['loader'], (c) => {
|
||||
ctx.inject(['loader', 'config'], (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 require('../service/worker').apply(ctx);
|
||||
await require('../service/server').apply(ctx);
|
||||
await Promise.all([
|
||||
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.inject(['server'], (c) => {
|
||||
resolve(c);
|
||||
|
||||
@@ -183,12 +183,12 @@ class SystemConfigHandler extends SystemHandler {
|
||||
@requireSudo
|
||||
async get() {
|
||||
this.response.template = 'manage_config.html';
|
||||
let value = this.ctx.get('config').configSource;
|
||||
let value = this.ctx.config.configSource;
|
||||
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) { }
|
||||
this.response.body = {
|
||||
schema: Schema.intersect(this.ctx.get('config').settings).toJSON(),
|
||||
schema: Schema.intersect(this.ctx.config.settings).toJSON(),
|
||||
value,
|
||||
};
|
||||
}
|
||||
@@ -202,7 +202,7 @@ class SystemConfigHandler extends SystemHandler {
|
||||
} catch (e) {
|
||||
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
|
||||
raw = raw.replace(/{{ name }}/g, this.domain.ui?.name || SystemModel.get('server.name')).trim();
|
||||
const lines = raw.split('\n');
|
||||
const sections = [];
|
||||
const sections: { id: string, title: string, content: string }[] = [];
|
||||
for (const line of lines) {
|
||||
if (line.startsWith('# ')) {
|
||||
const id = line.split(' ')[1];
|
||||
@@ -53,7 +53,7 @@ class LegacyModeHandler extends Handler {
|
||||
|
||||
@param('legacy', 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.nohint = nohint;
|
||||
this.back();
|
||||
@@ -74,7 +74,7 @@ class MarkdownHandler extends Handler {
|
||||
|
||||
class SystemConfigSchemaHandler extends Handler {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -116,7 +116,7 @@ class RichMediaHandler extends Handler {
|
||||
}
|
||||
|
||||
async post({ domainId, items }) {
|
||||
const res = [];
|
||||
const res: any[] = [];
|
||||
for (const item of items || []) {
|
||||
if (item.domainId && item.domainId === domainId) delete item.domainId;
|
||||
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 react from '@vitejs/plugin-react-swc';
|
||||
import c2k from 'koa2-connect';
|
||||
import _ from 'lodash';
|
||||
import fs from 'fs';
|
||||
import { createServer } from 'vite';
|
||||
import { } from '@hydrooj/framework';
|
||||
|
||||
Reference in new issue
Block a user