Skip to content

Commit 6f7cba9

Browse files
committed
feat(Renderer): 现在除非主动拉取,否则不会进行重新拉取
修复了提交问题时的 BUG
1 parent f011189 commit 6f7cba9

11 files changed

+185
-69
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Codeforces Client
22

3-
**Copyleft ! 2020.Mauve,版权部分所有,遵循 GPL 授权使用**
3+
**Copyleft (ɔ) 2020.Mauve,版权部分所有,遵循 GPL 授权使用**
44

55
## Codeforces 打开好慢,加载题面好慢
66

@@ -26,7 +26,7 @@
2626
- [ ] css 自定义页面
2727
- [x] 加快获取 XCsrfToken(0.4.0)
2828
- [x] 题面中的链接使用本地浏览器打开(0.5.0)
29-
- [x] problemset 页面
29+
- [x] problemset 页面(1.0.0)
3030
- [ ] 多语言
3131
- [ ] 将项目转为 electron-vue 项目
3232

src/components/About.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
<a href="https://github.com/Hukeqing/codeforces-client/releases" target="_blank"
1010
style="text-decoration:none;color: #3a8ee6; margin-left: 40px">Latest Release</a>
1111
</h2>
12+
<p>当前的版本号为:1.0.0</p>
1213
<p style="margin-top: 120px; font-size: 14px">
13-
Copyleft ! 2020.Mauve,版权部分所有,遵循 GPL 授权使用
14+
Copyleft (ɔ) 2020.Mauve,版权部分所有,遵循 GPL 授权使用
1415
</p>
1516
</div>
1617
</template>

src/components/Contest.vue

