添加需求时需要携带token,修改为添加token

This commit is contained in:
Kunagisa 2025-06-13 22:27:13 +08:00
parent 031f14f7f0
commit 7e6c2a1740

View File

@ -180,6 +180,7 @@
<script setup>
import { ref, onMounted, nextTick } from 'vue'
import axiosInstance from '../../api/axiosConfig'
//
const demands = ref([])
@ -299,25 +300,23 @@ async function submitAddForm() {
const now = new Date();
const dateStr = `${now.getFullYear()}-${(now.getMonth()+1).toString().padStart(2,'0')}-${now.getDate().toString().padStart(2,'0')} ${now.getHours().toString().padStart(2,'0')}:${now.getMinutes().toString().padStart(2,'0')}:${now.getSeconds().toString().padStart(2,'0')}`;
const payload = {
requester: addForm.value.requester , // requester使qq_code
requester: addForm.value.requester,
sendcontent: addForm.value.sendcontent,
content: addForm.value.sendcontent,
reward: addForm.value.reward,
date: dateStr,
qq_code: addForm.value.qq_code
};
const response = await fetch('http://zybdatasupport.online:8000/demands/add', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
})
if (!response.ok) throw new Error('提交失败')
showAddModal.value = false
fetchDemands() //
const response = await axiosInstance.post('/demands/add', payload);
if (response.status === 200) {
showAddModal.value = false;
fetchDemands(); //
}
} catch (e) {
addError.value = '提交失败,请稍后重试'
console.error('提交失败:', e);
addError.value = e.response?.data?.detail || '提交失败,请稍后重试';
} finally {
addLoading.value = false
addLoading.value = false;
}
}