mirror of https://github.com/halo-dev/halo-admin
Fixed #6
parent
5aed421693
commit
4713436d03
|
@ -28,8 +28,8 @@
|
||||||
:width="isMobile()?'100%':'460'"
|
:width="isMobile()?'100%':'460'"
|
||||||
placement="right"
|
placement="right"
|
||||||
closable
|
closable
|
||||||
@close="onClose"
|
@close="()=>this.postSettingVisible=false"
|
||||||
:visible="visible"
|
:visible="postSettingVisible"
|
||||||
>
|
>
|
||||||
<div class="post-setting-drawer-content">
|
<div class="post-setting-drawer-content">
|
||||||
<div :style="{ marginBottom: '16px' }">
|
<div :style="{ marginBottom: '16px' }">
|
||||||
|
@ -143,7 +143,7 @@
|
||||||
<img
|
<img
|
||||||
class="img"
|
class="img"
|
||||||
:src="postToStage.thumbnail || '//i.loli.net/2019/05/05/5ccf007c0a01d.png'"
|
:src="postToStage.thumbnail || '//i.loli.net/2019/05/05/5ccf007c0a01d.png'"
|
||||||
@click="handleShowThumbDrawer"
|
@click="()=>this.thumDrawerVisible=true"
|
||||||
>
|
>
|
||||||
<a-button
|
<a-button
|
||||||
class="post-thum-remove"
|
class="post-thum-remove"
|
||||||
|
@ -177,11 +177,11 @@
|
||||||
<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-button
|
<a-button
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="handleShowDrawer"
|
@click="()=>this.postSettingVisible = true"
|
||||||
>发布</a-button>
|
>发布</a-button>
|
||||||
<a-button
|
<a-button
|
||||||
type="dashed"
|
type="dashed"
|
||||||
@click="handleShowAttachDrawer"
|
@click="()=>this.attachmentDrawerVisible = true"
|
||||||
style="margin-left: 8px;"
|
style="margin-left: 8px;"
|
||||||
>附件库</a-button>
|
>附件库</a-button>
|
||||||
</footer-tool-bar>
|
</footer-tool-bar>
|
||||||
|
@ -222,7 +222,7 @@ export default {
|
||||||
xs: { span: 24 }
|
xs: { span: 24 }
|
||||||
},
|
},
|
||||||
attachmentDrawerVisible: false,
|
attachmentDrawerVisible: false,
|
||||||
visible: false,
|
postSettingVisible: false,
|
||||||
thumDrawerVisible: false,
|
thumDrawerVisible: false,
|
||||||
categoryForm: false,
|
categoryForm: false,
|
||||||
tags: [],
|
tags: [],
|
||||||
|
@ -245,6 +245,14 @@ export default {
|
||||||
clearInterval(this.timer)
|
clearInterval(this.timer)
|
||||||
this.timer = null
|
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) {
|
beforeRouteEnter(to, from, next) {
|
||||||
// Get post id from query
|
// Get post id from query
|
||||||
const postId = to.query.postId
|
const postId = to.query.postId
|
||||||
|
@ -300,16 +308,9 @@ export default {
|
||||||
this.createOrUpdatePost(() => this.$message.success('文章创建成功'), () => this.$message.success('文章更新成功'))
|
this.createOrUpdatePost(() => this.$message.success('文章创建成功'), () => this.$message.success('文章更新成功'))
|
||||||
},
|
},
|
||||||
autoSavePost() {
|
autoSavePost() {
|
||||||
this.createOrUpdatePost()
|
if (this.postToStage.title != null && this.postToStage.originalContent != null) {
|
||||||
},
|
this.createOrUpdatePost()
|
||||||
handleShowDrawer() {
|
}
|
||||||
this.visible = true
|
|
||||||
},
|
|
||||||
handleShowAttachDrawer() {
|
|
||||||
this.attachmentDrawerVisible = true
|
|
||||||
},
|
|
||||||
handleShowThumbDrawer() {
|
|
||||||
this.thumDrawerVisible = true
|
|
||||||
},
|
},
|
||||||
toggleCategoryForm() {
|
toggleCategoryForm() {
|
||||||
this.categoryForm = !this.categoryForm
|
this.categoryForm = !this.categoryForm
|
||||||
|
@ -331,9 +332,6 @@ export default {
|
||||||
this.categoryToCreate = {}
|
this.categoryToCreate = {}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onClose() {
|
|
||||||
this.visible = false
|
|
||||||
},
|
|
||||||
handleSelectPostThumb(data) {
|
handleSelectPostThumb(data) {
|
||||||
this.postToStage.thumbnail = data.path
|
this.postToStage.thumbnail = data.path
|
||||||
this.thumDrawerVisible = false
|
this.thumDrawerVisible = false
|
||||||
|
@ -345,14 +343,6 @@ export default {
|
||||||
}, 15000)
|
}, 15000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
beforeRouteLeave(to, from, next) {
|
|
||||||
if (this.timer !== null) {
|
|
||||||
clearInterval(this.timer)
|
|
||||||
}
|
|
||||||
// Auto save the post
|
|
||||||
this.autoSavePost()
|
|
||||||
next()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -32,8 +32,8 @@
|
||||||
title="页面设置"
|
title="页面设置"
|
||||||
:width="isMobile()?'100%':'460'"
|
:width="isMobile()?'100%':'460'"
|
||||||
:closable="true"
|
:closable="true"
|
||||||
@close="onClose"
|
@close="()=>this.sheetSettingVisible = false"
|
||||||
:visible="visible"
|
:visible="sheetSettingVisible"
|
||||||
>
|
>
|
||||||
<div class="post-setting-drawer-content">
|
<div class="post-setting-drawer-content">
|
||||||
<div :style="{ marginBottom: '16px' }">
|
<div :style="{ marginBottom: '16px' }">
|
||||||
|
@ -57,7 +57,10 @@
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="自定义模板:">
|
<a-form-item label="自定义模板:">
|
||||||
<a-select v-model="sheetToStage.template">
|
<a-select v-model="sheetToStage.template">
|
||||||
<a-select-option key="" value="">无</a-select-option>
|
<a-select-option
|
||||||
|
key=""
|
||||||
|
value=""
|
||||||
|
>无</a-select-option>
|
||||||
<a-select-option
|
<a-select-option
|
||||||
v-for="tpl in customTpls"
|
v-for="tpl in customTpls"
|
||||||
:key="tpl"
|
:key="tpl"
|
||||||
|
@ -77,7 +80,7 @@
|
||||||
<img
|
<img
|
||||||
class="img"
|
class="img"
|
||||||
:src="sheetToStage.thumbnail || '//i.loli.net/2019/05/05/5ccf007c0a01d.png'"
|
:src="sheetToStage.thumbnail || '//i.loli.net/2019/05/05/5ccf007c0a01d.png'"
|
||||||
@click="handleShowThumbDrawer"
|
@click="()=>this.thumDrawerVisible = true"
|
||||||
>
|
>
|
||||||
<a-button
|
<a-button
|
||||||
class="sheet-thum-remove"
|
class="sheet-thum-remove"
|
||||||
|
@ -87,7 +90,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<a-divider class="divider-transparent"/>
|
<a-divider class="divider-transparent" />
|
||||||
</div>
|
</div>
|
||||||
<AttachmentSelectDrawer
|
<AttachmentSelectDrawer
|
||||||
v-model="thumDrawerVisible"
|
v-model="thumDrawerVisible"
|
||||||
|
@ -111,12 +114,12 @@
|
||||||
<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-button
|
<a-button
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="handleShowDrawer"
|
@click="()=>this.sheetSettingVisible = true"
|
||||||
>发布</a-button>
|
>发布</a-button>
|
||||||
<a-button
|
<a-button
|
||||||
type="dashed"
|
type="dashed"
|
||||||
style="margin-left: 8px;"
|
style="margin-left: 8px;"
|
||||||
@click="handleShowAttachDrawer"
|
@click="()=>this.attachmentDrawerVisible = true"
|
||||||
>附件库</a-button>
|
>附件库</a-button>
|
||||||
</footer-tool-bar>
|
</footer-tool-bar>
|
||||||
</div>
|
</div>
|
||||||
|
@ -150,7 +153,7 @@ export default {
|
||||||
},
|
},
|
||||||
attachmentDrawerVisible: false,
|
attachmentDrawerVisible: false,
|
||||||
thumDrawerVisible: false,
|
thumDrawerVisible: false,
|
||||||
visible: false,
|
sheetSettingVisible: false,
|
||||||
customTpls: [],
|
customTpls: [],
|
||||||
sheetToStage: {},
|
sheetToStage: {},
|
||||||
timer: null
|
timer: null
|
||||||
|
@ -166,6 +169,14 @@ export default {
|
||||||
clearInterval(this.timer)
|
clearInterval(this.timer)
|
||||||
this.timer = null
|
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) {
|
beforeRouteEnter(to, from, next) {
|
||||||
// Get sheetId id from query
|
// Get sheetId id from query
|
||||||
const sheetId = to.query.sheetId
|
const sheetId = to.query.sheetId
|
||||||
|
@ -185,42 +196,42 @@ export default {
|
||||||
this.customTpls = response.data.data
|
this.customTpls = response.data.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleShowAttachDrawer() {
|
|
||||||
this.attachmentDrawerVisible = true
|
|
||||||
},
|
|
||||||
handleShowThumbDrawer() {
|
|
||||||
this.thumDrawerVisible = true
|
|
||||||
},
|
|
||||||
handleShowDrawer() {
|
|
||||||
this.visible = true
|
|
||||||
},
|
|
||||||
handlePublishClick() {
|
handlePublishClick() {
|
||||||
this.sheetToStage.status = 'PUBLISHED'
|
this.sheetToStage.status = 'PUBLISHED'
|
||||||
this.createOrUpdateSheet()
|
this.saveSheet()
|
||||||
},
|
},
|
||||||
handleDraftClick() {
|
handleDraftClick() {
|
||||||
this.sheetToStage.status = 'DRAFT'
|
this.sheetToStage.status = 'DRAFT'
|
||||||
this.createOrUpdateSheet()
|
this.saveSheet()
|
||||||
},
|
},
|
||||||
handlerRemoveThumb() {
|
handlerRemoveThumb() {
|
||||||
this.sheetToStage.thumbnail = null
|
this.sheetToStage.thumbnail = null
|
||||||
},
|
},
|
||||||
createOrUpdateSheet() {
|
createOrUpdateSheet(createSuccess, updateSuccess) {
|
||||||
if (this.sheetToStage.id) {
|
if (this.sheetToStage.id) {
|
||||||
sheetApi.update(this.sheetToStage.id, this.sheetToStage).then(response => {
|
sheetApi.update(this.sheetToStage.id, this.sheetToStage).then(response => {
|
||||||
this.$log.debug('Updated sheet', response.data.data)
|
this.$log.debug('Updated sheet', response.data.data)
|
||||||
this.$message.success('页面更新成功')
|
if (updateSuccess) {
|
||||||
|
updateSuccess()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
sheetApi.create(this.sheetToStage).then(response => {
|
sheetApi.create(this.sheetToStage).then(response => {
|
||||||
this.$log.debug('Created sheet', response.data.data)
|
this.$log.debug('Created sheet', response.data.data)
|
||||||
this.$message.success('页面创建成功')
|
if (createSuccess) {
|
||||||
|
createSuccess()
|
||||||
|
}
|
||||||
this.sheetToStage = response.data.data
|
this.sheetToStage = response.data.data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onClose() {
|
saveSheet() {
|
||||||
this.visible = false
|
this.createOrUpdateSheet(() => this.$message.success('页面创建成功'), () => this.$message.success('页面更新成功'))
|
||||||
|
},
|
||||||
|
autoSaveSheet() {
|
||||||
|
if (this.sheetToStage.title != null && this.sheetToStage.originalContent != null) {
|
||||||
|
this.createOrUpdateSheet()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
handleSelectSheetThumb(data) {
|
handleSelectSheetThumb(data) {
|
||||||
this.sheetToStage.thumbnail = data.path
|
this.sheetToStage.thumbnail = data.path
|
||||||
|
@ -229,21 +240,7 @@ export default {
|
||||||
autoSaveTimer() {
|
autoSaveTimer() {
|
||||||
if (this.timer == null) {
|
if (this.timer == null) {
|
||||||
this.timer = setInterval(() => {
|
this.timer = setInterval(() => {
|
||||||
if (this.sheetToStage.title != null && this.sheetToStage.originalContent != null) {
|
this.autoSaveSheet()
|
||||||
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
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 15000)
|
}, 15000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const webpack = require('webpack')
|
const webpack = require('webpack')
|
||||||
const GenerateAssetPlugin = require('generate-asset-webpack-plugin')
|
// const GenerateAssetPlugin = require('generate-asset-webpack-plugin')
|
||||||
|
|
||||||
function resolve(dir) {
|
function resolve(dir) {
|
||||||
return path.join(__dirname, dir)
|
return path.join(__dirname, dir)
|
||||||
|
|
Loading…
Reference in New Issue