@@ -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' ,
@@ -137,6 +140,7 @@ export default {
137140 this .disable = ! data .enabled ;
138141 this .html = data .allow_html ;
139142 this .contentLoading = false ;
143+ this .mdContent_sha256 = sha256 (this .mdContent );
140144 })
141145 .catch (err => {
142146 if (err .request .status === 404 ) {
@@ -152,15 +156,19 @@ export default {
152156 this .$router .push (' /problem/' + this .$route .params .id );
153157 },
154158 submit () {
159+ let request_data = {
160+ title: this .title ,
161+ memory_limit: this .memery * 1000 ,
162+ time_limit: this .time ,
163+ allow_html: this .html ,
164+ enabled: ! this .disable
165+ };
166+ if (sha256 (this .mdContent ) !== this .mdContent_sha256 ) {
167+ request_data[' description' ] = this .mdContent ;
168+ }
169+ this .mdContent_sha256 = sha256 (this .mdContent );
155170 this .$axios
156- .patch (apiurl (' /problem/' + this .$route .params .id ), {
157- title: this .title ,
158- description: this .mdContent ,
159- memory_limit: this .memery * 1000 ,
160- time_limit: this .time ,
161- allow_html: this .html ,
162- enabled: ! this .disable
163- })
171+ .patch (apiurl (' /problem/' + this .$route .params .id ), request_data)
164172 .then (() => {
165173 this .$SegmentMessage .success (this , ' Your changes have been submitted' );
166174 })
0 commit comments