mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
完善设置
This commit is contained in:
1 parent
fc0d9873a2
commit
7edb29d7b8
43 files changed
+219
-184
No files matched your search
@@ -43,20 +43,9 @@ class DiscussionHandler extends Handler {
|
||||
// TODO(twd2): do more visibility check eg. contest
|
||||
// TODO(twd2): exclude problem/contest discussions?
|
||||
// TODO(iceboy): continuation based pagination.
|
||||
if (type && docId) {
|
||||
if (type === 'problem') {
|
||||
const pdoc = await problem.getById(docId);
|
||||
if (!pdoc) throw new DiscussionNodeNotFoundError(type, docId);
|
||||
if (pdoc.hidden) this.checkPerm(PERM_VIEW_PROBLEM_HIDDEN);
|
||||
this.vnode = pdoc;
|
||||
} else if (type === 'contest') {
|
||||
const tdoc = await contest.get(docId);
|
||||
if (!tdoc) throw new DiscussionNodeNotFoundError(type, docId);
|
||||
this.vnode = tdoc;
|
||||
} else throw new DiscussionNodeNotFoundError(type, docId);
|
||||
this.vnode.parentType = type;
|
||||
this.vnode.parentId = docId;
|
||||
}
|
||||
this.vnode = await discussion.getVnode({ parentType: type, parentId: docId }, this);
|
||||
this.ddoc.parentType = this.ddoc.parentType || this.vnode.type;
|
||||
this.ddoc.parentId = this.ddoc.parentId || this.vnode.id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -186,9 +186,17 @@ class ManageSettingHandler extends ManageHandler {
|
||||
}
|
||||
|
||||
async post(args) {
|
||||
const tasks = [];
|
||||
for (const key in args) {
|
||||
await system.set(key, args[key]);
|
||||
if (typeof args[key] === 'object') {
|
||||
const subtasks = [];
|
||||
for (const sub in args[key]) {
|
||||
subtasks.push(system.set(`${key}.${sub}`, args[key][sub]));
|
||||
}
|
||||
tasks.push(Promise.all(subtasks));
|
||||
} else tasks.push(system.set(key, args[key]));
|
||||
}
|
||||
await Promise.all(tasks);
|
||||
this.back();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user