mirror of https://github.com/halo-dev/halo-admin
parent
65c3894321
commit
0bf3009f0f
|
@ -37,12 +37,12 @@
|
|||
@onRefreshTagIds="onRefreshTagIdsFromSetting"
|
||||
@onRefreshCategoryIds="onRefreshCategoryIdsFromSetting"
|
||||
@onRefreshPostMetas="onRefreshPostMetasFromSetting"
|
||||
@onSaved="onSaved"
|
||||
@onSaved="handleRestoreSavedStatus"
|
||||
/>
|
||||
|
||||
<AttachmentDrawer v-model="attachmentDrawerVisible" />
|
||||
|
||||
<footer-tool-bar :style="{ width: isSideMenu() && isDesktop() ? `calc(100% - ${sidebarOpened ? 256 : 80}px)` : '100%'}">
|
||||
<footer-tool-bar :style="{ width: isSideMenu() && isDesktop() ? `calc(100% - ${sidebarOpened ? 256 : 80}px)` : '100%' }">
|
||||
<a-space>
|
||||
<ReactiveButton
|
||||
type="danger"
|
||||
|
@ -99,7 +99,6 @@ export default {
|
|||
selectedTagIds: [],
|
||||
selectedCategoryIds: [],
|
||||
selectedMetas: [],
|
||||
isSaved: false,
|
||||
contentChanges: 0,
|
||||
draftSaving: false,
|
||||
previewSaving: false,
|
||||
|
@ -142,8 +141,6 @@ export default {
|
|||
|
||||
if (this.contentChanges <= 1) {
|
||||
next()
|
||||
} else if (this.isSaved) {
|
||||
next()
|
||||
} else {
|
||||
this.$confirm({
|
||||
title: '当前页面数据未保存,确定要离开吗?',
|
||||
|
@ -195,6 +192,9 @@ export default {
|
|||
if (draftOnly) {
|
||||
postApi
|
||||
.updateDraft(this.postToStage.id, this.postToStage.originalContent)
|
||||
.then((response) => {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
@close="sheetSettingVisible = false"
|
||||
@onRefreshSheet="onRefreshSheetFromSetting"
|
||||
@onRefreshSheetMetas="onRefreshSheetMetasFromSetting"
|
||||
@onSaved="onSaved"
|
||||
@onSaved="handleRestoreSavedStatus"
|
||||
/>
|
||||
|
||||
<AttachmentDrawer v-model="attachmentDrawerVisible" />
|
||||
|
@ -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 => <div style="color:red;">如果离开当面页面,你的数据很可能会丢失!</div>,
|
||||
content: (h) => <div style="color:red;">如果离开当面页面,你的数据很可能会丢失!</div>,
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue