Skip to content

Commit 7246acc

Browse files
committed
feat(Submission): 现在可以查看提交记录并且可以查看所有的可知数据了
1 parent f042088 commit 7246acc

File tree

5 files changed

+111
-22
lines changed

5 files changed

+111
-22
lines changed

src/components/About.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default {
5252
}
5353
},
5454
55-
created() {
55+
mounted() {
5656
fetch('https://api.github.com/repos/Hukeqing/codeforces-client/releases/latest').then(response => response.json()).then(json => {
5757
this.latestVersion = json.tag_name
5858
this.updateLink = json.html_url

src/components/Status.vue

Lines changed: 79 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,40 @@
107107
<el-input
108108
type="textarea"
109109
:rows="10"
110-
v-model="code"
110+
v-model="detail.source"
111111
class="rt-input"
112-
:disabled="true"
112+
readonly
113113
:autosize="{ minRows: 10 }">
114114
</el-input>
115+
<div v-for="data in detail.data" v-bind:key="data.id"
116+
style="box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04); border-radius: 4px; padding: 10px 10px 10px 10px">
117+
<h1>{{ data.id }}</h1>
118+
<p>
119+
Time: {{ data.timeConsumed }}ms &emsp;
120+
memory: {{ data.memoryConsumed }}KB &emsp;
121+
exitCode: {{ data.exitCode }}
122+
<br>
123+
Verdict: {{ data.verdict }}
124+
</p>
125+
<el-form label-position="left">
126+
<el-form-item label="Input">
127+
<el-input type="textarea" :autosize="{ minRows: 0 }" readonly
128+
v-model="data.input"></el-input>
129+
</el-form-item>
130+
<el-form-item label="Output">
131+
<el-input type="textarea" :autosize="{ minRows: 0 }" readonly
132+
v-model="data.output"></el-input>
133+
</el-form-item>
134+
<el-form-item label="Answer">
135+
<el-input type="textarea" :autosize="{ minRows: 0 }" readonly
136+
v-model="data.answer"></el-input>
137+
</el-form-item>
138+
<el-form-item label="comment">
139+
<el-input type="textarea" :autosize="{ minRows: 0 }" readonly
140+
v-model="data.checkerStdoutAndStderr"></el-input>
141+
</el-form-item>
142+
</el-form>
143+
</div>
115144
<span slot="footer" class="dialog-footer">
116145
<el-button type="primary" @click="submissionDialog = false">关 闭</el-button>
117146
</span>
@@ -123,6 +152,7 @@
123152
import {timeCycle} from '@/static/js/time'
124153
125154
let copy = require('../static/js/copy')
155+
let common = require('../static/crawler/common')
126156
let submission = require('../static/crawler/submission')
127157
128158
export default {
@@ -142,7 +172,7 @@ export default {
142172
curSubmission: '',
143173
onGetSubmission: false,
144174
submissionDialog: false,
145-
code: '',
175+
detail: {},
146176
timeOut: null
147177
}
148178
},
@@ -211,18 +241,54 @@ export default {
211241
},
212242
213243
openSubmit(index) {
214-
this.code = ''
215244
this.submissionDialog = true
216245
this.curSubmission = this.submits[index].id
217246
this.onGetSubmission = true
218-
submission.getSubmission(this.submits[index].contestId, this.submits[index].id, (e, r) => {
219-
this.onGetSubmission = false
220-
if (e) {
221-
console.log(r)
222-
this.$message.error('拉取出错')
223-
return
224-
}
225-
this.code = r
247+
// submission.getSubmission(this.submits[index].contestId, this.submits[index].id, (e, r) => {
248+
// this.onGetSubmission = false
249+
// if (e) {
250+
// console.log(r)
251+
// this.$message.error('拉取出错')
252+
// return
253+
// }
254+
// this.code = r
255+
// })
256+
this.detail = {}
257+
common.getXCsrfToken((e, x) => {
258+
submission.getSubmissionDetail(x, this.submits[index].id, (e, r) => {
259+
this.onGetSubmission = false
260+
if (e) {
261+
console.log(r)
262+
this.$message.error(r)
263+
return
264+
}
265+
r = JSON.parse(r)
266+
this.detail = {
267+
source: r.source,
268+
contestName: r.contestName,
269+
problemName: r.problemName,
270+
partyName: r.partyName,
271+
verdict: r.verdict,
272+
nextId: r.nextId,
273+
prevId: r.prevId,
274+
data: []
275+
}
276+
console.log(this.detail)
277+
for (let i = r['testCount']; i >= 1; --i) {
278+
this.detail.data.push({
279+
id: i,
280+
timeConsumed: r['timeConsumed#' + i],
281+
memoryConsumed: parseInt(r['memoryConsumed#' + i]) / 1024,
282+
exitCode: r['exitCode#' + i],
283+
verdict: r['verdict#' + i],
284+
input: r['input#' + i],
285+
output: r['output#' + i],
286+
answer: r['answer#' + i],
287+
checkerStdoutAndStderr: r['checkerStdoutAndStderr#' + i]
288+
})
289+
}
290+
console.log(this.detail)
291+
})
226292
})
227293
},
228294
@@ -236,7 +302,7 @@ export default {
236302
},
237303
238304
copyCode() {
239-
copy.copy(this.code)
305+
copy.copy(this.detail.source)
240306
this.$notify({
241307
title: '成功',
242308
message: '拷贝成功',

src/static/crawler/common.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ module.exports = {
2121
const $ = cheerio.load(b)
2222
let xCsrfToken = $('meta[name="X-Csrf-Token"]').prop('content');
2323
callback(false, xCsrfToken)
24-
console.log(xCsrfToken)
2524
} catch (e) {
2625
console.log('connection error')
2726
}

src/static/crawler/submission.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,29 @@ module.exports = {
3030
callback(true, '获取题面遇到意料之外的错误')
3131
}
3232
})
33+
},
34+
35+
getSubmissionDetail: function (xCsrfToken, submissionId, callback) {
36+
let data = {
37+
submissionId: submissionId,
38+
csrf_token: xCsrfToken,
39+
};
40+
41+
let opts = {
42+
url: basic.url + 'data/submitSource',
43+
method: 'POST',
44+
headers: {
45+
'User-Agent': basic.userAgent
46+
},
47+
form: data
48+
}
49+
50+
request(opts, (e, r, b) => {
51+
if (r.statusCode !== 200) {
52+
callback(true, '提交编号越界')
53+
return
54+
}
55+
callback(false, b)
56+
})
3357
}
3458
}

src/static/css/status.css

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,32 @@
33
font-weight: bold;
44
}
55

6-
.verdict-accepted-challenged {
6+
.el-table .verdict-accepted-challenged {
77
background-color: #c8ffc8;
88
}
99

1010
.el-table .verdict-failed {
1111
background-color: #ffc8c8;
1212
}
1313

14-
.verdict-rejected {
15-
color: #00a;
14+
.el-table .verdict-rejected {
15+
color: #ffc8c8;
1616
}
1717

18-
.verdict-waiting {
18+
.el-table .verdict-waiting {
1919
color: #c8c8c8;
2020
}
2121

22-
.verdict-successful-challenge {
22+
.el-table .verdict-successful-challenge {
2323
font-weight: bold;
2424
background-color: #c8ffc8;
2525
}
2626

27-
.verdict-unsuccessful-challenge {
27+
.el-table .verdict-unsuccessful-challenge {
2828
color: #00a;
2929
}
3030

31-
.verdict-challenged {
31+
.el-table .verdict-challenged {
3232
background-color: #ffc8c8;
3333
font-weight: bold;
3434
}

0 commit comments

Comments
 (0)