diff --git a/frontend_nuxt/pages/new-post.vue b/frontend_nuxt/pages/new-post.vue index ca79c55bf..93f9b4211 100644 --- a/frontend_nuxt/pages/new-post.vue +++ b/frontend_nuxt/pages/new-post.vue @@ -10,10 +10,6 @@
-
@@ -36,21 +32,6 @@
发布中...
- -
-
- - -
-
- - - -
-
- -
-
@@ -75,10 +56,6 @@ export default { const isWaitingPosting = ref(false) const isAiLoading = ref(false) const isLogin = computed(() => authState.loggedIn) - const postType = ref('NORMAL') - const prizeIcon = ref('') - const prizeCount = ref(1) - const lotteryEndTime = ref('') const loadDraft = async () => { const token = getToken() @@ -108,10 +85,6 @@ export default { content.value = '' selectedCategory.value = '' selectedTags.value = [] - postType.value = 'NORMAL' - prizeIcon.value = '' - prizeCount.value = 1 - lotteryEndTime.value = '' // 删除草稿 const token = getToken() @@ -240,20 +213,6 @@ export default { toast.error('请选择标签') return } - if (postType.value === 'LOTTERY') { - if (!prizeIcon.value) { - toast.error('请上传奖品图片') - return - } - if (!prizeCount.value || prizeCount.value <= 0) { - toast.error('奖品数量必须大于0') - return - } - if (!lotteryEndTime.value) { - toast.error('请选择抽奖结束时间') - return - } - } try { const token = getToken() await ensureTags(token) @@ -268,14 +227,7 @@ export default { title: title.value, content: content.value, categoryId: selectedCategory.value, - tagIds: selectedTags.value, - type: postType.value, - prizeIcon: postType.value === 'LOTTERY' ? prizeIcon.value : undefined, - prizeCount: postType.value === 'LOTTERY' ? prizeCount.value : undefined, - endTime: - postType.value === 'LOTTERY' && lotteryEndTime.value - ? new Date(lotteryEndTime.value).toISOString() - : undefined + tagIds: selectedTags.value }) }) const data = await res.json() @@ -299,55 +251,7 @@ export default { isWaitingPosting.value = false } } - const incPrizeCount = () => { - prizeCount.value += 1 - } - const decPrizeCount = () => { - if (prizeCount.value > 1) prizeCount.value -= 1 - } - const handlePrizeImage = async (e) => { - const file = e.target.files[0] - if (!file) return - try { - const res = await fetch(`${API_BASE_URL}/api/upload/presign?filename=${encodeURIComponent(file.name)}`, { - headers: { Authorization: `Bearer ${getToken()}` } - }) - if (!res.ok) { - toast.error('获取上传地址失败') - return - } - const info = await res.json() - const put = await fetch(info.uploadUrl, { method: 'PUT', body: file }) - if (!put.ok) { - toast.error('上传失败') - return - } - prizeIcon.value = info.fileUrl - toast.success('上传成功') - } catch (e) { - toast.error('上传失败') - } - } - return { - title, - content, - selectedCategory, - selectedTags, - submitPost, - saveDraft, - clearPost, - isWaitingPosting, - aiGenerate, - isAiLoading, - isLogin, - postType, - prizeIcon, - prizeCount, - lotteryEndTime, - incPrizeCount, - decPrizeCount, - handlePrizeImage - } + return { title, content, selectedCategory, selectedTags, submitPost, saveDraft, clearPost, isWaitingPosting, aiGenerate, isAiLoading, isLogin } } } @@ -462,42 +366,6 @@ export default { padding-bottom: 50px; } -.post-type-select { - padding: 5px; - border-radius: 5px; -} - -.lottery-options { - margin-top: 20px; - display: flex; - flex-direction: column; - gap: 10px; -} - -.prize-image input { - display: block; -} - -.prize-preview { - margin-top: 10px; - max-width: 200px; -} - -.prize-count { - display: flex; - align-items: center; - gap: 5px; -} - -.prize-count button { - padding: 5px 10px; -} - -.lottery-end-time input { - padding: 5px; - border-radius: 5px; -} - @media (max-width: 768px) { .new-post-page { width: calc(100vw - 20px);