From 16cc1e22d39a3a3db49901bca69604ce903ff982 Mon Sep 17 00:00:00 2001 From: johnniang Date: Wed, 8 May 2019 15:52:31 +0800 Subject: [PATCH 1/4] Fix login bug --- src/store/modules/user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/modules/user.js b/src/store/modules/user.js index ee43b841..0c46e311 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -40,7 +40,7 @@ const user = { }, actions: { loadUser({ commit }) { - return Promise((resolve, reject) => { + return new Promise((resolve, reject) => { userApi .getProfile() .then(response => { From 0922f72fee903ab5181cdd7f6946e7833d80cc4d Mon Sep 17 00:00:00 2001 From: johnniang Date: Wed, 8 May 2019 16:11:50 +0800 Subject: [PATCH 2/4] Optimize post edit autosave --- src/views/post/PostEdit.vue | 40 ++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/views/post/PostEdit.vue b/src/views/post/PostEdit.vue index dc944614..1dc5ae4e 100644 --- a/src/views/post/PostEdit.vue +++ b/src/views/post/PostEdit.vue @@ -271,7 +271,7 @@ export default { this.categories = response.data.data }) }, - createOrUpdatePost() { + createOrUpdatePost(createSuccess, updateSuccess) { // Set category ids this.postToStage.categoryIds = this.selectedCategoryIds // Set tag ids @@ -281,17 +281,27 @@ export default { // Update the post postApi.update(this.postToStage.id, this.postToStage).then(response => { this.$log.debug('Updated post', response.data.data) - this.$message.success('文章更新成功') + if (updateSuccess) { + updateSuccess() + } }) } else { // Create the post postApi.create(this.postToStage).then(response => { this.$log.debug('Created post', response.data.data) - this.$message.success('文章创建成功') + if (createSuccess) { + createSuccess() + } this.postToStage = response.data.data }) } }, + savePost() { + this.createOrUpdatePost(() => this.$message.success('文章创建成功'), () => this.$message.success('文章更新成功')) + }, + autoSavePost() { + this.createOrUpdatePost() + }, handleShowDrawer() { this.visible = true }, @@ -331,24 +341,18 @@ export default { autoSaveTimer() { if (this.timer == null) { this.timer = setInterval(() => { - if (this.postToStage.title != null && this.postToStage.originalContent != null) { - this.postToStage.categoryIds = this.selectedCategoryIds - this.postToStage.tagIds = this.selectedTagIds - - if (this.postToStage.id) { - postApi.update(this.postToStage.id, this.postToStage).then(response => { - this.$log.debug('Auto updated post', response.data.data) - }) - } else { - postApi.create(this.postToStage).then(response => { - this.$log.debug('Auto saved post', response.data.data) - this.postToStage = response.data.data - }) - } - } + this.autoSavePost() }, 15000) } } + }, + beforeRouteLeave(to, from, next) { + if (this.timer !== null) { + clearInterval(this.timer) + } + // Auto save the post + this.autoSavePost() + next() } } From afde5dc9f87e10c3a718833690f0819de45962a9 Mon Sep 17 00:00:00 2001 From: johnniang Date: Wed, 8 May 2019 17:49:19 +0800 Subject: [PATCH 3/4] Load user when option updating --- src/views/system/OptionForm.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/views/system/OptionForm.vue b/src/views/system/OptionForm.vue index 6dd7ea4d..d7a488a7 100644 --- a/src/views/system/OptionForm.vue +++ b/src/views/system/OptionForm.vue @@ -571,6 +571,7 @@ import AttachmentSelectDrawer from '../attachment/components/AttachmentSelectDra import optionApi from '@/api/option' import mailApi from '@/api/mail' import attachmentApi from '@/api/attachment' +import { mapActions } from 'vuex' export default { components: { @@ -598,6 +599,7 @@ export default { this.loadOptions() }, methods: { + ...mapActions(['loadUser']), loadOptions() { optionApi.listAll().then(response => { this.options = response.data.data @@ -607,11 +609,12 @@ export default { handleSaveOptions() { optionApi.save(this.options).then(response => { this.loadOptions() + this.loadUser() this.$message.success('保存成功!') }) }, handleAttachChange(e) { - switch (e.toUppper()) { + switch (e) { case 'LOCAL': case 'SMMS': this.upyunFormHidden = false From bb4f88bd03a9d20438012d756a6c5e029309d5aa Mon Sep 17 00:00:00 2001 From: johnniang Date: Wed, 8 May 2019 18:06:59 +0800 Subject: [PATCH 4/4] Fix xss attack for comment --- package-lock.json | 23 +- package.json | 1 + src/components/Tools/HeaderComment.vue | 12 +- src/views/comment/CommentList.vue | 3 + src/views/dashboard/Dashboard.vue | 9 +- yarn.lock | 11006 ----------------------- 6 files changed, 30 insertions(+), 11024 deletions(-) delete mode 100644 yarn.lock diff --git a/package-lock.json b/package-lock.json index c849680c..ee68a722 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10716,11 +10716,6 @@ "integrity": "sha1-vsECT4WxvZbL6kBbI8FK1kQ6b4E=", "dev": true }, - "lodash.get": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", - "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=" - }, "lodash.kebabcase": { "version": "4.1.1", "resolved": "http://registry.npm.taobao.org/lodash.kebabcase/download/lodash.kebabcase-4.1.1.tgz", @@ -10843,6 +10838,11 @@ "object-visit": "^1.0.0" } }, + "marked": { + "version": "0.6.2", + "resolved": "https://registry.npm.taobao.org/marked/download/marked-0.6.2.tgz", + "integrity": "sha1-xXS+i1Rai0hkFFbKHb4ON7bczBo=" + }, "math-random": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/math-random/-/math-random-1.0.4.tgz", @@ -13555,7 +13555,8 @@ "version": "4.0.8", "resolved": "http://registry.npm.taobao.org/rx-lite/download/rx-lite-4.0.8.tgz", "integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=", - "dev": true + "dev": true, + "optional": true }, "rx-lite-aggregates": { "version": "4.0.8", @@ -15485,11 +15486,6 @@ } } }, - "vue-fragment": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/vue-fragment/-/vue-fragment-1.5.0.tgz", - "integrity": "sha512-nobmbbOSOx59fm7U00BDz14Yvqitwx7NPQGYDTKg3+dNDGTDCRNy/q2kfr5hV4S0l4fQG0kvC+rbCmENLmHUSA==" - }, "vue-hot-reload-api": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/vue-hot-reload-api/-/vue-hot-reload-api-2.3.3.tgz", @@ -15558,11 +15554,6 @@ "integrity": "sha512-We9ZLSYPQx9y3v5+HNWyjkGFaxZMlWPTqYBU08y4YT46f453BQ4JxIoS8rV0a8PIxnKap7m/YIzrdIfoHxrpaA==", "dev": true }, - "vue-svg-component-runtime": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/vue-svg-component-runtime/-/vue-svg-component-runtime-1.0.1.tgz", - "integrity": "sha512-TkmZ1qwFeFJSRH6b6KVqDU2f8DCSdoNoo/veKqog7FsyF0UETTI66ALKX1rrLXy/KT6LSaJB5IfZkuuSfaQsEA==" - }, "vue-svg-icon-loader": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/vue-svg-icon-loader/-/vue-svg-icon-loader-2.1.1.tgz", diff --git a/package.json b/package.json index 005d0e01..28d8e6ae 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "ant-design-vue": "~1.3.7", "axios": "^0.18.0", "enquire.js": "^2.1.6", + "marked": "^0.6.2", "mavon-editor": "^2.7.2", "moment": "^2.24.0", "nprogress": "^0.2.0", diff --git a/src/components/Tools/HeaderComment.vue b/src/components/Tools/HeaderComment.vue index 5c180cb2..7fe7e8af 100644 --- a/src/components/Tools/HeaderComment.vue +++ b/src/components/Tools/HeaderComment.vue @@ -11,7 +11,7 @@ >