mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
添加path_section
This commit is contained in:
1 parent
53a6dbeb1a
commit
a2600d5cc4
8 files changed
+67
-39
No files matched your search
@@ -31,7 +31,13 @@ GET('/p', requirePerm(PERM_VIEW_PROBLEM), async ctx => {
|
||||
if (ctx.query.category) q.category = ctx.query.category;
|
||||
if (!ctx.state.user.hasPerm(PERM_VIEW_PROBLEM_HIDDEN)) q.hidden = false;
|
||||
let pdocs = await problem.getMany(q, { pid: 1 }, page, constants.PROBLEM_PER_PAGE);
|
||||
ctx.body = { page, pdocs, category: '' };
|
||||
ctx.body = {
|
||||
path: [
|
||||
['Hydro', '/'],
|
||||
['problem_main', null]
|
||||
],
|
||||
page, pdocs, category: ''
|
||||
};
|
||||
});
|
||||
GET('/problem/random', requirePerm(PERM_VIEW_PROBLEM), async ctx => {
|
||||
let q = {};
|
||||
@@ -47,7 +53,14 @@ GET('/p/:pid', requirePerm(PERM_VIEW_PROBLEM), async ctx => {
|
||||
let pdoc = await problem.get({ pid, uid });
|
||||
if (pdoc.hidden) ctx.checkPerm(PERM_VIEW_PROBLEM_HIDDEN);
|
||||
let udoc = await user.getById(pdoc.owner);
|
||||
ctx.body = { pdoc, udoc, title: pdoc.title };
|
||||
ctx.body = {
|
||||
path: [
|
||||
['Hydro', '/'],
|
||||
['problem_main', '/p'],
|
||||
[pdoc.title, null, true]
|
||||
],
|
||||
pdoc, udoc, title: pdoc.title
|
||||
};
|
||||
});
|
||||
GET('/p/:pid/submit', requirePerm(PERM_SUBMIT_PROBLEM), async ctx => {
|
||||
ctx.templateName = 'problem_submit.html';
|
||||
@@ -56,7 +69,15 @@ GET('/p/:pid/submit', requirePerm(PERM_SUBMIT_PROBLEM), async ctx => {
|
||||
let pdoc = await problem.get({ pid, uid });
|
||||
if (pdoc.hidden) ctx.checkPerm(PERM_VIEW_PROBLEM_HIDDEN);
|
||||
let udoc = await user.getById(pdoc.owner);
|
||||
ctx.body = { pdoc, udoc, title: pdoc.title };
|
||||
ctx.body = {
|
||||
path: [
|
||||
['Hydro', '/'],
|
||||
['problem_main', '/p'],
|
||||
[pdoc.title, `/p/${pid}`, true],
|
||||
['problem_submit', null]
|
||||
],
|
||||
pdoc, udoc, title: pdoc.title
|
||||
};
|
||||
});
|
||||
POST('/p/:pid/submit', requirePerm(PERM_SUBMIT_PROBLEM), async ctx => {
|
||||
let rid = await record.add({
|
||||
@@ -74,13 +95,19 @@ GET('/p/:pid/settings', async ctx => {
|
||||
ctx.templateName = 'problem_settings.html';
|
||||
let pdoc = await problem.get({ pid: ctx.params.pid, uid: ctx.state.user._id });
|
||||
if (pdoc.hidden) ctx.checkPerm(PERM_VIEW_PROBLEM_HIDDEN);
|
||||
ctx.body = { pdoc };
|
||||
ctx.body = {
|
||||
path: [
|
||||
['Hydro', '/'],
|
||||
['problem_main', '/p'],
|
||||
[pdoc.title, `/p/${ctx.params.pid}`, true],
|
||||
['problem_settings', null]
|
||||
], pdoc
|
||||
};
|
||||
});
|
||||
POST('/p/:pid/settings', async ctx => {
|
||||
ctx.templateName = 'problem_settings.html';
|
||||
// TODO(masnn)
|
||||
let pdoc = await problem.get({ pid: ctx.params.pid, uid: ctx.state.user._id });
|
||||
ctx.body = { pdoc };
|
||||
ctx.back();
|
||||
});
|
||||
GET('/p/:pid/upload', async ctx => {
|
||||
ctx.templateName = 'problem_upload.html';
|
||||
@@ -123,7 +150,13 @@ GET('/p/:pid/data', async ctx => {
|
||||
});
|
||||
GET('/problem/create', requirePerm(PERM_CREATE_PROBLEM), async ctx => {
|
||||
ctx.templateName = 'problem_edit.html';
|
||||
ctx.body = { page_name: 'problem_create' };
|
||||
ctx.body = {
|
||||
path: [
|
||||
['Hydro', '/'],
|
||||
['problem_main', '/p'],
|
||||
['problem_create', null]
|
||||
], page_name: 'problem_create'
|
||||
};
|
||||
});
|
||||
POST('/problem/create', requirePerm(PERM_CREATE_PROBLEM), async ctx => {
|
||||
let { title, pid, content, hidden } = ctx.request.body;
|
||||
|
||||
+14
-2
@@ -21,7 +21,13 @@ GET('/r', async ctx => {
|
||||
udict[rdoc.uid] = await user.getById(rdoc.uid);
|
||||
pdict[rdoc.pid] = await problem.get({ pid: rdoc.pid, uid: ctx.state.user._id });
|
||||
}
|
||||
ctx.body = { page, rdocs, pdict, udict };
|
||||
ctx.body = {
|
||||
path: [
|
||||
['Hydro', '/'],
|
||||
['record_main', null]
|
||||
],
|
||||
page, rdocs, pdict, udict
|
||||
};
|
||||
});
|
||||
SOCKET('/record-conn', [], conn => {
|
||||
let tid = conn.params.tid;
|
||||
@@ -43,7 +49,13 @@ GET('/r/:rid', async ctx => {
|
||||
let rdoc = await record.get(rid);
|
||||
if (rdoc.hidden) ctx.checkPerm(PERM_VIEW_CONTEST_HIDDEN_SCOREBOARD);
|
||||
if (rdoc.uid != uid && !ctx.state.user.hasPerm(PERM_READ_RECORD_CODE)) rdoc.code = null;
|
||||
ctx.body = { rdoc, show_status: true };
|
||||
ctx.body = {
|
||||
path: [
|
||||
['Hydro', '/'],
|
||||
['record_detail', null]
|
||||
],
|
||||
rdoc, show_status: true
|
||||
};
|
||||
});
|
||||
SOCKET('/record-detail-conn', [], async conn => {
|
||||
let rdoc = await record.get(conn.params.rid);
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
<div class="header{% if no_path_section %} mini{% endif %}">
|
||||
<div class="header__content"><div class="row"><div class="columns">
|
||||
{% if domain_id == vj4.model.builtin.DOMAIN_ID_SYSTEM %}
|
||||
<a class="header__logo" href="{{ reverse_url('domain_main', domain_id=vj4.model.builtin.DOMAIN_ID_SYSTEM) }}" target="_self"></a>
|
||||
{% else %}
|
||||
<div class="header__logo--domain"><a href="{{ reverse_url('domain_main') }}" target="_self">{{ domain['name'] }}</a></div>
|
||||
<div class="header__logo--system"><a href="{{ reverse_url('domain_main', domain_id=vj4.model.builtin.DOMAIN_ID_SYSTEM) }}" target="_blank">Powered by Vijos</a></div>
|
||||
{% endif %}
|
||||
<a class="header__logo" href="/" target="_self"></a>
|
||||
</div></div></div>
|
||||
{% include "partials/path.html" %}
|
||||
</div>
|
||||
@@ -4,11 +4,11 @@
|
||||
<div class="media">
|
||||
<div class="media__body">
|
||||
<div class="location-path">
|
||||
{% for c in path_components %}
|
||||
/ {% if c[1] %}<a href="{{ c[1] }}">{{ c[0] }}</a>{% endif %}
|
||||
{% for c in path %}
|
||||
/ {% if c[1] %}<a href="{{ c[1] }}">{{ c[0] if c[2] else _(c[0]) }}</a>{% endif %}
|
||||
{%- endfor %}
|
||||
</div>
|
||||
<h1 class="location-current" data-emoji-enabled>{{ path_components[-1][0] }}</h1>
|
||||
<h1 class="location-current" data-emoji-enabled>{{ path[path.length - 1][0] if path[path.length - 1][0] else _(path[path.length - 1][0]) }}</h1>
|
||||
</div>
|
||||
<div class="media__right">
|
||||
{% include "partials/hamburger.html" %}
|
||||
|
||||
@@ -13,20 +13,11 @@ import Toolbar, {
|
||||
ToolbarSplitComponent as ToolbarSplit,
|
||||
} from './ToolbarComponent';
|
||||
|
||||
function isTestCaseDataValid(data) {
|
||||
return data.input.trim().length > 0 && data.output.trim().length > 0;
|
||||
}
|
||||
|
||||
function isPretestValid(state) {
|
||||
return _.some(state.tabs, id => isTestCaseDataValid(state.data[id]));
|
||||
}
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
pretestVisible: state.ui.pretest.visible,
|
||||
recordsVisible: state.ui.records.visible,
|
||||
isPosting: state.ui.isPosting,
|
||||
editorLang: state.editor.lang,
|
||||
pretestValid: isPretestValid(state.pretest),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
@@ -45,9 +36,7 @@ const mapDispatchToProps = dispatch => ({
|
||||
postPretest(context) {
|
||||
const state = context.store.getState();
|
||||
const { pretest } = state;
|
||||
const testCases = pretest.tabs
|
||||
.filter(tabId => isTestCaseDataValid(pretest.data[tabId]));
|
||||
// const titles = testCases.map(tabId => pretest.meta[tabId].title);
|
||||
const testCases = pretest.tabs;
|
||||
const inputs = testCases.map(tabId => pretest.data[tabId].input);
|
||||
const outputs = testCases.map(tabId => pretest.data[tabId].output);
|
||||
const req = request.post(Context.postPretestUrl, {
|
||||
@@ -123,7 +112,7 @@ export default class ScratchpadToolbarContainer extends React.PureComponent {
|
||||
</ToolbarItem>
|
||||
<ToolbarSplit />
|
||||
<ToolbarButton
|
||||
activated={this.props.pretestVisible}
|
||||
activated
|
||||
onClick={() => this.props.togglePanel('pretest')}
|
||||
data-global-hotkey="alt+p"
|
||||
data-tooltip={`${i18n('Toggle Pretest Panel')} (Alt+P)`}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"target": "ES6",
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
import { NamedPage } from 'vj/misc/PageLoader';
|
||||
import DomainSelectAutoComplete from 'vj/components/autocomplete/DomainSelectAutoComplete';
|
||||
|
||||
const page = new NamedPage('problem_copy', async () => {
|
||||
DomainSelectAutoComplete.getOrConstruct($('.section__body [name="src_domain_id"]'));
|
||||
});
|
||||
|
||||
export default page;
|
||||
@@ -0,0 +1,6 @@
|
||||
import { NamedPage } from 'vj/misc/PageLoader';
|
||||
|
||||
const page = new NamedPage('problem_import', async () => {
|
||||
});
|
||||
|
||||
export default page;
|
||||
Reference in new issue
Block a user