+21-14
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,6 @@ let contest = require('../static/crawler/contest')
7979
export default {
8080
name: "Contest",
8181
82-
created() {
83-
this.myCid = this.contestId
84-
if (this.myCid !== '')
85-
this.getContest()
86-
},
87-
8882
data() {
8983
return {
9084
loading: false,
@@ -95,7 +89,18 @@ export default {
9589
},
9690
9791
props: {
98-
contestId: String
92+
contestId: String,
93+
wat: Boolean,
94+
},
95+
96+
watch: {
97+
wat: function (value) {
98+
if (value === true) {
99+
this.myCid = this.contestId
100+
if (this.myCid !== '')
101+
this.getContest()
102+
}
103+
}
99104
},
100105
101106
methods: {
@@ -131,20 +136,22 @@ export default {
131136
</script>
132137

133138
<style>
139+
.main {
140+
margin-top: 30px;
141+
margin-left: 30px;
142+
margin-right: 30px;
143+
}
144+
134145
.el-table .accept {
135146
background: #64ff64;
136147
}
137148
138149
.el-table .reject {
139150
background: #ff6464;
140151
}
141-
</style>
142-
143152
144-
<style scoped>
145-
.main {
146-
margin-top: 30px;
147-
margin-left: 30px;
148-
margin-right: 30px;
153+
.el-table tbody tr:hover > td {
154+
background-color: #96ffff !important;
155+
font-weight: bolder;
149156
}
150157
</style>

src/components/ContestList.vue

+15-7
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616
</div>
1717
</el-backtop>
1818
</template>
19+
<el-button type="primary" :disabled="curPage === 0" v-on:click="prePage" :loading="isLoading" v-if="notFetch">
20+
重新拉取
21+
</el-button>
1922
<template v-if="!notFetch">
20-
<el-table :data="contestList.slice(curPage * 20, (curPage + 1) * 20)"
23+
<el-table :data="contestList.slice(curPage * 40, (curPage + 1) * 40)"
2124
style="width: 100%"
2225
:row-class-name="getColor">
2326
<el-table-column
@@ -37,23 +40,23 @@
3740
align="center"
3841
min-width="200">
3942
<template slot-scope="scope">
40-
{{ getTime(contestList[scope.$index + curPage * 20].startTimeSeconds) }}
43+
{{ getTime(contestList[scope.$index + curPage * 40].startTimeSeconds) }}
4144
</template>
4245
</el-table-column>
4346
<el-table-column
4447
label="Length"
4548
align="center"
4649
min-width="100">
4750
<template slot-scope="scope">
48-
{{ getLengthTime(contestList[scope.$index + curPage * 20].durationSeconds) }}
51+
{{ getLengthTime(contestList[scope.$index + curPage * 40].durationSeconds) }}
4952
</template>
5053
</el-table-column>
5154
<el-table-column
5255
label="Status"
5356
align="center"
5457
min-width="100">
5558
<template slot-scope="scope">
56-
{{ contestList[scope.$index + curPage * 20].phase.toLowerCase() }}
59+
{{ contestList[scope.$index + curPage * 40].phase.toLowerCase() }}
5760
</template>
5861
</el-table-column>
5962
<el-table-column
@@ -62,8 +65,8 @@
6265
min-width="50">
6366
<template scope="scope">
6467
<el-button type="primary"
65-
v-on:click="clickContest(scope.$index + curPage * 20)"
66-
:disabled="enterButton(scope.$index + curPage * 20)">
68+
v-on:click="clickContest(scope.$index + curPage * 40)"
69+
:disabled="enterButton(scope.$index + curPage * 40)">
6770
进入
6871
</el-button>
6972
</template>
@@ -72,7 +75,7 @@
7275
<el-button-group style="margin-top: 30px">
7376
<el-button type="primary" icon="el-icon-arrow-left" :disabled="curPage === 0" v-on:click="prePage">上一页
7477
</el-button>
75-
<el-button type="primary" v-on:click="nextPage" :disabled="curPage >= contestList.length / 20 - 1">下一页<i
78+
<el-button type="primary" v-on:click="nextPage" :disabled="curPage >= contestList.length / 40 - 1">下一页<i
7679
class="el-icon-arrow-right el-icon--right"></i>
7780
</el-button>
7881
</el-button-group>
@@ -202,6 +205,11 @@ export default {
202205
.el-table .contestLine_system_finish {
203206
background: #ffffff;
204207
}
208+
209+
.el-table tbody tr:hover > td {
210+
background-color: #96ffff !important;
211+
font-weight: bolder;
212+
}
205213
</style>
206214

207215
<style scoped>

src/components/Home.vue

+24-10
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,19 @@
6666
</el-menu>
6767
</el-aside>
6868
<el-main>
69-
<Login v-if="status==='1'" :user="user" :logout="logout" v-on:login="login"></Login>
70-
<Submit v-if="status==='2'" :user="user" :contestId="contestId" :problemId="problemId" v-on:proMessage="proMessage"></Submit>
69+
<Login v-show="status==='1'" :user="user" :logout="logout" v-on:login="login"></Login>
70+
<Submit v-show="status==='2'" :user="user" :contestId="contestId" :problemId="problemId"
71+
:wat="watchAttr['2']"
72+
v-on:proMessage="proMessage"></Submit>
7173
<Status v-if="status==='3'" :user="user"></Status>
72-
<ContestList v-if="status==='4-1'" v-on:proMessage="proMessage"></ContestList>
73-
<Contest v-if="status==='4-2'" :contestId="contestId" v-on:proMessage="proMessage"></Contest>
74-
<ProblemSet v-if="status==='4-3'" v-on:proMessage="proMessage"></ProblemSet>
75-
<Problem v-if="status==='5'" :contestId="contestId" :problemId="problemId" v-on:proMessage="proMessage"></Problem>
76-
<LocalManager v-if="status==='6'"></LocalManager>
77-
<About v-if="status==='7'"></About>
74+
<ContestList v-show="status==='4-1'" v-on:proMessage="proMessage"></ContestList>
75+
<Contest v-show="status==='4-2'" :contestId="contestId" v-on:proMessage="proMessage"
76+
:wat="watchAttr['4-2']"></Contest>
77+
<ProblemSet v-show="status==='4-3'" v-on:proMessage="proMessage"></ProblemSet>
78+
<Problem v-show="status==='5'" :contestId="contestId" :problemId="problemId" :wat="watchAttr['5']"
79+
v-on:proMessage="proMessage"></Problem>
80+
<LocalManager v-show="status==='6'"></LocalManager>
81+
<About v-show="status==='7'"></About>
7882
</el-main>
7983
</el-container>
8084
</el-container>
@@ -100,7 +104,12 @@ export default {
100104
user: '',
101105
logout: '',
102106
contestId: '',
103-
problemId: ''
107+
problemId: '',
108+
watchAttr: {
109+
'2': false,
110+
'3': false,
111+
'4-2': false
112+
}
104113
}
105114
},
106115
@@ -118,6 +127,7 @@ export default {
118127
119128
methods: {
120129
changeSelect(index) {
130+
this.watchAttr[this.status] = false
121131
this.status = index
122132
},
123133
@@ -130,7 +140,11 @@ export default {
130140
proMessage(problem) {
131141
this.contestId = String(problem.contest)
132142
this.problemId = problem.id
133-
this.status = String(problem.next)
143+
if (this.status !== problem.next) {
144+
this.watchAttr[this.status] = false
145+
this.status = String(problem.next)
146+
this.watchAttr[problem.next] = true
147+
}
134148
},
135149
}
136150
}

src/components/LocalManager.vue

+8
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ export default {
9696
}
9797
</script>
9898

99+
100+
<style>
101+
.el-table tbody tr:hover > td {
102+
background-color: #96ffff !important;
103+
font-weight: bolder;
104+
}
105+
</style>
106+
99107
<style scoped>
100108
101109
</style>

src/components/Problem.vue

+15-7
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,6 @@ export default {
7878
name: "Problem",
7979
8080
created() {
81-
this.myCid = this.contestId
82-
this.myPid = this.problemId
83-
if (this.myCid === '' || this.myPid === '')
84-
return
85-
this.getProblem()
8681
},
8782
8883
data() {
@@ -99,7 +94,20 @@ export default {
9994
10095
props: {
10196
contestId: String,
102-
problemId: String
97+
problemId: String,
98+
wat: Boolean,
99+
},
100+
101+
watch: {
102+
wat: function (value) {
103+
if (value === true) {
104+
this.myCid = this.contestId
105+
this.myPid = this.problemId
106+
if (this.myCid === '' || this.myPid === '')
107+
return
108+
this.getProblem()
109+
}
110+
}
103111
},
104112
105113
methods: {
@@ -174,7 +182,7 @@ export default {
174182
this.$message.error('请输入题目的两个编号')
175183
return
176184
}
177-
this.$emit('proMessage', {contest: this.contestId, id: this.contestId, next: '2'})
185+
this.$emit('proMessage', {contest: this.contestId, id: this.problemId, next: '2'})
178186
}
179187
}
180188
}

src/components/ProblemSet.vue

+40-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
<template>
22
<div class="main">
3+
<template>
4+
<el-backtop>
5+
<div style="
6+
height: 100%;
7+
width: 100%;
8+
background-color: #64c8ff;
9+
box-shadow: 0 0 6px rgba(0,0,0, .12);
10+
text-align: center;
11+
line-height: 40px;
12+
color: #1989fa;
13+
border-radius: 30px;"
14+
><i class="el-icon-top"></i>
15+
</div>
16+
</el-backtop>
17+
</template>
318
<el-form ref="form" label-width="80px"
419
style="box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1); padding-top: 10px; padding-right: 20px; padding-bottom: 3px">
520
<el-form-item label="题目标签">
@@ -26,7 +41,7 @@
2641
v-model="sortValue"
2742
:options="sortOptions"
2843
:props="{ expandTrigger: 'hover' }"></el-cascader>
29-
<el-button type="primary" @click="getProblemSet" style="margin-left: 10px; width: 120px"
44+
<el-button type="primary" @click="fetchProblemSet" style="margin-left: 10px; width: 120px"
3045
:loading="loading">拉取
3146
</el-button>
3247
</el-form-item>
@@ -79,6 +94,14 @@
7994
</el-table-column>
8095
</el-table>
8196
</template>
97+
<div style="margin-top: 30px">
98+
99+
<el-input-number v-model="page" :min="1" :max="max_page" style="margin-left: 15px; margin-right: 15px"
100+
label="" :disabled="loading"></el-input-number>
101+
/ {{max_page}}
102+
103+
<el-button type="primary" style="margin-left: 15px" icon="el-icon-right" :loading="loading" v-on:click="getProblemSet" round></el-button>
104+
</div>
82105
</div>
83106
</template>
84107

@@ -164,11 +187,17 @@ export default {
164187
}]
165188
}
166189
],
167-
sortValue: ['0']
190+
sortValue: ['0'],
191+
page: 1,
192+
max_page: 1
168193
}
169194
},
170195
171196
methods: {
197+
fetchProblemSet() {
198+
this.page = 1
199+
this.getProblemSet()
200+
},
172201
getProblemSet() {
173202
this.notFetch = true
174203
this.loading = true
@@ -183,13 +212,15 @@ export default {
183212
args += ',' + this.score[0] + '-' + this.score[1]
184213
else
185214
args += 'tags=' + this.score[0] + '-' + this.score[1]
186-
problemSet.getProblemSetList(args, (e, p) => {
215+
problemSet.getProblemSetList(this.page, args, (e, p, m) => {
187216
if (e) {
188217
console.log(p)
189218
this.$message.error('拉取失败')
190219
} else {
191220
this.notFetch = false
192221
this.problems = p
222+
m = parseInt(m)
223+
this.max_page = m > this.page ? m : this.page
193224
}
194225
this.loading = false
195226
})
@@ -206,21 +237,22 @@ export default {
206237
clickProblem(index) {
207238
console.log(this.problems[index].id)
208239
this.$emit('proMessage', {contest: this.problems[index].contest, id: this.problems[index].id, next: '5'})
209-
}
240+
},
210241
}
211242
}
212243
</script>
213244

214245
<style scoped>
215-
.el-select {
216-
width: 100%;
217-
}
218-
219246
.el-table .accept {
220247
background: #64ff64;
221248
}
222249
223250
.el-table .reject {
224251
background: #ff6464;
225252
}
253+
254+
.el-table tbody tr:hover > td {
255+
background-color: #96ffff !important;
256+
font-weight: bolder;
257+
}
226258
</style>

0 commit comments

Comments
 (0)