mirror of https://github.com/halo-dev/halo
pull/3445/head
parent
737c1030a8
commit
c06c9c6abe
|
@ -292,15 +292,24 @@
|
||||||
loadedText="保存成功"
|
loadedText="保存成功"
|
||||||
erroredText="保存失败"
|
erroredText="保存失败"
|
||||||
></ReactiveButton>
|
></ReactiveButton>
|
||||||
<ReactiveButton
|
<a-popconfirm
|
||||||
@click="handlePublishClick"
|
title="是否同时更新发布时间为当前时间?"
|
||||||
@callback="handleSavedCallback"
|
ok-text="更新"
|
||||||
:loading="saving"
|
cancel-text="不更新"
|
||||||
:errored="savedErrored"
|
@confirm="handlePublishClick(true)"
|
||||||
:text="`${selectedPost.id?'保存':'发布'}`"
|
@cancel="handlePublishClick(false)"
|
||||||
:loadedText="`${selectedPost.id?'保存':'发布'}成功`"
|
:disabled="selectedPost.status !== 'DRAFT'"
|
||||||
:erroredText="`${selectedPost.id?'保存':'发布'}失败`"
|
>
|
||||||
></ReactiveButton>
|
<ReactiveButton
|
||||||
|
@click="selectedPost.status !== 'DRAFT'?handlePublishClick(false):()=>{}"
|
||||||
|
@callback="handleSavedCallback"
|
||||||
|
:loading="saving"
|
||||||
|
:errored="savedErrored"
|
||||||
|
:text="`${selectedPost.id?'保存':'发布'}`"
|
||||||
|
:loadedText="`${selectedPost.id?'保存':'发布'}成功`"
|
||||||
|
:erroredText="`${selectedPost.id?'保存':'发布'}失败`"
|
||||||
|
></ReactiveButton>
|
||||||
|
</a-popconfirm>
|
||||||
</a-space>
|
</a-space>
|
||||||
</div>
|
</div>
|
||||||
</a-drawer>
|
</a-drawer>
|
||||||
|
@ -329,7 +338,7 @@ export default {
|
||||||
components: {
|
components: {
|
||||||
CategoryTree,
|
CategoryTree,
|
||||||
CategorySelectTree,
|
CategorySelectTree,
|
||||||
TagSelect
|
TagSelect,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -345,41 +354,41 @@ export default {
|
||||||
saving: false,
|
saving: false,
|
||||||
savedErrored: false,
|
savedErrored: false,
|
||||||
draftSaving: false,
|
draftSaving: false,
|
||||||
draftSavedErrored: false
|
draftSavedErrored: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
post: {
|
post: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true,
|
||||||
},
|
},
|
||||||
tagIds: {
|
tagIds: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true
|
required: true,
|
||||||
},
|
},
|
||||||
categoryIds: {
|
categoryIds: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true
|
required: true,
|
||||||
},
|
},
|
||||||
metas: {
|
metas: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true
|
required: true,
|
||||||
},
|
},
|
||||||
needTitle: {
|
needTitle: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: false,
|
required: false,
|
||||||
default: false
|
default: false,
|
||||||
},
|
},
|
||||||
saveDraftButton: {
|
saveDraftButton: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: false,
|
required: false,
|
||||||
default: true
|
default: true,
|
||||||
},
|
},
|
||||||
visible: {
|
visible: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: false,
|
required: false,
|
||||||
default: true
|
default: true,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
post(val) {
|
post(val) {
|
||||||
|
@ -402,7 +411,7 @@ export default {
|
||||||
},
|
},
|
||||||
selectedMetas(val) {
|
selectedMetas(val) {
|
||||||
this.$emit('onRefreshPostMetas', val)
|
this.$emit('onRefreshPostMetas', val)
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters(['options']),
|
...mapGetters(['options']),
|
||||||
|
@ -441,7 +450,7 @@ export default {
|
||||||
default:
|
default:
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleAfterVisibleChanged(visible) {
|
handleAfterVisibleChanged(visible) {
|
||||||
|
@ -465,7 +474,7 @@ export default {
|
||||||
for (let i = 0, len = fields.length; i < len; i++) {
|
for (let i = 0, len = fields.length; i < len; i++) {
|
||||||
this.selectedMetas.push({
|
this.selectedMetas.push({
|
||||||
value: '',
|
value: '',
|
||||||
key: fields[i]
|
key: fields[i],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -485,7 +494,7 @@ export default {
|
||||||
if (!this.categoryToCreate.name) {
|
if (!this.categoryToCreate.name) {
|
||||||
this.$notification['error']({
|
this.$notification['error']({
|
||||||
message: '提示',
|
message: '提示',
|
||||||
description: '分类名称不能为空!'
|
description: '分类名称不能为空!',
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -503,8 +512,8 @@ export default {
|
||||||
this.selectedPost.status = 'DRAFT'
|
this.selectedPost.status = 'DRAFT'
|
||||||
this.createOrUpdatePost()
|
this.createOrUpdatePost()
|
||||||
},
|
},
|
||||||
handlePublishClick() {
|
handlePublishClick(refreshCreateTime = false) {
|
||||||
if (this.selectedPost.status === 'DRAFT') {
|
if (refreshCreateTime) {
|
||||||
this.selectedPost.createTime = new Date()
|
this.selectedPost.createTime = new Date()
|
||||||
}
|
}
|
||||||
this.selectedPost.status = 'PUBLISHED'
|
this.selectedPost.status = 'PUBLISHED'
|
||||||
|
@ -514,7 +523,7 @@ export default {
|
||||||
if (!this.selectedPost.title) {
|
if (!this.selectedPost.title) {
|
||||||
this.$notification['error']({
|
this.$notification['error']({
|
||||||
message: '提示',
|
message: '提示',
|
||||||
description: '文章标题不能为空!'
|
description: '文章标题不能为空!',
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -595,7 +604,7 @@ export default {
|
||||||
handleInsertPostMeta() {
|
handleInsertPostMeta() {
|
||||||
this.selectedMetas.push({
|
this.selectedMetas.push({
|
||||||
value: '',
|
value: '',
|
||||||
key: ''
|
key: '',
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleSetPinyinSlug() {
|
handleSetPinyinSlug() {
|
||||||
|
@ -604,7 +613,7 @@ export default {
|
||||||
this.$set(this.selectedPost, 'slug', pinyin.convertToPinyin(this.selectedPost.title, '-', true))
|
this.$set(this.selectedPost, 'slug', pinyin.convertToPinyin(this.selectedPost.title, '-', true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -208,21 +208,30 @@
|
||||||
loadedText="保存成功"
|
loadedText="保存成功"
|
||||||
erroredText="保存失败"
|
erroredText="保存失败"
|
||||||
></ReactiveButton>
|
></ReactiveButton>
|
||||||
<ReactiveButton
|
|
||||||
@click="handlePublishClick"
|
<a-popconfirm
|
||||||
@callback="handleSavedCallback"
|
title="是否同时更新发布时间为当前时间?"
|
||||||
:loading="saving"
|
ok-text="更新"
|
||||||
:errored="savedErrored"
|
cancel-text="不更新"
|
||||||
:text="`${selectedSheet.id?'保存':'发布'}`"
|
@confirm="handlePublishClick(true)"
|
||||||
:loadedText="`${selectedSheet.id?'保存':'发布'}成功`"
|
@cancel="handlePublishClick(false)"
|
||||||
:erroredText="`${selectedSheet.id?'保存':'发布'}失败`"
|
:disabled="selectedSheet.status !== 'DRAFT'"
|
||||||
></ReactiveButton>
|
>
|
||||||
|
<ReactiveButton
|
||||||
|
@click="selectedSheet.status !== 'DRAFT'?handlePublishClick(false):()=>{}"
|
||||||
|
@callback="handleSavedCallback"
|
||||||
|
:loading="saving"
|
||||||
|
:errored="savedErrored"
|
||||||
|
:text="`${selectedSheet.id?'保存':'发布'}`"
|
||||||
|
:loadedText="`${selectedSheet.id?'保存':'发布'}成功`"
|
||||||
|
:erroredText="`${selectedSheet.id?'保存':'发布'}失败`"
|
||||||
|
></ReactiveButton>
|
||||||
|
</a-popconfirm>
|
||||||
</a-space>
|
</a-space>
|
||||||
</div>
|
</div>
|
||||||
</a-drawer>
|
</a-drawer>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
// libs
|
// libs
|
||||||
import { mixin, mixinDevice } from '@/utils/mixin.js'
|
import { mixin, mixinDevice } from '@/utils/mixin.js'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
|
@ -245,33 +254,33 @@ export default {
|
||||||
saving: false,
|
saving: false,
|
||||||
savedErrored: false,
|
savedErrored: false,
|
||||||
draftSaving: false,
|
draftSaving: false,
|
||||||
draftSavedErrored: false
|
draftSavedErrored: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
sheet: {
|
sheet: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true,
|
||||||
},
|
},
|
||||||
metas: {
|
metas: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true
|
required: true,
|
||||||
},
|
},
|
||||||
needTitle: {
|
needTitle: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: false,
|
required: false,
|
||||||
default: false
|
default: false,
|
||||||
},
|
},
|
||||||
saveDraftButton: {
|
saveDraftButton: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: false,
|
required: false,
|
||||||
default: true
|
default: true,
|
||||||
},
|
},
|
||||||
visible: {
|
visible: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: false,
|
required: false,
|
||||||
default: true
|
default: true,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
sheet(val) {
|
sheet(val) {
|
||||||
|
@ -282,7 +291,7 @@ export default {
|
||||||
},
|
},
|
||||||
selectedMetas(val) {
|
selectedMetas(val) {
|
||||||
this.$emit('onRefreshSheetMetas', val)
|
this.$emit('onRefreshSheetMetas', val)
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters(['options']),
|
...mapGetters(['options']),
|
||||||
|
@ -301,7 +310,7 @@ export default {
|
||||||
const sheetPrefix = this.options.sheet_prefix
|
const sheetPrefix = this.options.sheet_prefix
|
||||||
const pathSuffix = this.options.path_suffix ? this.options.path_suffix : ''
|
const pathSuffix = this.options.path_suffix ? this.options.path_suffix : ''
|
||||||
return `${blogUrl}/${sheetPrefix}/${this.selectedSheet.slug ? this.selectedSheet.slug : '{slug}'}${pathSuffix}`
|
return `${blogUrl}/${sheetPrefix}/${this.selectedSheet.slug ? this.selectedSheet.slug : '{slug}'}${pathSuffix}`
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleAfterVisibleChanged(visible) {
|
handleAfterVisibleChanged(visible) {
|
||||||
|
@ -313,13 +322,13 @@ export default {
|
||||||
},
|
},
|
||||||
handleListPresetMetasField() {
|
handleListPresetMetasField() {
|
||||||
if (this.metas.length <= 0) {
|
if (this.metas.length <= 0) {
|
||||||
themeApi.getActivatedTheme().then(response => {
|
themeApi.getActivatedTheme().then((response) => {
|
||||||
const fields = response.data.data.sheetMetaField
|
const fields = response.data.data.sheetMetaField
|
||||||
if (fields && fields.length > 0) {
|
if (fields && fields.length > 0) {
|
||||||
for (let i = 0, len = fields.length; i < len; i++) {
|
for (let i = 0, len = fields.length; i < len; i++) {
|
||||||
this.selectedMetas.push({
|
this.selectedMetas.push({
|
||||||
value: '',
|
value: '',
|
||||||
key: fields[i]
|
key: fields[i],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -330,7 +339,7 @@ export default {
|
||||||
this.customTplsLoading = true
|
this.customTplsLoading = true
|
||||||
themeApi
|
themeApi
|
||||||
.customSheetTpls()
|
.customSheetTpls()
|
||||||
.then(response => {
|
.then((response) => {
|
||||||
this.customTpls = response.data.data
|
this.customTpls = response.data.data
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
|
@ -343,7 +352,10 @@ export default {
|
||||||
this.selectedSheet.thumbnail = encodeURI(data.path)
|
this.selectedSheet.thumbnail = encodeURI(data.path)
|
||||||
this.thumbDrawerVisible = false
|
this.thumbDrawerVisible = false
|
||||||
},
|
},
|
||||||
handlePublishClick() {
|
handlePublishClick(refreshCreateTime = false) {
|
||||||
|
if (refreshCreateTime) {
|
||||||
|
this.selectedSheet.createTime = new Date()
|
||||||
|
}
|
||||||
this.selectedSheet.status = 'PUBLISHED'
|
this.selectedSheet.status = 'PUBLISHED'
|
||||||
this.createOrUpdateSheet()
|
this.createOrUpdateSheet()
|
||||||
},
|
},
|
||||||
|
@ -355,7 +367,7 @@ export default {
|
||||||
if (!this.selectedSheet.title) {
|
if (!this.selectedSheet.title) {
|
||||||
this.$notification['error']({
|
this.$notification['error']({
|
||||||
message: '提示',
|
message: '提示',
|
||||||
description: '页面标题不能为空!'
|
description: '页面标题不能为空!',
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -391,7 +403,7 @@ export default {
|
||||||
this.savedErrored = true
|
this.savedErrored = true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then((response) => {
|
||||||
this.selectedSheet = response.data.data
|
this.selectedSheet = response.data.data
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
|
@ -429,7 +441,7 @@ export default {
|
||||||
handleInsertSheetMeta() {
|
handleInsertSheetMeta() {
|
||||||
this.selectedMetas.push({
|
this.selectedMetas.push({
|
||||||
value: '',
|
value: '',
|
||||||
key: ''
|
key: '',
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleSetPinyinSlug() {
|
handleSetPinyinSlug() {
|
||||||
|
@ -438,7 +450,7 @@ export default {
|
||||||
this.$set(this.selectedSheet, 'slug', pinyin.convertToPinyin(this.selectedSheet.title, '-', true))
|
this.$set(this.selectedSheet, 'slug', pinyin.convertToPinyin(this.selectedSheet.title, '-', true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue