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
|
// eslint-disable-next-line
|
||||||
import { BasicLayout, RouteView, BlankLayout, PageView } from '@/layouts'
|
import { BasicLayout, PageView } from '@/layouts'
|
||||||
|
|
||||||
export const asyncRouterMap = [
|
export const asyncRouterMap = [
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,6 +45,10 @@
|
||||||
type="danger"
|
type="danger"
|
||||||
@click="handleSaveDraft"
|
@click="handleSaveDraft"
|
||||||
>保存草稿</a-button>
|
>保存草稿</a-button>
|
||||||
|
<a-button
|
||||||
|
@click="handlePreview"
|
||||||
|
style="margin-left: 8px;"
|
||||||
|
>预览</a-button>
|
||||||
<a-button
|
<a-button
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="handleShowPostSetting"
|
@click="handleShowPostSetting"
|
||||||
|
@ -61,6 +65,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mixin, mixinDevice } from '@/utils/mixin.js'
|
import { mixin, mixinDevice } from '@/utils/mixin.js'
|
||||||
|
import { mapGetters } from 'vuex'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import PostSetting from './components/PostSetting'
|
import PostSetting from './components/PostSetting'
|
||||||
import AttachmentDrawer from '../attachment/components/AttachmentDrawer'
|
import AttachmentDrawer from '../attachment/components/AttachmentDrawer'
|
||||||
|
@ -125,6 +130,9 @@ export default {
|
||||||
}
|
}
|
||||||
next()
|
next()
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['options'])
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleSaveDraft() {
|
handleSaveDraft() {
|
||||||
this.postToStage.status = 'DRAFT'
|
this.postToStage.status = 'DRAFT'
|
||||||
|
@ -178,6 +186,29 @@ export default {
|
||||||
handleShowPostSetting() {
|
handleShowPostSetting() {
|
||||||
this.postSettingVisible = true
|
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() {
|
onPostSettingsClose() {
|
||||||
this.postSettingVisible = false
|
this.postSettingVisible = false
|
||||||
|
|
|
@ -39,6 +39,10 @@
|
||||||
type="danger"
|
type="danger"
|
||||||
@click="handleSaveDraft"
|
@click="handleSaveDraft"
|
||||||
>保存草稿</a-button>
|
>保存草稿</a-button>
|
||||||
|
<a-button
|
||||||
|
@click="handlePreview"
|
||||||
|
style="margin-left: 8px;"
|
||||||
|
>预览</a-button>
|
||||||
<a-button
|
<a-button
|
||||||
type="primary"
|
type="primary"
|
||||||
style="margin-left: 8px;"
|
style="margin-left: 8px;"
|
||||||
|
@ -55,6 +59,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mixin, mixinDevice } from '@/utils/mixin.js'
|
import { mixin, mixinDevice } from '@/utils/mixin.js'
|
||||||
|
import { mapGetters } from 'vuex'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import { toolbars } from '@/core/const'
|
import { toolbars } from '@/core/const'
|
||||||
import SheetSetting from './components/SheetSetting'
|
import SheetSetting from './components/SheetSetting'
|
||||||
|
@ -115,6 +120,9 @@ export default {
|
||||||
}
|
}
|
||||||
next()
|
next()
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['options'])
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleSaveDraft() {
|
handleSaveDraft() {
|
||||||
this.sheetToStage.status = 'DRAFT'
|
this.sheetToStage.status = 'DRAFT'
|
||||||
|
@ -166,6 +174,27 @@ export default {
|
||||||
handleShowSheetSetting() {
|
handleShowSheetSetting() {
|
||||||
this.sheetSettingVisible = true
|
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() {
|
onSheetSettingsClose() {
|
||||||
this.sheetSettingVisible = false
|
this.sheetSettingVisible = false
|
||||||
},
|
},
|
||||||
|
|
|
@ -660,7 +660,7 @@
|
||||||
label="CDN 加速域名:"
|
label="CDN 加速域名:"
|
||||||
:wrapper-col="wrapperCol"
|
: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>
|
||||||
<a-form-item
|
<a-form-item
|
||||||
label="自定义 head:"
|
label="自定义 head:"
|
||||||
|
|
Loading…
Reference in New Issue