update fe

This commit is contained in:
Himit_ZH 2021-12-26 13:50:04 +08:00
parent f13330ee11
commit ab04560a37
12 changed files with 256 additions and 207 deletions

View File

@ -16,6 +16,7 @@ import top.hcode.hoj.pojo.vo.TrainingRankVo;
import top.hcode.hoj.pojo.vo.TrainingVo;
import top.hcode.hoj.pojo.vo.UserRolesVo;
import top.hcode.hoj.service.training.impl.*;
import top.hcode.hoj.utils.Constants;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@ -91,11 +92,6 @@ public class TrainingController {
return CommonResult.errorResponse("该训练不存在或不允许显示!");
}
CommonResult result = trainingRegisterService.checkTrainingAuth(training, request);
if (result != null) {
return result;
}
TrainingVo trainingVo = BeanUtil.copyProperties(training, TrainingVo.class);
TrainingCategory trainingCategory = trainingCategoryService.getTrainingCategoryByTrainingId(training.getId());
trainingVo.setCategoryName(trainingCategory.getName());
@ -106,9 +102,12 @@ public class TrainingController {
// 获取当前登录的用户
HttpSession session = request.getSession();
UserRolesVo userRolesVo = (UserRolesVo) session.getAttribute("userInfo");
if (userRolesVo != null) {
if (userRolesVo != null
&& trainingRegisterService.checkTrainingAuth(training, request) == null) {
Integer userTrainingACProblemCount = trainingProblemService.getUserTrainingACProblemCount(userRolesVo.getUid(), trainingProblemIdList);
trainingVo.setAcCount(userTrainingACProblemCount);
} else {
trainingVo.setAcCount(0);
}
return CommonResult.successResponse(trainingVo, "success");

View File

@ -53,6 +53,9 @@ mybatis-plus:
type-aliases-package: top.hcode.hoj.pojo.entity
configuration:
cache-enabled: false
# 关闭打印 mybatis-plus 的 LOGO
global-config:
banner: false
shiro-redis:
enabled: true

View File

@ -62,6 +62,9 @@ mybatis-plus:
type-aliases-package: top.hcode.hoj.pojo.entity
configuration:
cache-enabled: false
# 关闭打印 mybatis-plus 的 LOGO
global-config:
banner: false
shiro-redis:
enabled: true
redis-manager:

View File

@ -31,6 +31,9 @@ spring:
mybatis-plus:
mapper-locations: classpath*:top/hcode/hoj/dao/xml/**Mapper.xml
type-aliases-package: top.hcode.hoj.pojo.entity
# 关闭打印 mybatis-plus 的 LOGO
global-config:
banner: false
logging:

View File

@ -342,8 +342,8 @@ const ojApi = {
})
},
// 注册私有训练
registerTraining(tid, training){
return ajax('/api/register-contest','post',{
registerTraining(tid, password){
return ajax('/api/register-training','post',{
data:{
tid,
password

View File

@ -479,5 +479,8 @@ export const m = {
Training_Number:'Number',
Training_Auth:'Training Auth',
Training_Total_Problems:'Total Problems',
Record_List:'Record List'
Record_List:'Record List',
To_Enter_Training_Need_Password:'To enter the Private training, please input the password!',
Enter_the_training_password:'Enter the training password',
Register_training_successfully:'Register training successfully',
}

View File

@ -482,6 +482,8 @@ export const m = {
Training_Number:'训练编号',
Training_Auth:'训练权限',
Training_Total_Problems:'总题数',
Record_List:'记录榜单'
Record_List:'记录榜单',
To_Enter_Training_Need_Password:'请输入该私有训练的密码,方可进入',
Enter_the_training_password:'请输入私有训练的密码',
Register_training_successfully:'验证训练密码成功!',
}

View File

@ -1,7 +1,7 @@
import api from '@/common/api'
import { TRAINING_TYPE } from '@/common/constants'
const state = {
intoAccess: false, // 比赛进入权限
intoAccess: true, // 比赛进入权限
training: {
auth: TRAINING_TYPE.Public.name,
rankShowName:'username'
@ -33,7 +33,7 @@ const getters = {
// 是否需要显示密码验证框
trainingPasswordFormVisible: (state, getters) => {
// 如果是公开训练,或已注册过,管理员都不用再显示
return state.training.auth !== TRAINING_TYPE.Public.name &&!state.intoAccess && !getters.isTrainingAdmin
return !state.intoAccess && state.training.auth != TRAINING_TYPE.Public.name && !getters.isTrainingAdmin
}
}

View File

@ -187,6 +187,7 @@
field="realname"
min-width="96"
:title="$t('m.RealName')"
show-overflow
v-if="isContestAdmin"
>
</vxe-table-column>

View File

@ -192,6 +192,7 @@
min-width="96"
:title="$t('m.RealName')"
v-if="isContestAdmin"
show-overflow
>
</vxe-table-column>
<vxe-table-column

View File

@ -1,5 +1,5 @@
<template>
<el-row>
<div>
<el-card shadow class="training-header">
<div slot="header">
<span class="panel-title">{{ training.title }}</span>
@ -24,8 +24,8 @@
</div>
</template>
</el-card>
<el-tabs @tab-click="tabClick" v-model="route_name" class="card-top">
<div class="card-top">
<el-tabs @tab-click="tabClick" v-model="route_name">
<el-tab-pane name="TrainingDetails" lazy>
<span slot="label"
><i class="el-icon-s-home"></i>&nbsp;{{
@ -37,7 +37,6 @@
<el-card
v-if="trainingPasswordFormVisible"
class="password-form-card"
style="text-align:center"
>
<div slot="header">
<span class="panel-title" style="color: #e6a23c;"
@ -47,19 +46,20 @@
>
</div>
<h3>
{{ $t('m.To_Enter_Need_Password') }}
{{ $t('m.To_Enter_Training_Need_Password') }}
</h3>
<el-form>
<el-input
v-model="trainingPassword"
type="password"
:placeholder="$t('m.Enter_the_contest_password')"
:placeholder="$t('m.Enter_the_training_password')"
@keydown.enter.native="checkPassword"
style="width:70%"
/>
<el-button
type="primary"
@click="checkPassword"
:loading="btnLoading"
style="margin:5px"
>{{ $t('m.OK') }}</el-button
>
@ -162,7 +162,7 @@
<el-tab-pane
name="TrainingProblemList"
lazy
:disabled="contestMenuDisabled"
:disabled="trainingMenuDisabled"
>
<span slot="label"
><i class="fa fa-list" aria-hidden="true"></i>&nbsp;{{
@ -179,7 +179,7 @@
<el-tab-pane
name="TrainingRank"
lazy
:disabled="contestMenuDisabled"
:disabled="trainingMenuDisabled"
v-if="isPrivateTraining"
>
<span slot="label"
@ -192,18 +192,22 @@
</transition>
</el-tab-pane>
</el-tabs>
</el-row>
</div>
</div>
</template>
<script>
import { TRAINING_TYPE } from '@/common/constants';
import { mapState, mapGetters } from 'vuex';
import { mapState, mapGetters, mapActions } from 'vuex';
import myMessage from '@/common/message';
import api from '@/common/api';
export default {
data() {
return {
route_name: 'TrainingDetails',
TRAINING_TYPE: {},
trainingPassword: '',
btnLoading: false,
customColors: [
{ color: '#909399', percentage: 20 },
{ color: '#f56c6c', percentage: 40 },
@ -215,19 +219,39 @@ export default {
},
created() {
this.route_name = this.$route.name;
if (this.route_name == 'ProblemDetails') {
if (this.route_name == 'TrainingProblemDetails') {
this.route_name = 'TrainingProblemList';
}
this.TRAINING_TYPE = Object.assign({}, TRAINING_TYPE);
this.$store.dispatch('getTraining');
this.$store.dispatch('getTraining').then((res) => {
this.changeDomTitle({ title: res.data.data.title });
});
},
methods: {
...mapActions(['changeDomTitle']),
tabClick(tab) {
let name = tab.name;
if (name !== this.$route.name) {
this.$router.push({ name: name });
}
},
checkPassword() {
if (this.trainingPassword === '') {
myMessage.warning(this.$i18n.t('m.Enter_the_training_password'));
return;
}
this.btnLoading = true;
api.registerTraining(this.training.id + '', this.trainingPassword).then(
(res) => {
myMessage.success(this.$i18n.t('m.Register_training_successfully'));
this.$store.commit('trainingIntoAccess', { intoAccess: true });
this.btnLoading = false;
},
(res) => {
this.btnLoading = false;
}
);
},
goUserHome(username) {
this.$router.push({
name: 'UserHome',
@ -263,6 +287,15 @@ export default {
}
},
},
watch: {
$route(newVal) {
this.route_name = newVal.name;
if (newVal.name == 'TrainingProblemDetails') {
this.route_name = 'TrainingProblemList';
}
this.changeDomTitle({ title: this.training.title });
},
},
beforeDestroy() {
this.$store.commit('clearTraining');
},
@ -281,6 +314,10 @@ export default {
font-size: 18px;
font-weight: 700;
}
.password-form-card {
text-align: center;
margin-bottom: 15px;
}
.info-rows > * {
margin-bottom: var(--info-row-margin-bottom, 1em);

View File

@ -1,9 +1,9 @@
<template>
<div style="margin-top:5px">
<el-card shadow>
<div slot="header" class="rank-title">
<span class="panel-title">{{ $t('m.Record_List') }}</span>
</div>
<div>
<vxe-table
round
border
@ -89,6 +89,7 @@
field="realname"
min-width="96"
:title="$t('m.RealName')"
show-overflow
v-if="isTrainingAdmin"
>
</vxe-table-column>
@ -111,8 +112,8 @@
</vxe-table-column>
<vxe-table-column
min-width="70"
v-for="problem in trainingProblemList"
:key="problem.problemId"
v-for="(problem, index) in trainingProblemList"
:key="index"
>
<template v-slot:header>
<span
@ -125,7 +126,7 @@
>
</template>
<template v-slot="{ row }">
<span v-if="row.submissionInfo[problem.problemId]">
<template v-if="row.submissionInfo[problem.problemId]">
<span
class="judge-status"
:style="
@ -147,11 +148,10 @@
: 0
}}ms)
</span>
</span>
</template>
</template>
</vxe-table-column>
</vxe-table>
</div>
<Pagination
:total="total"
:page-size.sync="limit"
@ -161,6 +161,7 @@
:layout="'prev, pager, next, sizes'"
></Pagination>
</el-card>
</div>
</template>
<script>
import Avatar from 'vue-avatar';
@ -187,13 +188,11 @@ export default {
JUDGE_STATUS: {},
};
},
created() {
mounted() {
this.JUDGE_STATUS = Object.assign({}, JUDGE_STATUS);
if (!this.trainingProblemList.length) {
this.getTrainingProblemList();
}
},
mounted() {
this.trainingID = this.$route.params.trainingID;
this.getTrainingRankData();
},
@ -269,12 +268,10 @@ export default {
</script>
<style scoped>
.rank-title {
margin-bottom: 18px;
text-align: center;
}
/deep/.el-card__body {
padding: 20px !important;
padding-top: 0px !important;
}
.vxe-cell p,