Skip to content

Commit

Permalink
Merge pull request #9 from csthenry/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
csthenry authored Oct 3, 2023
2 parents d3ef48b + 9db4a16 commit fc65c7d
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 74 deletions.
112 changes: 62 additions & 50 deletions hoj-vue/src/components/oj/common/Announcements.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,59 +23,67 @@
>
</span>
</div>
<el-skeleton :rows="6" :loading="skeletonLoading" animated>
<transition-group name="el-zoom-in-bottom">
<div
class="no-announcement"
v-if="!announcements.length"
key="no-announcement"
>
<el-empty :description="$t('m.No_Announcements')"></el-empty>
</div>
<template v-if="listVisible">
<ul class="announcements-container" key="list">
<li v-for="announcement in announcements" :key="announcement.title">
<div class="flex-container">
<div class="title">
<a class="entry" @click="goAnnouncement(announcement)">
{{ announcement.title }}</a
>
</div>

<div class="info">
<span class="date">
<i class="el-icon-edit"></i>
{{ announcement.gmtCreate | localtime }}
</span>
<span class="creator">
<i class="el-icon-user"></i>
{{ announcement.username }}
</span>
</div>
</div>
</li>
</ul>
<Pagination
v-if="!isContest"
key="page"
:total="total"
:page-size="limit"
@on-change="getAnnouncementList"
>
</Pagination>
<el-skeleton :count="4" :loading="skeletonLoading" :throttle="skeletonDelay" animated>
<template slot="template">
<el-skeleton-item
variant="button"
style="margin-bottom:15px; width: 100%; height: 88px;"
/>
</template>
<template>
<transition-group name="el-zoom-in-bottom">
<div
class="no-announcement"
v-if="!announcements.length"
key="no-announcement"
>
<el-empty :description="$t('m.No_Announcements')"></el-empty>
</div>
<template v-if="listVisible">
<ul class="announcements-container" key="list">
<li v-for="announcement in announcements" :key="announcement.title">
<div class="flex-container">
<div class="title">
<a class="entry" @click="goAnnouncement(announcement)">
{{ announcement.title }}</a
>
</div>

<template v-else>
<div
v-katex
v-highlight
v-html="announcement.content"
key="content"
class="content-container markdown-body"
></div>
<div class="info">
<span class="date">
<i class="el-icon-edit"></i>
{{ announcement.gmtCreate | localtime }}
</span>
<span class="creator">
<i class="el-icon-user"></i>
{{ announcement.username }}
</span>
</div>
</div>
</li>
</ul>
<Pagination
v-if="!isContest"
key="page"
:total="total"
:page-size="limit"
@on-change="getAnnouncementList"
>
</Pagination>
</template>

<template v-else>
<div
v-katex
v-highlight
v-html="announcement.content"
key="content"
class="content-container markdown-body"
></div>
</template>
</transition-group>
</template>
</transition-group>
</el-skeleton>
</el-skeleton>
</el-card>
</template>

Expand All @@ -98,6 +106,7 @@ export default {
return {
total: 0,
skeletonLoading: true,
skeletonDelay: 0,
btnLoading: false,
announcements: [],
isMarkdownRender: [],
Expand All @@ -110,6 +119,9 @@ export default {
},
methods: {
init() {
if(this.total !== 0) {
this.skeletonDelay = 500;
}
if (this.isContest) {
this.getContestAnnouncementList();
} else {
Expand Down
6 changes: 3 additions & 3 deletions hoj-vue/src/components/oj/common/ProblemHorizontalMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,13 @@ export default {
ul {
margin: 0;
}
@media screen and (min-width: 1050px) {
/* @media screen and (min-width: 1050px) {
#problem-footer {
margin: 0 -1%;
}
}
} */
/deep/.el-card__body {
padding: 5px 0px !important;
padding: 5px !important;
}
.dataNav {
display: flex;
Expand Down
16 changes: 8 additions & 8 deletions hoj-vue/src/components/oj/group/Problem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,8 @@
auto-resize
:data="problem.testCaseScore"
align="center"
:sort-config="{trigger: 'cell',
defaultSort: {field: 'groupNum', order: 'asc'},
:sort-config="{trigger: 'cell',
defaultSort: {field: 'groupNum', order: 'asc'},
orders: ['desc', 'asc', null],
sortMethod: customSortMethod}"
>
Expand All @@ -675,7 +675,7 @@
>
</vxe-table-column>
<vxe-table-column
v-if="problem.judgeCaseMode == JUDGE_CASE_MODE.SUBTASK_LOWEST
v-if="problem.judgeCaseMode == JUDGE_CASE_MODE.SUBTASK_LOWEST
|| problem.judgeCaseMode == JUDGE_CASE_MODE.SUBTASK_AVERAGE"
field="groupNum"
:title="$t('m.Sample_Group_Num')"
Expand Down Expand Up @@ -782,7 +782,7 @@
</el-col>
<el-col
:span="24"
v-show="problem.judgeCaseMode == JUDGE_CASE_MODE.SUBTASK_LOWEST
v-show="problem.judgeCaseMode == JUDGE_CASE_MODE.SUBTASK_LOWEST
|| problem.judgeCaseMode == JUDGE_CASE_MODE.SUBTASK_AVERAGE"
>
<el-form-item :label="$t('m.Sample_Group_Num')">
Expand Down Expand Up @@ -1107,7 +1107,7 @@ export default {
this.codeTemplate = data;
},
"problem.spjLanguage"(newVal) {
if (this.allSpjLanguage.length) {
if (this.allSpjLanguage.length && this.problem.judgeMode != "default") {
this.spjMode = this.allSpjLanguage.find((item) => {
return item.name == this.problem.spjLanguage && item.isSpj == true;
})["contentType"];
Expand Down Expand Up @@ -1540,7 +1540,7 @@ export default {
return;
}
if (
(this.problem.judgeCaseMode == this.JUDGE_CASE_MODE.SUBTASK_LOWEST
(this.problem.judgeCaseMode == this.JUDGE_CASE_MODE.SUBTASK_LOWEST
|| this.problem.judgeCaseMode == this.JUDGE_CASE_MODE.SUBTASK_AVERAGE
) && this.problemSamples[i].groupNum == ""
) {
Expand Down Expand Up @@ -1592,7 +1592,7 @@ export default {
return;
}
if (
(this.problem.judgeCaseMode == this.JUDGE_CASE_MODE.SUBTASK_LOWEST
(this.problem.judgeCaseMode == this.JUDGE_CASE_MODE.SUBTASK_LOWEST
|| this.problem.judgeCaseMode == this.JUDGE_CASE_MODE.SUBTASK_AVERAGE
) && problemSamples[i].groupNum == ""
) {
Expand Down Expand Up @@ -1681,7 +1681,7 @@ export default {
if (problemLanguageList[i].name == lang.name) {
problemLanguageList[i] = lang;
if (this.codeTemplate[lang.name].status) {
if(this.codeTemplate[lang.name].code == null
if(this.codeTemplate[lang.name].code == null
|| this.codeTemplate[lang.name].code.length == 0){
mMessage.error(
lang.name +
Expand Down
15 changes: 11 additions & 4 deletions hoj-vue/src/views/oj/problem/Problem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1042,10 +1042,17 @@ export default {
if (codeTemplate && codeTemplate[lang]) {
//正则处理代码模板
this.enableCodeTemplate = true;
let reg = /([\s\S]*)\/\/TEMPLATE\sBEGIN\n([\s\S]*)\n\/\/TEMPLATE\sEND([\s\S]*)/;
this.templatePrefix = String(codeTemplate[lang]).replace(reg, "$1");
this.templateSuffix = String(codeTemplate[lang]).replace(reg, "$3");
codeTemplateSlice = String(codeTemplate[lang]).replace(reg, "$2");
//特判无模板标记的情况,则不进行模板分割
if(codeTemplate[lang].indexOf("//TEMPLATE BEGIN") == -1 || codeTemplate[lang].indexOf("//TEMPLATE END") == -1){
this.templatePrefix = "";
this.templateSuffix = "";
codeTemplateSlice = codeTemplate[lang];
} else {
let reg = /([\s\S]*)\/\/TEMPLATE\sBEGIN\n([\s\S]*)\n\/\/TEMPLATE\sEND([\s\S]*)/gms;
this.templatePrefix = String(codeTemplate[lang]).replace(reg, "$1");
this.templateSuffix = String(codeTemplate[lang]).replace(reg, "$3");
codeTemplateSlice = String(codeTemplate[lang]).replace(reg, "$2");
}
} else {
this.enableCodeTemplate = false;
this.templatePrefix = "";
Expand Down
43 changes: 34 additions & 9 deletions hoj-vue/src/views/oj/status/SubmissionDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@
</vxe-table>
</el-col>
<template v-if="testCaseResult != null">
<template v-if="testCaseResult.judgeCaseMode == JUDGE_CASE_MODE.DEFAULT
<template v-if="testCaseResult.judgeCaseMode == JUDGE_CASE_MODE.DEFAULT
|| testCaseResult.judgeCaseMode == JUDGE_CASE_MODE.ERGODIC_WITHOUT_ERROR ">
<el-col
:span="24"
v-if="testCaseResult != null
v-if="testCaseResult != null
&& testCaseResult.judgeCaseList != null
&& testCaseResult.judgeCaseList.length > 0"
>
Expand Down Expand Up @@ -279,7 +279,7 @@
v-if="submission.code"
>
<Highlight
:code="submission.code"
:code="displayCode"
:language="submission.language"
:border-color.sync="status.color"
></Highlight>
Expand Down Expand Up @@ -346,6 +346,7 @@ export default {
submitTime: "",
pid: "",
cid: "",
gid: "",
displayPid: "",
status: 0,
time: "",
Expand All @@ -355,6 +356,7 @@ export default {
errorMessage: "",
share: true,
},
displayCode: "",
tableData: [],
testCaseResult: {},
codeShare: true,
Expand All @@ -380,7 +382,7 @@ export default {
},
methods: {
doCopy() {
this.$copyText(this.submission.code).then(
this.$copyText(this.displayCode).then(
() => {
myMessage.success(this.$i18n.t("m.Copied_successfully"));
},
Expand All @@ -389,7 +391,33 @@ export default {
}
);
},
splitCodeTemplate(lang) {
let func =
this.$route.name === "ContestSubmissionDetails"
? "getContestProblem"
: "getProblem";
api[func](this.submission.displayPid, this.submission.cid, this.submission.gid, true).then((res) => {
let codeTemplate = res.data.data.codeTemplate;
if (codeTemplate && codeTemplate[lang]) {
//特判无模板标记的情况,则不进行模板分割
if (codeTemplate[lang].indexOf("//TEMPLATE BEGIN") == -1 || codeTemplate[lang].indexOf("//TEMPLATE END") == -1) {
this.displayCode = this.submission.code;
} else {
//正则处理代码模板
let reg = /([\s\S]*)\/\/TEMPLATE\sBEGIN\n([\s\S]*)\n\/\/TEMPLATE\sEND([\s\S]*)/gms;
let templatePrefix = String(codeTemplate[lang]).replace(reg, "$1");
let templateSuffix = String(codeTemplate[lang]).replace(reg, "$3");
this.displayCode = String(this.submission.code).replace(templatePrefix, "");
this.displayCode = String(this.displayCode).replace(templateSuffix, "");
}
} else {
this.displayCode = this.submission.code;
}
this.$nextTick((_) => {
addCodeBtn();
});
});
},
submissionTimeFormat(time) {
return utils.submissionTimeFormat(time);
},
Expand Down Expand Up @@ -465,17 +493,14 @@ export default {
data.submission.displayPid = this.$route.params.problemID;
}
this.submission = data.submission;
this.splitCodeTemplate(this.submission.language); //分离代码模板
this.tableData = [data.submission];
if (data.submission.cid != 0) {
// 比赛的提交不可分享
this.codeShare = false;
} else {
this.codeShare = data.codeShare;
}
this.$nextTick((_) => {
addCodeBtn();
});
},
() => {
this.loadingTable = false;
Expand Down

0 comments on commit fc65c7d

Please sign in to comment.