数据结构优化
This commit is contained in:
@@ -65,11 +65,13 @@
|
||||
class="admin-input text-sm"
|
||||
@keyup.enter="createColumn"
|
||||
/>
|
||||
<input
|
||||
v-model="newColumn.cover"
|
||||
placeholder="封面图片URL"
|
||||
class="admin-input text-sm"
|
||||
/>
|
||||
<div>
|
||||
<label class="block text-xs text-art-muted mb-2">封面图片</label>
|
||||
<ImageUpload
|
||||
v-model="newColumn.cover"
|
||||
:categoryId="1"
|
||||
/>
|
||||
</div>
|
||||
<textarea
|
||||
v-model="newColumn.description"
|
||||
placeholder="描述"
|
||||
@@ -144,7 +146,7 @@ import {
|
||||
createCategory as createCategoryApi,
|
||||
createColumn as createColumnApi,
|
||||
createTag as createTagApi,
|
||||
updatePost,
|
||||
updatePostRelations,
|
||||
Category,
|
||||
Column,
|
||||
Tag,
|
||||
@@ -152,6 +154,7 @@ import {
|
||||
} from '../../services/api'
|
||||
import { useToast } from '../../composables/useToast'
|
||||
import CustomSelect from '../CustomSelect.vue'
|
||||
import ImageUpload from './ImageUpload.vue'
|
||||
|
||||
const props = defineProps<{
|
||||
isOpen: boolean
|
||||
@@ -320,23 +323,13 @@ const save = async () => {
|
||||
|
||||
saving.value = true
|
||||
try {
|
||||
const payload: any = {
|
||||
title: props.post.title,
|
||||
// 只更新关联关系,不更新内容
|
||||
await updatePostRelations(props.post.id, {
|
||||
categoryId: selectedCategoryId.value,
|
||||
date: props.post.date,
|
||||
excerpt: props.post.excerpt || '',
|
||||
content: props.post.content || '',
|
||||
isPublished: props.post.isPublished || 1,
|
||||
tags: selectedTagIds.value.map(id => ({ id }))
|
||||
}
|
||||
|
||||
if (selectedColumnId.value > 0) {
|
||||
payload.columnId = selectedColumnId.value
|
||||
} else {
|
||||
payload.columnId = null
|
||||
}
|
||||
|
||||
await updatePost(props.post.id, payload)
|
||||
columnId: selectedColumnId.value > 0 ? selectedColumnId.value : null,
|
||||
tagIds: selectedTagIds.value
|
||||
})
|
||||
|
||||
toast.showToast('保存成功', 'success')
|
||||
emit('saved')
|
||||
close()
|
||||
|
||||
Reference in New Issue
Block a user