diff --git a/src/views/post/PostEdit.vue b/src/views/post/PostEdit.vue
index 5e790af7..56081b73 100644
--- a/src/views/post/PostEdit.vue
+++ b/src/views/post/PostEdit.vue
@@ -28,8 +28,8 @@
:width="isMobile()?'100%':'460'"
placement="right"
closable
- @close="onClose"
- :visible="visible"
+ @close="()=>this.postSettingVisible=false"
+ :visible="postSettingVisible"
>
@@ -143,7 +143,7 @@
![]()
this.thumDrawerVisible=true"
>
this.postSettingVisible = true"
>发布
this.attachmentDrawerVisible = true"
style="margin-left: 8px;"
>附件库
@@ -222,7 +222,7 @@ export default {
xs: { span: 24 }
},
attachmentDrawerVisible: false,
- visible: false,
+ postSettingVisible: false,
thumDrawerVisible: false,
categoryForm: false,
tags: [],
@@ -245,6 +245,14 @@ export default {
clearInterval(this.timer)
this.timer = null
},
+ beforeRouteLeave(to, from, next) {
+ if (this.timer !== null) {
+ clearInterval(this.timer)
+ }
+ // Auto save the post
+ this.autoSavePost()
+ next()
+ },
beforeRouteEnter(to, from, next) {
// Get post id from query
const postId = to.query.postId
@@ -300,16 +308,9 @@ export default {
this.createOrUpdatePost(() => this.$message.success('文章创建成功'), () => this.$message.success('文章更新成功'))
},
autoSavePost() {
- this.createOrUpdatePost()
- },
- handleShowDrawer() {
- this.visible = true
- },
- handleShowAttachDrawer() {
- this.attachmentDrawerVisible = true
- },
- handleShowThumbDrawer() {
- this.thumDrawerVisible = true
+ if (this.postToStage.title != null && this.postToStage.originalContent != null) {
+ this.createOrUpdatePost()
+ }
},
toggleCategoryForm() {
this.categoryForm = !this.categoryForm
@@ -331,9 +332,6 @@ export default {
this.categoryToCreate = {}
})
},
- onClose() {
- this.visible = false
- },
handleSelectPostThumb(data) {
this.postToStage.thumbnail = data.path
this.thumDrawerVisible = false
@@ -345,14 +343,6 @@ export default {
}, 15000)
}
}
- },
- beforeRouteLeave(to, from, next) {
- if (this.timer !== null) {
- clearInterval(this.timer)
- }
- // Auto save the post
- this.autoSavePost()
- next()
}
}
diff --git a/src/views/sheet/SheetEdit.vue b/src/views/sheet/SheetEdit.vue
index c72a489a..ef8d4f97 100644
--- a/src/views/sheet/SheetEdit.vue
+++ b/src/views/sheet/SheetEdit.vue
@@ -32,8 +32,8 @@
title="页面设置"
:width="isMobile()?'100%':'460'"
:closable="true"
- @close="onClose"
- :visible="visible"
+ @close="()=>this.sheetSettingVisible = false"
+ :visible="sheetSettingVisible"
>
@@ -57,7 +57,10 @@
- 无
+ 无
this.thumDrawerVisible = true"
>
-
+
this.sheetSettingVisible = true"
>发布
this.attachmentDrawerVisible = true"
>附件库
@@ -150,7 +153,7 @@ export default {
},
attachmentDrawerVisible: false,
thumDrawerVisible: false,
- visible: false,
+ sheetSettingVisible: false,
customTpls: [],
sheetToStage: {},
timer: null
@@ -166,6 +169,14 @@ export default {
clearInterval(this.timer)
this.timer = null
},
+ beforeRouteLeave(to, from, next) {
+ if (this.timer !== null) {
+ clearInterval(this.timer)
+ }
+ // Auto save the sheet
+ this.autoSaveSheet()
+ next()
+ },
beforeRouteEnter(to, from, next) {
// Get sheetId id from query
const sheetId = to.query.sheetId
@@ -185,42 +196,42 @@ export default {
this.customTpls = response.data.data
})
},
- handleShowAttachDrawer() {
- this.attachmentDrawerVisible = true
- },
- handleShowThumbDrawer() {
- this.thumDrawerVisible = true
- },
- handleShowDrawer() {
- this.visible = true
- },
handlePublishClick() {
this.sheetToStage.status = 'PUBLISHED'
- this.createOrUpdateSheet()
+ this.saveSheet()
},
handleDraftClick() {
this.sheetToStage.status = 'DRAFT'
- this.createOrUpdateSheet()
+ this.saveSheet()
},
handlerRemoveThumb() {
this.sheetToStage.thumbnail = null
},
- createOrUpdateSheet() {
+ createOrUpdateSheet(createSuccess, updateSuccess) {
if (this.sheetToStage.id) {
sheetApi.update(this.sheetToStage.id, this.sheetToStage).then(response => {
this.$log.debug('Updated sheet', response.data.data)
- this.$message.success('页面更新成功')
+ if (updateSuccess) {
+ updateSuccess()
+ }
})
} else {
sheetApi.create(this.sheetToStage).then(response => {
this.$log.debug('Created sheet', response.data.data)
- this.$message.success('页面创建成功')
+ if (createSuccess) {
+ createSuccess()
+ }
this.sheetToStage = response.data.data
})
}
},
- onClose() {
- this.visible = false
+ saveSheet() {
+ this.createOrUpdateSheet(() => this.$message.success('页面创建成功'), () => this.$message.success('页面更新成功'))
+ },
+ autoSaveSheet() {
+ if (this.sheetToStage.title != null && this.sheetToStage.originalContent != null) {
+ this.createOrUpdateSheet()
+ }
},
handleSelectSheetThumb(data) {
this.sheetToStage.thumbnail = data.path
@@ -229,21 +240,7 @@ export default {
autoSaveTimer() {
if (this.timer == null) {
this.timer = setInterval(() => {
- if (this.sheetToStage.title != null && this.sheetToStage.originalContent != null) {
- this.sheetToStage.categoryIds = this.selectedCategoryIds
- this.sheetToStage.tagIds = this.selectedTagIds
-
- if (this.sheetToStage.id) {
- sheetApi.update(this.sheetToStage.id, this.sheetToStage).then(response => {
- this.$log.debug('Auto updated sheet', response.data.data)
- })
- } else {
- sheetApi.create(this.sheetToStage).then(response => {
- this.$log.debug('Auto saved sheet', response.data.data)
- this.sheetToStage = response.data.data
- })
- }
- }
+ this.autoSaveSheet()
}, 15000)
}
}
diff --git a/vue.config.js b/vue.config.js
index 9f069749..7d2d38dc 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -1,6 +1,6 @@
const path = require('path')
const webpack = require('webpack')
-const GenerateAssetPlugin = require('generate-asset-webpack-plugin')
+// const GenerateAssetPlugin = require('generate-asset-webpack-plugin')
function resolve(dir) {
return path.join(__dirname, dir)