core: switch to injectUI

This commit is contained in:
undefined committed 2024-02-23 07:15:57 +08:00
1 parent bdb86dd9f6
commit e44054aa40
4 files changed
+7 -8

No files matched your search

+4 -4
View File
@@ -46,7 +46,7 @@ const getLoader = (type: LoadTask, filename: string) => async function loader(pe
else logger.info(`${name} init: %s`, i);
} catch (e) {
fail.push(i);
app.inject(
app.injectUI(
'Notification', `${name} load fail: {0}`,
{ args: [i], type: 'warn' }, PRIV.PRIV_VIEW_SYSTEM_NOTIFICATION,
);
@@ -89,7 +89,7 @@ export async function locale(pending: string[], fail: string[]) {
logger.info('Locale init: %s', i);
} catch (e) {
fail.push(i);
app.inject('Notification', 'Locale load fail: {0}', { args: [i], type: 'warn' }, PRIV.PRIV_VIEW_SYSTEM_NOTIFICATION);
app.injectUI('Notification', 'Locale load fail: {0}', { args: [i], type: 'warn' }, PRIV.PRIV_VIEW_SYSTEM_NOTIFICATION);
logger.error('Locale Load Fail: %s', i);
logger.error(e);
}
@@ -131,7 +131,7 @@ export async function setting(pending: string[], fail: string[], modelSetting: t
}
logger.info('Config load: %s', i);
} catch (e) {
app.inject('Notification', 'Config load fail: {0}', { args: [i], type: 'warn' }, PRIV.PRIV_VIEW_SYSTEM_NOTIFICATION);
app.injectUI('Notification', 'Config load fail: {0}', { args: [i], type: 'warn' }, PRIV.PRIV_VIEW_SYSTEM_NOTIFICATION);
logger.error('Config Load Fail: %s', i);
logger.error(e);
}
@@ -155,7 +155,7 @@ export async function template(pending: string[], fail: string[]) {
logger.info('Template init: %s', i);
} catch (e) {
fail.push(i);
app.inject('Notification', 'Template load fail: {0}', { args: [i], type: 'warn' }, PRIV.PRIV_VIEW_SYSTEM_NOTIFICATION);
app.injectUI('Notification', 'Template load fail: {0}', { args: [i], type: 'warn' }, PRIV.PRIV_VIEW_SYSTEM_NOTIFICATION);
logger.error('Template Load Fail: %s', i);
logger.error(e);
}
+1 -1
View File
@@ -328,7 +328,7 @@ export class ContestScoreboardHandler extends ContestDetailBaseHandler {
if (!realtime && this.tdoc.lockAt && !this.tdoc.unlocked) {
config.lockAt = this.tdoc.lockAt;
}
const allGroups = this.user.hasPerm(PERM.PERM_EDIT_CONTEST_SELF) || (this.user.own(this.tdoc) && this.user.hasPerm(PERM.PERM_EDIT_CONTEST))
const allGroups = this.user.hasPerm(PERM.PERM_EDIT_CONTEST_SELF) || (this.user.own(this.tdoc) && this.user.hasPerm(PERM.PERM_EDIT_CONTEST));
const [[, rows, udict, pdict], groups] = await Promise.all([
contest.getScoreboard.call(this, domainId, tid, config),
user.listGroup(domainId, allGroups ? undefined : this.user._id),
+1 -1
View File
@@ -22,5 +22,5 @@ class ProblemImportHydroHandler extends Handler {
export async function apply(ctx: Context) {
ctx.Route('problem_import_hydro', '/problem/import/hydro', ProblemImportHydroHandler, PERM.PERM_CREATE_PROBLEM);
ctx.inject('ProblemAdd', 'problem_import_hydro', { icon: 'copy', text: 'Import From Hydro' });
ctx.injectUI('ProblemAdd', 'problem_import_hydro', { icon: 'copy', text: 'Import From Hydro' });
}
+1 -2
View File
@@ -18,7 +18,6 @@ import { Context } from './context';
// eslint-disable-next-line import/no-duplicates
import { sleep, unwrapExports } from './utils';
import { PRIV } from './model/builtin';
import { inject } from './lib/ui';
const argv = cac().parse();
const logger = new Logger('loader');
@@ -130,7 +129,7 @@ export function addon(addonPath: string, prepend = false) {
} catch (e) {
logger.error(`Addon not found: ${addonPath}`);
logger.error(e);
inject('Notification', 'Addon not found: {0}', { args: [addonPath], type: 'warn' }, PRIV.PRIV_VIEW_SYSTEM_NOTIFICATION);
app.injectUI('Notification', 'Addon not found: {0}', { args: [addonPath], type: 'warn' }, PRIV.PRIV_VIEW_SYSTEM_NOTIFICATION);
}
}