@@ -107,12 +107,15 @@ import apiurl from './../../apiurl';
107107import MarkdownEditor from ' ./../lib/MarkdownEditor.vue' ;
108108import ConfirmDelete from ' ./../lib/confirmDelete.vue' ;
109109
110+ import sha256 from ' js-sha256' ;
111+
110112export default {
111113 name: ' ProblemEdit' ,
112114 data () {
113115 return {
114116 title: ' ' ,
115117 mdContent: ' Loading...' ,
118+ mdContent_sha256: null ,
116119 contentLoading: true ,
117120 time: ' Unknown' ,
118121 memery: ' Unknown' ,
@@ -136,6 +139,7 @@ export default {
136139 this .disable = ! data .enabled ;
137140 this .html = data .allow_html ;
138141 this .contentLoading = false ;
142+ this .mdContent_sha256 = sha256 (this .mdContent );
139143 this .$axios
140144 .get (apiurl (' /problem/' + String (this .$route .params .id ) + ' /description' ))
141145 .then (detail => {
@@ -156,15 +160,19 @@ export default {
156160 this .$router .push (' /problem/' + this .$route .params .id );
157161 },
158162 submit () {
163+ let request_data = {
164+ title: this .title ,
165+ memory_limit: this .memery * 1000 ,
166+ time_limit: this .time ,
167+ allow_html: this .html ,
168+ enabled: ! this .disable
169+ };
170+ if (sha256 (this .mdContent ) !== this .mdContent_sha256 ) {
171+ request_data[' description' ] = this .mdContent ;
172+ }
173+ this .mdContent_sha256 = sha256 (this .mdContent );
159174 this .$axios
160- .patch (apiurl (' /problem/' + this .$route .params .id ), {
161- title: this .title ,
162- description: this .mdContent ,
163- memory_limit: this .memery * 1000 ,
164- time_limit: this .time ,
165- allow_html: this .html ,
166- enabled: ! this .disable
167- })
175+ .patch (apiurl (' /problem/' + this .$route .params .id ), request_data)
168176 .then (() => {
169177 this .$SegmentMessage .success (this , ' Your changes have been submitted' );
170178 })
0 commit comments