diff --git a/src/views/post/PostEdit.vue b/src/views/post/PostEdit.vue
index 644a76e7..c05afcf0 100644
--- a/src/views/post/PostEdit.vue
+++ b/src/views/post/PostEdit.vue
@@ -37,12 +37,12 @@
@onRefreshTagIds="onRefreshTagIdsFromSetting"
@onRefreshCategoryIds="onRefreshCategoryIdsFromSetting"
@onRefreshPostMetas="onRefreshPostMetasFromSetting"
- @onSaved="onSaved"
+ @onSaved="handleRestoreSavedStatus"
/>
-
+
{
+ this.handleRestoreSavedStatus()
+ })
.catch(() => {
this.draftSavederrored = true
})
@@ -206,11 +206,12 @@ export default {
} else {
postApi
.update(this.postToStage.id, this.postToStage, false)
- .catch(() => {
- this.draftSavederrored = true
- })
.then((response) => {
this.postToStage = response.data.data
+ this.handleRestoreSavedStatus()
+ })
+ .catch(() => {
+ this.draftSavederrored = true
})
.finally(() => {
setTimeout(() => {
@@ -222,11 +223,12 @@ export default {
// Create the post
postApi
.create(this.postToStage, false)
- .catch(() => {
- this.draftSavederrored = true
- })
.then((response) => {
this.postToStage = response.data.data
+ this.handleRestoreSavedStatus()
+ })
+ .catch(() => {
+ this.draftSavederrored = true
})
.finally(() => {
setTimeout(() => {
@@ -249,6 +251,7 @@ export default {
.preview(this.postToStage.id)
.then((response) => {
window.open(response.data, '_blank')
+ this.handleRestoreSavedStatus()
})
.finally(() => {
setTimeout(() => {
@@ -265,6 +268,7 @@ export default {
.preview(this.postToStage.id)
.then((response) => {
window.open(response.data, '_blank')
+ this.handleRestoreSavedStatus()
})
.finally(() => {
setTimeout(() => {
@@ -274,6 +278,9 @@ export default {
})
}
},
+ handleRestoreSavedStatus() {
+ this.contentChanges = 0
+ },
onContentChange(val) {
this.postToStage.originalContent = val
},
@@ -288,9 +295,6 @@ export default {
},
onRefreshPostMetasFromSetting(metas) {
this.selectedMetas = metas
- },
- onSaved(isSaved) {
- this.isSaved = isSaved
}
}
}
diff --git a/src/views/sheet/SheetEdit.vue b/src/views/sheet/SheetEdit.vue
index 22890b5b..c61e0a2a 100644
--- a/src/views/sheet/SheetEdit.vue
+++ b/src/views/sheet/SheetEdit.vue
@@ -33,7 +33,7 @@
@close="sheetSettingVisible = false"
@onRefreshSheet="onRefreshSheetFromSetting"
@onRefreshSheetMetas="onRefreshSheetMetasFromSetting"
- @onSaved="onSaved"
+ @onSaved="handleRestoreSavedStatus"
/>
@@ -92,7 +92,6 @@ export default {
sheetSettingVisible: false,
sheetToStage: {},
selectedMetas: [],
- isSaved: false,
contentChanges: 0,
draftSaving: false,
draftSavederrored: false,
@@ -103,9 +102,9 @@ export default {
// Get sheetId id from query
const sheetId = to.query.sheetId
- next(vm => {
+ next((vm) => {
if (sheetId) {
- sheetApi.get(sheetId).then(response => {
+ sheetApi.get(sheetId).then((response) => {
const sheet = response.data.data
vm.sheetToStage = sheet
vm.selectedMetas = sheet.metas
@@ -133,12 +132,10 @@ export default {
}
if (this.contentChanges <= 1) {
next()
- } else if (this.isSaved) {
- next()
} else {
this.$confirm({
title: '当前页面数据未保存,确定要离开吗?',
- content: h => 如果离开当面页面,你的数据很可能会丢失!
,
+ content: (h) => 如果离开当面页面,你的数据很可能会丢失!
,
onOk() {
next()
},
@@ -185,6 +182,9 @@ export default {
if (draftOnly) {
sheetApi
.updateDraft(this.sheetToStage.id, this.sheetToStage.originalContent)
+ .then((response) => {
+ this.handleRestoreSavedStatus()
+ })
.catch(() => {
this.draftSavederrored = true
})
@@ -196,12 +196,13 @@ export default {
} else {
sheetApi
.update(this.sheetToStage.id, this.sheetToStage, false)
+ .then((response) => {
+ this.sheetToStage = response.data.data
+ this.handleRestoreSavedStatus()
+ })
.catch(() => {
this.draftSavederrored = true
})
- .then(response => {
- this.sheetToStage = response.data.data
- })
.finally(() => {
setTimeout(() => {
this.draftSaving = false
@@ -211,12 +212,13 @@ export default {
} else {
sheetApi
.create(this.sheetToStage, false)
+ .then((response) => {
+ this.sheetToStage = response.data.data
+ this.handleRestoreSavedStatus()
+ })
.catch(() => {
this.draftSavederrored = true
})
- .then(response => {
- this.sheetToStage = response.data.data
- })
.finally(() => {
setTimeout(() => {
this.draftSaving = false
@@ -231,12 +233,13 @@ export default {
}
this.previewSaving = true
if (this.sheetToStage.id) {
- sheetApi.update(this.sheetToStage.id, this.sheetToStage, false).then(response => {
+ sheetApi.update(this.sheetToStage.id, this.sheetToStage, false).then((response) => {
this.$log.debug('Updated sheet', response.data.data)
sheetApi
.preview(this.sheetToStage.id)
- .then(response => {
+ .then((response) => {
window.open(response.data, '_blank')
+ this.handleRestoreSavedStatus()
})
.finally(() => {
setTimeout(() => {
@@ -245,13 +248,14 @@ export default {
})
})
} else {
- sheetApi.create(this.sheetToStage, false).then(response => {
+ sheetApi.create(this.sheetToStage, false).then((response) => {
this.$log.debug('Created sheet', response.data.data)
this.sheetToStage = response.data.data
sheetApi
.preview(this.sheetToStage.id)
- .then(response => {
+ .then((response) => {
window.open(response.data, '_blank')
+ this.handleRestoreSavedStatus()
})
.finally(() => {
setTimeout(() => {
@@ -261,6 +265,9 @@ export default {
})
}
},
+ handleRestoreSavedStatus() {
+ this.contentChanges = 0
+ },
onContentChange(val) {
this.sheetToStage.originalContent = val
},
@@ -269,9 +276,6 @@ export default {
},
onRefreshSheetMetasFromSetting(metas) {
this.selectedMetas = metas
- },
- onSaved(isSaved) {
- this.isSaved = isSaved
}
}
}