mirror of https://github.com/halo-dev/halo-admin
fix: the post will be prompted to save even if it is not modified.
parent
2b887e7a5a
commit
7df15e561a
|
@ -94,7 +94,8 @@ export default {
|
||||||
selectedTagIds: [],
|
selectedTagIds: [],
|
||||||
selectedCategoryIds: [],
|
selectedCategoryIds: [],
|
||||||
selectedPostMetas: [],
|
selectedPostMetas: [],
|
||||||
isSaved: false
|
isSaved: false,
|
||||||
|
contentChanges: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeRouteEnter(to, from, next) {
|
beforeRouteEnter(to, from, next) {
|
||||||
|
@ -131,7 +132,7 @@ export default {
|
||||||
this.attachmentDrawerVisible = false
|
this.attachmentDrawerVisible = false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.postToStage.originalContent) {
|
if (this.contentChanges <= 1) {
|
||||||
next()
|
next()
|
||||||
} else if (this.isSaved) {
|
} else if (this.isSaved) {
|
||||||
next()
|
next()
|
||||||
|
@ -157,7 +158,17 @@ export default {
|
||||||
return '当前页面数据未保存,确定要离开吗?'
|
return '当前页面数据未保存,确定要离开吗?'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
temporaryContent: function(newValue, oldValue) {
|
||||||
|
if (newValue) {
|
||||||
|
this.contentChanges++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
temporaryContent() {
|
||||||
|
return this.postToStage.originalContent
|
||||||
|
},
|
||||||
...mapGetters(['options'])
|
...mapGetters(['options'])
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -204,9 +215,6 @@ export default {
|
||||||
if (!this.postToStage.title) {
|
if (!this.postToStage.title) {
|
||||||
this.postToStage.title = moment(new Date()).format('YYYY-MM-DD-HH-mm-ss')
|
this.postToStage.title = moment(new Date()).format('YYYY-MM-DD-HH-mm-ss')
|
||||||
}
|
}
|
||||||
if (!this.postToStage.originalContent) {
|
|
||||||
this.postToStage.originalContent = '开始编辑...'
|
|
||||||
}
|
|
||||||
if (this.postToStage.id) {
|
if (this.postToStage.id) {
|
||||||
// Update the post
|
// Update the post
|
||||||
postApi.update(this.postToStage.id, this.postToStage, false).then(response => {
|
postApi.update(this.postToStage.id, this.postToStage, false).then(response => {
|
||||||
|
|
|
@ -85,7 +85,8 @@ export default {
|
||||||
sheetSettingVisible: false,
|
sheetSettingVisible: false,
|
||||||
sheetToStage: {},
|
sheetToStage: {},
|
||||||
selectedSheetMetas: [],
|
selectedSheetMetas: [],
|
||||||
isSaved: false
|
isSaved: false,
|
||||||
|
contentChanges: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeRouteEnter(to, from, next) {
|
beforeRouteEnter(to, from, next) {
|
||||||
|
@ -120,7 +121,7 @@ export default {
|
||||||
if (this.attachmentDrawerVisible) {
|
if (this.attachmentDrawerVisible) {
|
||||||
this.attachmentDrawerVisible = false
|
this.attachmentDrawerVisible = false
|
||||||
}
|
}
|
||||||
if (!this.sheetToStage.originalContent) {
|
if (this.contentChanges <= 1) {
|
||||||
next()
|
next()
|
||||||
} else if (this.isSaved) {
|
} else if (this.isSaved) {
|
||||||
next()
|
next()
|
||||||
|
@ -146,7 +147,17 @@ export default {
|
||||||
return '当前页面数据未保存,确定要离开吗?'
|
return '当前页面数据未保存,确定要离开吗?'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
temporaryContent: function(newValue, oldValue) {
|
||||||
|
if (newValue) {
|
||||||
|
this.contentChanges++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
temporaryContent() {
|
||||||
|
return this.sheetToStage.originalContent
|
||||||
|
},
|
||||||
...mapGetters(['options'])
|
...mapGetters(['options'])
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
Loading…
Reference in New Issue