获取个人消息接口联调

This commit is contained in:
GUjiYN 2024-03-12 21:59:31 +08:00
parent 925d56c48a
commit 94a533eb75
2 changed files with 23 additions and 41 deletions

View File

@ -534,18 +534,18 @@ const projectGetCustom = (data) =>{
* 展示全部消息
*
*/
const messageGetAll = (token) => {
const messageGet = (token) => {
return axios({
url:api + "/message/get/all",
url:api + "/message/get",
method:"get",
headers:{
'Authorization':'Bearer '+token,
'content-type': 'application/json;charset=utf-8',
'Timestamp': getCurrentTimestamp()
}
})
}
export default {
login,
register,
@ -584,6 +584,6 @@ export default {
messageGetAll
messageGet
}

View File

@ -31,35 +31,13 @@
<tbody>
<tr v-for="(message, index) in messages" :key="index" class="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
<th class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white" scope="row">
{{ message.uid }}
{{ message.title }}
</th>
<td class="px-6 py-4">
{{ message.createdAt }}
{{ message.text }}
</td>
<td class="px-6 py-4 flex justify-end">
<a-button class="flex justify-center items-center" type="link"><DeleteOutlined />删除</a-button>
</td>
</tr>
<tr class="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
<th class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white" scope="row">
小明老师
</th>
<td class="px-6 py-4">
时间
</td>
<td class="px-6 py-4 flex justify-end">
<a-button class="flex justify-center items-center" type="link" @click="deleteMessage(message.id)"><DeleteOutlined />删除</a-button>
</td>
</tr>
<tr class=" bg-white border-b dark:bg-gray-800 dark:border-gray-700">
<th class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white" scope="row">
小明老师
</th>
<td class="px-6 py-4">
时间
</td>
<td class="px-6 py-4 flex justify-end">
<a-button class="flex justify-center items-center" type="link"><DeleteOutlined />删除</a-button>
<a-button class="flex justify-center items-center" type="link" @click="deleteMessage(message.id)"><DeleteOutlined />删除</a-button>
</td>
</tr>
</tbody>
@ -81,23 +59,27 @@ const messages = ref([]); // 使用ref创建响应式数据
onMounted(() =>{
messageGetAll();
/*requests.userGetProfile(token).then((res)=>{
const data = {
"uid": res.data.data.id,
"begin": "",
"end": "",
"page": "",
"pageSize": ""
}*/
request.messageGet(token).then((res) => {
messages.value = res.data.data.rows;
})
/* });*/
})
function messageGetAll() {
request.messageGetAll(token).then((res) => {
// res
messages.value = res.data.data; // messages
}).catch(error => {
console.error("Failed to fetch messages:", error);
});
}
const deleteMessage = (messageId) => {
const deleteMessage = (id) => {
//
console.log("Deleting message with id:", messageId);
console.log("Deleting message with id:", id);
// messages
messages.value = messages.value.filter(message => message.id !== messageId);
messages.value = messages.value.filter(message => message.id !== id);
};