mirror of https://github.com/halo-dev/halo-admin
Support preview post and sheet.
parent
600f9d682e
commit
0723e5cc38
|
@ -1,5 +1,5 @@
|
|||
// eslint-disable-next-line
|
||||
import { BasicLayout, RouteView, BlankLayout, PageView } from '@/layouts'
|
||||
import { BasicLayout, PageView } from '@/layouts'
|
||||
|
||||
export const asyncRouterMap = [
|
||||
{
|
||||
|
|
|
@ -45,6 +45,10 @@
|
|||
type="danger"
|
||||
@click="handleSaveDraft"
|
||||
>保存草稿</a-button>
|
||||
<a-button
|
||||
@click="handlePreview"
|
||||
style="margin-left: 8px;"
|
||||
>预览</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
@click="handleShowPostSetting"
|
||||
|
@ -61,6 +65,7 @@
|
|||
|
||||
<script>
|
||||
import { mixin, mixinDevice } from '@/utils/mixin.js'
|
||||
import { mapGetters } from 'vuex'
|
||||
import moment from 'moment'
|
||||
import PostSetting from './components/PostSetting'
|
||||
import AttachmentDrawer from '../attachment/components/AttachmentDrawer'
|
||||
|
@ -125,6 +130,9 @@ export default {
|
|||
}
|
||||
next()
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['options'])
|
||||
},
|
||||
methods: {
|
||||
handleSaveDraft() {
|
||||
this.postToStage.status = 'DRAFT'
|
||||
|
@ -178,6 +186,29 @@ export default {
|
|||
handleShowPostSetting() {
|
||||
this.postSettingVisible = true
|
||||
},
|
||||
handlePreview() {
|
||||
this.postToStage.status = 'DRAFT'
|
||||
if (!this.postToStage.title) {
|
||||
this.postToStage.title = moment(new Date()).format('YYYY-MM-DD-HH-mm-ss')
|
||||
}
|
||||
if (!this.postToStage.originalContent) {
|
||||
this.postToStage.originalContent = '开始编辑...'
|
||||
}
|
||||
if (this.postToStage.id) {
|
||||
// Update the post
|
||||
postApi.update(this.postToStage.id, this.postToStage, false).then(response => {
|
||||
this.$log.debug('Updated post', response.data.data)
|
||||
window.open(`${this.options.blog_url}/api/admin/posts/preview/${this.postToStage.id}`, '_blank')
|
||||
})
|
||||
} else {
|
||||
// Create the post
|
||||
postApi.create(this.postToStage, false).then(response => {
|
||||
this.$log.debug('Created post', response.data.data)
|
||||
this.postToStage = response.data.data
|
||||
window.open(`${this.options.blog_url}/api/admin/posts/preview/${this.postToStage.id}`, '_blank')
|
||||
})
|
||||
}
|
||||
},
|
||||
// 关闭文章设置抽屉
|
||||
onPostSettingsClose() {
|
||||
this.postSettingVisible = false
|
||||
|
|
|
@ -39,6 +39,10 @@
|
|||
type="danger"
|
||||
@click="handleSaveDraft"
|
||||
>保存草稿</a-button>
|
||||
<a-button
|
||||
@click="handlePreview"
|
||||
style="margin-left: 8px;"
|
||||
>预览</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
style="margin-left: 8px;"
|
||||
|
@ -55,6 +59,7 @@
|
|||
|
||||
<script>
|
||||
import { mixin, mixinDevice } from '@/utils/mixin.js'
|
||||
import { mapGetters } from 'vuex'
|
||||
import moment from 'moment'
|
||||
import { toolbars } from '@/core/const'
|
||||
import SheetSetting from './components/SheetSetting'
|
||||
|
@ -115,6 +120,9 @@ export default {
|
|||
}
|
||||
next()
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['options'])
|
||||
},
|
||||
methods: {
|
||||
handleSaveDraft() {
|
||||
this.sheetToStage.status = 'DRAFT'
|
||||
|
@ -166,6 +174,27 @@ export default {
|
|||
handleShowSheetSetting() {
|
||||
this.sheetSettingVisible = true
|
||||
},
|
||||
handlePreview() {
|
||||
this.sheetToStage.status = 'DRAFT'
|
||||
if (!this.sheetToStage.title) {
|
||||
this.sheetToStage.title = moment(new Date()).format('YYYY-MM-DD-HH-mm-ss')
|
||||
}
|
||||
if (!this.sheetToStage.originalContent) {
|
||||
this.sheetToStage.originalContent = '开始编辑...'
|
||||
}
|
||||
if (this.sheetToStage.id) {
|
||||
sheetApi.update(this.sheetToStage.id, this.sheetToStage, false).then(response => {
|
||||
this.$log.debug('Updated sheet', response.data.data)
|
||||
window.open(`${this.options.blog_url}/api/admin/sheets/preview/${this.sheetToStage.id}`, '_blank')
|
||||
})
|
||||
} else {
|
||||
sheetApi.create(this.sheetToStage, false).then(response => {
|
||||
this.$log.debug('Created sheet', response.data.data)
|
||||
this.sheetToStage = response.data.data
|
||||
window.open(`${this.options.blog_url}/api/admin/sheets/preview/${this.sheetToStage.id}`, '_blank')
|
||||
})
|
||||
}
|
||||
},
|
||||
onSheetSettingsClose() {
|
||||
this.sheetSettingVisible = false
|
||||
},
|
||||
|
|
|
@ -660,7 +660,7 @@
|
|||
label="CDN 加速域名:"
|
||||
:wrapper-col="wrapperCol"
|
||||
>
|
||||
<a-input v-model="options.blog_cdn_domain" placeholder="请确保 CDN 已经缓存了静态资源"/>
|
||||
<a-input v-model="options.blog_cdn_domain" placeholder="请确保已经正确配置好了 CDN"/>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="自定义 head:"
|
||||
|
|
Loading…
Reference in New Issue