mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: fix #519
This commit is contained in:
1 parent
a0ef60bfeb
commit
4fe734a6f3
4 files changed
+8
-11
No files matched your search
+1
-1
@@ -6,7 +6,7 @@ ignorePatterns:
|
||||
- packages/ui-default
|
||||
overrides:
|
||||
- files:
|
||||
- '**/public/**/*.{ts,tsx,page.js}'
|
||||
- '**/{public,frontend}/**/*.{ts,tsx,page.js}'
|
||||
rules:
|
||||
'@typescript-eslint/indent':
|
||||
- warn
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "4.7.8",
|
||||
"version": "4.7.9",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/plugin-api",
|
||||
"module": "src/plugin-api",
|
||||
|
||||
@@ -99,27 +99,23 @@ class TrainingMainHandler extends Handler {
|
||||
class TrainingDetailHandler extends Handler {
|
||||
@param('tid', Types.ObjectID)
|
||||
@param('uid', Types.PositiveInt, true)
|
||||
async get(domainId: string, tid: ObjectID, uid: number) {
|
||||
async get(domainId: string, tid: ObjectID, uid = this.user._id) {
|
||||
const tdoc = await training.get(domainId, tid);
|
||||
await this.ctx.parallel('training/get', tdoc, this);
|
||||
let targetUser = this.user._id;
|
||||
let enrollUsers: number[] = [];
|
||||
let shouldCompare = false;
|
||||
const pids = training.getPids(tdoc.dag);
|
||||
if (this.user.hasPriv(PRIV.PRIV_USER_PROFILE)) {
|
||||
enrollUsers = (await training.getMultiStatus(domainId, { docId: tid, uid: { $gt: 1 } })
|
||||
.project({ uid: 1 }).limit(500).toArray()).map((x) => +x.uid);
|
||||
if (uid) {
|
||||
targetUser = uid;
|
||||
shouldCompare = targetUser !== this.user._id;
|
||||
}
|
||||
}
|
||||
shouldCompare = uid !== this.user._id;
|
||||
} else uid = this.user._id;
|
||||
const canViewHidden = this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN) || this.user._id;
|
||||
const [udoc, udict, pdict, psdict, selfPsdict] = await Promise.all([
|
||||
user.getById(domainId, tdoc.owner),
|
||||
user.getListForRender(domainId, enrollUsers),
|
||||
problem.getList(domainId, pids, canViewHidden, true),
|
||||
problem.getListStatus(domainId, targetUser, pids),
|
||||
problem.getListStatus(domainId, uid, pids),
|
||||
shouldCompare ? problem.getListStatus(domainId, this.user._id, pids) : {},
|
||||
]);
|
||||
const donePids = new Set<number>();
|
||||
|
||||
@@ -77,7 +77,8 @@ export async function buildUI() {
|
||||
const lazyModules: string[] = [];
|
||||
const newFiles = ['entry.js'];
|
||||
for (const addon of global.addons) {
|
||||
const publicPath = resolve(addon, 'public');
|
||||
let publicPath = resolve(addon, 'frontend');
|
||||
if (!fs.existsSync(publicPath)) publicPath = resolve(addon, 'public');
|
||||
if (!fs.existsSync(publicPath)) continue;
|
||||
const targets = fs.readdirSync(publicPath);
|
||||
for (const target of targets) {
|
||||
|
||||
Reference in new issue
Block a user