mirror of https://github.com/halo-dev/halo-admin
feat: #52
parent
1eb4c2ee03
commit
9281630827
|
@ -8226,11 +8226,11 @@
|
|||
}
|
||||
},
|
||||
"halo-editor": {
|
||||
"version": "2.7.8",
|
||||
"resolved": "https://registry.npmjs.org/halo-editor/-/halo-editor-2.7.8.tgz",
|
||||
"integrity": "sha512-Okpnv3JQMDgQsxmKNTcSNfrvV8+FeeR2MhZ1hBhVp1yvDHFyujXENmaoGplQ/aUrnpebc4RiDAuHcB+Yla1S3Q==",
|
||||
"version": "2.7.6",
|
||||
"resolved": "https://registry.npmjs.org/halo-editor/-/halo-editor-2.7.6.tgz",
|
||||
"integrity": "sha512-ipzW+pxWoC3JB5jAlC/7fFZnqBbXMtC6eOXZDM1dtuM4BN60kOH/tzJMlLCuEYCzWnhg+abtwtljAtOe66ASGg==",
|
||||
"requires": {
|
||||
"highlight.js": "^9.16.2",
|
||||
"highlight.js": "^9.11.0",
|
||||
"highlight.js-async-webpack": "^1.0.4"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
"enquire.js": "^2.1.6",
|
||||
"filepond": "^4.7.2",
|
||||
"filepond-plugin-image-preview": "^4.5.0",
|
||||
"halo-editor": "^2.7.8",
|
||||
"halo-editor": "^2.7.6",
|
||||
"marked": "^0.7.0",
|
||||
"moment": "^2.24.0",
|
||||
"nprogress": "^0.2.0",
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<div style="margin-bottom: 16px">
|
||||
<a-input
|
||||
v-model="postToStage.title"
|
||||
v-decorator="['title', { rules: [{ required: true, message: '请输入文章标题' }] }]"
|
||||
size="large"
|
||||
placeholder="请输入文章标题"
|
||||
/>
|
||||
|
@ -36,6 +35,7 @@
|
|||
@onRefreshPost="onRefreshPostFromSetting"
|
||||
@onRefreshTagIds="onRefreshTagIdsFromSetting"
|
||||
@onRefreshCategoryIds="onRefreshCategoryIdsFromSetting"
|
||||
@onSaved="onSaved"
|
||||
/>
|
||||
|
||||
<AttachmentDrawer v-model="attachmentDrawerVisible" />
|
||||
|
@ -91,7 +91,8 @@ export default {
|
|||
postSettingVisible: false,
|
||||
postToStage: {},
|
||||
selectedTagIds: [],
|
||||
selectedCategoryIds: []
|
||||
selectedCategoryIds: [],
|
||||
isSaved: false
|
||||
}
|
||||
},
|
||||
beforeRouteEnter(to, from, next) {
|
||||
|
@ -115,7 +116,9 @@ export default {
|
|||
if (this.attachmentDrawerVisible) {
|
||||
this.attachmentDrawerVisible = false
|
||||
}
|
||||
window.onbeforeunload = null
|
||||
if (window.onbeforeunload) {
|
||||
window.onbeforeunload = null
|
||||
}
|
||||
},
|
||||
beforeRouteLeave(to, from, next) {
|
||||
if (this.postSettingVisible) {
|
||||
|
@ -124,24 +127,31 @@ export default {
|
|||
if (this.attachmentDrawerVisible) {
|
||||
this.attachmentDrawerVisible = false
|
||||
}
|
||||
if (this.postToStage.originalContent) {
|
||||
const answer = window.confirm('当前文章数据未保存,确定要离开吗?')
|
||||
if (answer) {
|
||||
next()
|
||||
} else {
|
||||
next(false)
|
||||
}
|
||||
} else {
|
||||
|
||||
if (!this.postToStage.originalContent) {
|
||||
next()
|
||||
} else if (this.isSaved) {
|
||||
next()
|
||||
} else {
|
||||
this.$confirm({
|
||||
title: '当前页面数据未保存,确定要离开吗?',
|
||||
content: h => <div style="color:red;">如果离开当面页面,你的数据很可能会丢失!</div>,
|
||||
onOk() {
|
||||
next()
|
||||
},
|
||||
onCancel() {
|
||||
next(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
window.onbeforeunload = function(e) {
|
||||
e = e || window.event
|
||||
if (e) {
|
||||
e.returnValue = '当前文章数据未保存,确定要离开吗?'
|
||||
e.returnValue = '当前页面数据未保存,确定要离开吗?'
|
||||
}
|
||||
return '当前文章数据未保存,确定要离开吗?'
|
||||
return '当前页面数据未保存,确定要离开吗?'
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -228,6 +238,9 @@ export default {
|
|||
},
|
||||
onRefreshCategoryIdsFromSetting(categoryIds) {
|
||||
this.selectedCategoryIds = categoryIds
|
||||
},
|
||||
onSaved(isSaved) {
|
||||
this.isSaved = isSaved
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -377,6 +377,7 @@ export default {
|
|||
this.$log.debug('Updated post', response.data.data)
|
||||
if (updateSuccess) {
|
||||
updateSuccess()
|
||||
this.$emit('onSaved', true)
|
||||
this.$router.push({ name: 'PostList' })
|
||||
}
|
||||
})
|
||||
|
@ -386,6 +387,7 @@ export default {
|
|||
this.$log.debug('Created post', response.data.data)
|
||||
if (createSuccess) {
|
||||
createSuccess()
|
||||
this.$emit('onSaved', true)
|
||||
this.$router.push({ name: 'PostList' })
|
||||
}
|
||||
this.selectedPost = response.data.data
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<div style="margin-bottom: 16px">
|
||||
<a-input
|
||||
v-model="sheetToStage.title"
|
||||
v-decorator="['title', { rules: [{ required: true, message: '请输入页面标题' }] }]"
|
||||
size="large"
|
||||
placeholder="请输入页面标题"
|
||||
/>
|
||||
|
@ -31,6 +30,7 @@
|
|||
:visible="sheetSettingVisible"
|
||||
@close="onSheetSettingsClose"
|
||||
@onRefreshSheet="onRefreshSheetFromSetting"
|
||||
@onSaved="onSaved"
|
||||
/>
|
||||
|
||||
<AttachmentDrawer v-model="attachmentDrawerVisible" />
|
||||
|
@ -82,7 +82,8 @@ export default {
|
|||
toolbars,
|
||||
attachmentDrawerVisible: false,
|
||||
sheetSettingVisible: false,
|
||||
sheetToStage: {}
|
||||
sheetToStage: {},
|
||||
isSaved: false
|
||||
}
|
||||
},
|
||||
beforeRouteEnter(to, from, next) {
|
||||
|
@ -105,7 +106,9 @@ export default {
|
|||
if (this.attachmentDrawerVisible) {
|
||||
this.attachmentDrawerVisible = false
|
||||
}
|
||||
window.onbeforeunload = null
|
||||
if (window.onbeforeunload) {
|
||||
window.onbeforeunload = null
|
||||
}
|
||||
},
|
||||
beforeRouteLeave(to, from, next) {
|
||||
if (this.sheetSettingVisible) {
|
||||
|
@ -114,15 +117,21 @@ export default {
|
|||
if (this.attachmentDrawerVisible) {
|
||||
this.attachmentDrawerVisible = false
|
||||
}
|
||||
if (this.sheetToStage.originalContent) {
|
||||
const answer = window.confirm('当前页面数据未保存,确定要离开吗?')
|
||||
if (answer) {
|
||||
next()
|
||||
} else {
|
||||
next(false)
|
||||
}
|
||||
} else {
|
||||
if (!this.sheetToStage.originalContent) {
|
||||
next()
|
||||
} else if (this.isSaved) {
|
||||
next()
|
||||
} else {
|
||||
this.$confirm({
|
||||
title: '当前页面数据未保存,确定要离开吗?',
|
||||
content: h => <div style="color:red;">如果离开当面页面,你的数据很可能会丢失!</div>,
|
||||
onOk() {
|
||||
next()
|
||||
},
|
||||
onCancel() {
|
||||
next(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
@ -207,6 +216,9 @@ export default {
|
|||
},
|
||||
onRefreshSheetFromSetting(sheet) {
|
||||
this.sheetToStage = sheet
|
||||
},
|
||||
onSaved(isSaved) {
|
||||
this.isSaved = isSaved
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -222,6 +222,8 @@ export default {
|
|||
this.$log.debug('Updated sheet', response.data.data)
|
||||
if (updateSuccess) {
|
||||
updateSuccess()
|
||||
this.$emit('onSaved', true)
|
||||
this.$router.push({ name: 'SheetList' })
|
||||
}
|
||||
})
|
||||
} else {
|
||||
|
@ -229,6 +231,8 @@ export default {
|
|||
this.$log.debug('Created sheet', response.data.data)
|
||||
if (createSuccess) {
|
||||
createSuccess()
|
||||
this.$emit('onSaved', true)
|
||||
this.$router.push({ name: 'SheetList' })
|
||||
}
|
||||
this.selectedSheet = response.data.data
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue