From 56aafde4a86f6b021242c88ebd633c301a9e73b7 Mon Sep 17 00:00:00 2001 From: undefined Date: Sat, 26 Jun 2021 12:44:27 +0800 Subject: [PATCH] core: remove path section --- packages/hydrooj/package.json | 2 +- packages/hydrooj/src/handler/problem.ts | 53 +++---------------- .../ui-default/templates/partials/path.html | 19 ------- 3 files changed, 9 insertions(+), 65 deletions(-) delete mode 100644 packages/ui-default/templates/partials/path.html diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index 7e5f51fd3..e03ab704b 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "2.28.52", + "version": "2.28.53", "bin": "bin/hydrooj.js", "main": "dist/loader.js", "typings": "dist/loader.d.ts", diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index 8949d4c19..1054f72d0 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -8,7 +8,7 @@ import { ForbiddenError, } from '../error'; import { - ProblemDoc, User, PathComponent, ProblemStatusDoc, + ProblemDoc, User, ProblemStatusDoc, } from '../interface'; import paginate from '../lib/paginate'; import { isPid, parsePid as convertPid } from '../lib/validator'; @@ -35,7 +35,7 @@ export class ProblemHandler extends Handler { async cleanup() { if (this.response.template === 'problem_main.html' && this.request.json) { const { - path, page, pcount, ppcount, pdocs, psdict, category, + page, pcount, ppcount, pdocs, psdict, category, } = this.response.body; this.response.body = { title: this.renderTitle(category), @@ -45,10 +45,9 @@ export class ProblemHandler extends Handler { }), this.renderHTML('partials/problem_stat.html', { pcount }), this.renderHTML('partials/problem_lucky.html', { category }), - this.renderHTML('partials/path.html', { path }), ])).map((i) => ({ html: i })), raw: { - path, page, pcount, ppcount, pdocs, psdict, category, + page, pcount, ppcount, pdocs, psdict, category, }, }; } @@ -64,10 +63,6 @@ export class ProblemMainHandler extends ProblemHandler { // eslint-disable-next-line @typescript-eslint/no-shadow const query: FilterQuery = {}; let psdict = {}; - const path: PathComponent[] = [ - ['Hydro', 'homepage'], - ['problem_main', null], - ]; const search = global.Hydro.lib.problemSearch; let sort: number[]; if (category.length) { @@ -75,11 +70,7 @@ export class ProblemMainHandler extends ProblemHandler { for (const tag of category) query.$and.push({ tag }); } if (q) category.push(q); - if (category.length) { - this.extraTitleContent = category.join('+'); - path[1][1] = 'problem_main'; - path.push([category.join('+'), null, null, true]); - } + if (category.length) this.extraTitleContent = category.join('+'); if (q) { if (search) { const result = await search(domainId, q); @@ -108,7 +99,7 @@ export class ProblemMainHandler extends ProblemHandler { ); } this.response.body = { - path, page, pcount, ppcount, pdocs, psdict, category: category.join('+'), + page, pcount, ppcount, pdocs, psdict, category: category.join('+'), }; } @@ -197,11 +188,6 @@ export class ProblemDetailHandler extends ProblemHandler { pdoc: this.pdoc, udoc: this.udoc, title: this.pdoc.title, - path: [ - ['Hydro', 'homepage'], - ['problem_main', 'problem_main'], - [this.pdoc.title, null, null, true], - ], }; this.extraTitleContent = this.pdoc.title; } @@ -246,16 +232,9 @@ export class ProblemDetailHandler extends ProblemHandler { } export class ProblemSubmitHandler extends ProblemDetailHandler { - @param('pid', Types.Name, null, parsePid) - async get(domainId: string, pid: string | number) { + async get() { this.response.template = 'problem_submit.html'; this.response.body = { - path: [ - ['Hydro', 'homepage'], - ['problem_main', 'problem_main'], - [this.pdoc.title, 'problem_detail', { pid }, true], - ['problem_submit', null], - ], pdoc: this.pdoc, udoc: this.udoc, title: this.pdoc.title, @@ -312,14 +291,8 @@ export class ProblemManageHandler extends ProblemDetailHandler { } export class ProblemEditHandler extends ProblemManageHandler { - async get({ pid }) { + async get() { this.response.template = 'problem_edit.html'; - this.response.body.path = [ - ['Hydro', 'homepage'], - ['problem_main', 'problem_main'], - [this.pdoc.title, 'problem_detail', { pid }, true], - ['problem_edit', null], - ]; } @route('pid', Types.Name, null, parsePid) @@ -462,13 +435,8 @@ export class ProblemSolutionHandler extends ProblemDetailHandler { } const udict = await user.getList(domainId, uids); const pssdict = await solution.getListStatus(domainId, docids, this.user._id); - const path = [ - ['problem_main', 'problem_main'], - [this.pdoc.title, 'problem_detail', { pid: this.pdoc.pid || this.pdoc.docId }, true], - ['problem_solution', null], - ]; this.response.body = { - path, psdocs, page, pcount, pscount, udict, pssdict, pdoc: this.pdoc, + psdocs, page, pcount, pscount, udict, pssdict, pdoc: this.pdoc, }; await bus.serial('handler/solution/get', this); } @@ -569,11 +537,6 @@ export class ProblemCreateHandler extends Handler { async get() { this.response.template = 'problem_edit.html'; this.response.body = { - path: [ - ['Hydro', 'homepage'], - ['problem_main', 'problem_main'], - ['problem_create', null], - ], page_name: 'problem_create', }; } diff --git a/packages/ui-default/templates/partials/path.html b/packages/ui-default/templates/partials/path.html deleted file mode 100644 index 6dbc36085..000000000 --- a/packages/ui-default/templates/partials/path.html +++ /dev/null @@ -1,19 +0,0 @@ -
-{% if not no_path_section %} -
-
-
-
- {%- for c in path -%} - / {% if loop.index < path.length %}{{ c[0] if c[3] else _(c[0]) }}{% endif %} - {%- endfor %} -
-

{{ path[path.length - 1][0] if path[path.length - 1][3] else _(path[path.length - 1][0]) }}

-
-
- {% include "partials/hamburger.html" %} -
-
-
-{% endif %} -