From eb67db2c8325983058cd0c5b2a0f5e7ddfcae05b Mon Sep 17 00:00:00 2001 From: gzezFISHER Date: Fri, 14 Aug 2020 10:50:36 +0800 Subject: [PATCH 1/3] optimize edit problem --- src/components/problem/edit.vue | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/components/problem/edit.vue b/src/components/problem/edit.vue index 37592ad9..71cd2dbd 100644 --- a/src/components/problem/edit.vue +++ b/src/components/problem/edit.vue @@ -107,12 +107,15 @@ import apiurl from './../../apiurl'; import MarkdownEditor from './../lib/MarkdownEditor.vue'; import ConfirmDelete from './../lib/confirmDelete.vue'; +const sha256 = require('js-sha256').sha256; + export default { name: 'ProblemEdit', data() { return { title: '', mdContent: 'Loading...', + mdContent_sha256: null, contentLoading: true, time: 'Unknown', memery: 'Unknown', @@ -137,6 +140,7 @@ export default { this.disable = !data.enabled; this.html = data.allow_html; this.contentLoading = false; + this.mdContent_sha256 = sha256(this.mdContent); }) .catch(err => { if (err.request.status === 404) { @@ -152,15 +156,20 @@ export default { this.$router.push('/problem/' + this.$route.params.id); }, submit() { + let request_data = { + title: this.title, + memory_limit: this.memery * 1000, + time_limit: this.time, + allow_html: this.html, + enabled: !this.disable + }; + if(sha256(this.mdContent) !== this.mdContent_sha256) { + request_data['description'] = this.mdContent; + } + this.mdContent_sha256 = sha256(this.mdContent); + console.log(typeof(request_data)); this.$axios - .patch(apiurl('/problem/' + this.$route.params.id), { - title: this.title, - description: this.mdContent, - memory_limit: this.memery * 1000, - time_limit: this.time, - allow_html: this.html, - enabled: !this.disable - }) + .patch(apiurl('/problem/' + this.$route.params.id), request_data) .then(() => { this.$SegmentMessage.success(this, 'Your changes have been submitted'); }) From a010ff03dec8ec7600d5302a2b688cfb23d3da28 Mon Sep 17 00:00:00 2001 From: gzezFISHER <57309829+gzezFISHER@users.noreply.github.com> Date: Fri, 14 Aug 2020 11:17:57 +0800 Subject: [PATCH 2/3] Update src/components/problem/edit.vue Co-authored-by: szdytom <33175397+szdytom@users.noreply.github.com> --- src/components/problem/edit.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/problem/edit.vue b/src/components/problem/edit.vue index 71cd2dbd..949ba7d2 100644 --- a/src/components/problem/edit.vue +++ b/src/components/problem/edit.vue @@ -107,7 +107,7 @@ import apiurl from './../../apiurl'; import MarkdownEditor from './../lib/MarkdownEditor.vue'; import ConfirmDelete from './../lib/confirmDelete.vue'; -const sha256 = require('js-sha256').sha256; +import sha256 from 'js-sha256'; export default { name: 'ProblemEdit', From b9681511321394dd38485301e4386b62914551de Mon Sep 17 00:00:00 2001 From: gzezFISHER <57309829+gzezFISHER@users.noreply.github.com> Date: Fri, 14 Aug 2020 11:18:44 +0800 Subject: [PATCH 3/3] Update edit.vue --- src/components/problem/edit.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/problem/edit.vue b/src/components/problem/edit.vue index 949ba7d2..03fa4214 100644 --- a/src/components/problem/edit.vue +++ b/src/components/problem/edit.vue @@ -167,7 +167,6 @@ export default { request_data['description'] = this.mdContent; } this.mdContent_sha256 = sha256(this.mdContent); - console.log(typeof(request_data)); this.$axios .patch(apiurl('/problem/' + this.$route.params.id), request_data) .then(() => {