feat: 更新发布中ui

This commit is contained in:
tim
2025-07-14 17:19:38 +08:00
parent 93b54dff18
commit f11f026829

View File

@@ -33,17 +33,13 @@ import { getToken } from '../utils/auth'
export default { export default {
name: 'NewPostPageView', name: 'NewPostPageView',
data() {
return {
isWaitingPosting: false
}
},
components: { PostEditor, CategorySelect, TagSelect }, components: { PostEditor, CategorySelect, TagSelect },
setup() { setup() {
const title = ref('') const title = ref('')
const content = ref('') const content = ref('')
const selectedCategory = ref('') const selectedCategory = ref('')
const selectedTags = ref([]) const selectedTags = ref([])
const isWaitingPosting = ref(false)
const loadDraft = async () => { const loadDraft = async () => {
const token = getToken() const token = getToken()
@@ -171,6 +167,7 @@ export default {
try { try {
const token = getToken() const token = getToken()
await ensureTags(token) await ensureTags(token)
isWaitingPosting.value = true
const res = await fetch(`${API_BASE_URL}/api/posts`, { const res = await fetch(`${API_BASE_URL}/api/posts`, {
method: 'POST', method: 'POST',
headers: { headers: {
@@ -195,9 +192,11 @@ export default {
} }
} catch (e) { } catch (e) {
toast.error('发布失败') toast.error('发布失败')
} finally {
isWaitingPosting.value = false
} }
} }
return { title, content, selectedCategory, selectedTags, submitPost, saveDraft, clearPost } return { title, content, selectedCategory, selectedTags, submitPost, saveDraft, clearPost, isWaitingPosting }
} }
} }
</script> </script>
@@ -282,6 +281,4 @@ export default {
align-items: center; align-items: center;
margin-top: 20px; margin-top: 20px;
} }
</style> </style>