core: rename ConfigService to SettingService

This commit is contained in:
undefined committed 2025-06-08 21:42:03 +08:00
1 parent 82735ea3cb
commit c7117ef3ea
15 files changed
+59 -69

No files matched your search

+1 -1
View File
@@ -743,7 +743,7 @@ export async function apply(ctx: Context) {
await Promise.all(tasks);
});
ctx.plugin(ScoreboardService);
ctx.inject(['scoreboard'], ({ Route, scoreboard }) => {
await ctx.inject(['scoreboard'], ({ Route, scoreboard }) => {
Route('contest_scoreboard', '/contest/:tid/scoreboard', ContestScoreboardHandler, PERM.PERM_VIEW_CONTEST_SCOREBOARD);
Route('contest_scoreboard_view', '/contest/:tid/scoreboard/:view', ContestScoreboardHandler, PERM.PERM_VIEW_CONTEST_SCOREBOARD);
scoreboard.addView('default', 'Default', { tdoc: 'tdoc', groups: 'groups', realtime: Types.Boolean }, {
+1 -1
View File
@@ -461,7 +461,7 @@ export async function apply(ctx: Context) {
ctx.Route('domain_join_applications', '/domain/join_applications', DomainJoinApplicationsHandler);
ctx.Route('domain_join', '/domain/join', DomainJoinHandler, PRIV.PRIV_USER_PROFILE);
ctx.Route('domain_search', '/domain/search', DomainSearchHandler, PRIV.PRIV_USER_PROFILE);
ctx.inject(['api'], ({ api }) => {
await ctx.inject(['api'], ({ api }) => {
api.provide(DomainApi);
});
}
+1 -1
View File
@@ -314,7 +314,7 @@ export async function apply(ctx) {
ctx.Route('homework_edit', '/homework/:tid/edit', HomeworkEditHandler);
ctx.Route('homework_files', '/homework/:tid/file', HomeworkFilesHandler, PERM.PERM_VIEW_HOMEWORK);
ctx.Route('homework_file_download', '/homework/:tid/file/:filename', ContestFileDownloadHandler, PERM.PERM_VIEW_HOMEWORK);
ctx.inject(['scoreboard'], ({ Route }) => {
await ctx.inject(['scoreboard'], ({ Route }) => {
Route('homework_scoreboard', '/homework/:tid/scoreboard', ContestScoreboardHandler, PERM.PERM_VIEW_HOMEWORK_SCOREBOARD);
Route('homework_scoreboard_view', '/homework/:tid/scoreboard/:view', ContestScoreboardHandler, PERM.PERM_VIEW_HOMEWORK_SCOREBOARD);
});
+8 -8
View File
@@ -199,14 +199,14 @@ class SystemConfigHandler extends SystemHandler {
try {
try {
value = Schema.intersect(this.ctx.config.settings)(yaml.load(this.ctx.config.configSource));
value = Schema.intersect(this.ctx.setting.settings)(yaml.load(this.ctx.setting.configSource));
} catch (e) {
value = yaml.load(this.ctx.config.configSource);
value = yaml.load(this.ctx.setting.configSource);
}
for (const schema of this.ctx.config.settings) processNode(value, schema);
for (const schema of this.ctx.setting.settings) processNode(value, schema);
} catch (e) { }
this.response.body = {
schema: Schema.intersect(this.ctx.config.settings).toJSON(),
schema: Schema.intersect(this.ctx.setting.settings).toJSON(),
value: yaml.dump(value),
};
}
@@ -214,7 +214,7 @@ class SystemConfigHandler extends SystemHandler {
@requireSudo
@param('value', Types.String)
async post({ }, value: string) {
const oldConfig = yaml.load(this.ctx.config.configSource);
const oldConfig = yaml.load(this.ctx.setting.configSource);
let config;
const processNode = (node: any, old: any, schema: Schema<any, any>, parent?: any, accessKey?: string) => {
if (['union', 'intersect'].includes(schema.type)) {
@@ -231,11 +231,11 @@ class SystemConfigHandler extends SystemHandler {
try {
config = yaml.load(value);
for (const schema of this.ctx.config.settings) processNode(config, oldConfig, schema, null, '');
for (const schema of this.ctx.setting.settings) processNode(config, oldConfig, schema, null, '');
} catch (e) {
throw new ValidationError('value', '', e.message);
}
await this.ctx.config.saveConfig(config);
await this.ctx.setting.saveConfig(config);
}
}
@@ -357,7 +357,7 @@ class SystemUserPrivHandler extends SystemHandler {
}
}
export const inject = ['config', 'check'];
export const inject = ['setting', 'check'];
export async function apply(ctx) {
ctx.Route('manage', '/manage', SystemMainHandler);
ctx.Route('manage_dashboard', '/manage/dashboard', SystemDashboardHandler);
+1 -1
View File
@@ -1070,7 +1070,7 @@ export async function apply(ctx: Context) {
ctx.Route('problem_solution_reply_raw', '/p/:pid/solution/:psid/:psrid/raw', ProblemSolutionRawHandler, PERM.PERM_VIEW_PROBLEM);
ctx.Route('problem_statistics', '/p/:pid/stat', ProblemStatisticsHandler, PERM.PERM_VIEW_PROBLEM);
ctx.Route('problem_create', '/problem/create', ProblemCreateHandler, PERM.PERM_CREATE_PROBLEM);
ctx.inject(['api'], ({ api }) => {
await ctx.inject(['api'], ({ api }) => {
api.provide(ProblemApi);
});
}
+1 -1
View File
@@ -625,7 +625,7 @@ export async function apply(ctx: Context) {
throw new NotFoundError();
},
});
ctx.inject(['api'], ({ api }) => {
await ctx.inject(['api'], ({ api }) => {
api.provide(UserApi);
});
}