fix(service): 🐛 修复请求体包裹多层data的问题

This commit is contained in:
nongyehong 2024-10-27 22:11:09 +08:00
parent 45e2bfce66
commit d97d24f1c1
13 changed files with 38 additions and 42 deletions

View File

@ -1,7 +1,7 @@
# 后端服务地址
VITE_SERVICE_URL="https://hulaspark.com"
# websocket服务地址
VITE_WEBSOCKET_URL="wss://hulaspark.com"
VITE_WEBSOCKET_URL="wss://hulaspark.com/websocket"
# 项目标题
VITE_APP_TITLE="HuLa—IM"
# 项目名称

View File

@ -1,7 +1,7 @@
# 后端服务地址
VITE_SERVICE_URL="https://hulaspark.com"
# websocket服务地址
VITE_WEBSOCKET_URL="wss://hulaspark.com"
VITE_WEBSOCKET_URL="wss://hulaspark.com/websocket"
# 项目标题
VITE_APP_TITLE="HuLa—IM"
# 项目名称

View File

@ -1,7 +1,7 @@
{
"name": "hula",
"type": "module",
"version": "2.5.0",
"version": "2.4.0",
"license": "Apache-2.0",
"engines": {
"node": ">=18.12.0",

View File

@ -1,6 +1,6 @@
{
"productName": "HuLa",
"version": "2.5.0",
"version": "2.4.0",
"identifier": "com.tauri.build",
"build": {
"beforeDevCommand": "pnpm dev",

View File

@ -1,6 +1,6 @@
{
"productName": "HuLa",
"version": "2.5.0",
"version": "2.4.0",
"identifier": "com.tauri.build",
"build": {
"beforeDevCommand": "pnpm dev",

View File

@ -1,6 +1,6 @@
{
"productName": "HuLa",
"version": "2.5.0",
"version": "2.4.0",
"identifier": "com.tauri.build",
"build": {
"beforeDevCommand": "pnpm dev",

View File

@ -131,10 +131,11 @@
v-if="chatStore.isGroup"
:style="item.fromUser.uid === userUid ? 'flex-direction: row-reverse' : ''">
<!-- 用户徽章 -->
<n-popover trigger="hover">
<n-popover
v-if="useBadgeInfo(useUserInfo(item.fromUser.uid).value.wearingItemId).value.img"
trigger="hover">
<template #trigger>
<img
v-if="useBadgeInfo(useUserInfo(item.fromUser.uid).value.wearingItemId).value.img"
class="size-18px"
:src="useBadgeInfo(useUserInfo(item.fromUser.uid).value.wearingItemId).value.img"
alt="badge" />
@ -152,17 +153,17 @@
</n-flex>
</ContextMenu>
<!-- 群主 -->
<div
v-if="chatStore.isGroup && item.message.id === 1"
class="flex p-4px rounded-4px bg-#f5dadf size-fit select-none">
<span class="text-(10px #d5304f)">群主</span>
</div>
<!-- <div-->
<!-- v-if="chatStore.isGroup && item.message.id === 1"-->
<!-- class="flex p-4px rounded-4px bg-#f5dadf size-fit select-none">-->
<!-- <span class="text-(10px #d5304f)">群主</span>-->
<!-- </div>-->
<!-- 管理员 -->
<div
v-if="chatStore.isGroup && item.message.id === 2"
class="flex p-4px rounded-4px bg-#13987F66 size-fit select-none">
<span class="text-(10px #13987f)">管理员</span>
</div>
<!-- <div-->
<!-- v-if="chatStore.isGroup && item.message.id === 2"-->
<!-- class="flex p-4px rounded-4px bg-#13987F66 size-fit select-none">-->
<!-- <span class="text-(10px #13987f)">管理员</span>-->
<!-- </div>-->
<!-- 信息时间(群聊) -->
<Transition name="fade">
<span v-if="chatStore.isGroup && hoverBubble.key === item.message.id" class="text-(12px #909090)">
@ -338,7 +339,6 @@
import { EventEnum, MittEnum, MsgEnum, RoomTypeEnum } from '@/enums'
import { type MessageType, SessionItem } from '@/services/types.ts'
import Mitt from '@/utils/Bus.ts'
import { invoke } from '@tauri-apps/api/core'
import { usePopover } from '@/hooks/usePopover.ts'
import { useWindow } from '@/hooks/useWindow.ts'
import { listen } from '@tauri-apps/api/event'
@ -542,14 +542,14 @@ onMounted(() => {
virtualListInst.value?.scrollTo({ position: 'bottom', debounce: true })
})
/**! 启动图标闪烁 需要设置"resources": ["sec-tauri/图标放置的文件夹"]*/
invoke('tray_blink', {
isRun: true,
ms: 500,
iconPath1: 'tray/msg.png',
iconPath2: 'tray/msg-sub.png'
}).catch((error) => {
console.error('设置图标失败:', error)
})
// invoke('tray_blink', {
// isRun: true,
// ms: 500,
// iconPath1: 'tray/msg.png',
// iconPath2: 'tray/msg-sub.png'
// }).catch((error) => {
// console.error(':', error)
// })
Mitt.on(MittEnum.SEND_MESSAGE, (event: MessageType) => {
nextTick(() => {
addToDomUpdateQueue(event.message.id, event.fromUser.uid)

View File

@ -111,11 +111,11 @@ onMounted(() => {
editInfo.value.show = true
/** 获取用户的徽章列表 */
apis.getBadgeList().then((res) => {
editInfo.value.badgeList = res.data
editInfo.value.badgeList = res as any
})
/** 获取用户信息 */
apis.getUserInfo().then((res) => {
editInfo.value.content = res.data
editInfo.value.content = res
})
})
})

View File

@ -59,8 +59,8 @@ async function Http<T>(
// 拼接 API 基础路径
url = `${import.meta.env.VITE_SERVICE_URL}${url}`
console.log('fetch url: ', url)
console.log('fetch options: ', fetchOptions)
// console.log('fetch url: ', url)
// console.log('fetch options: ', fetchOptions)
try {
const res = await fetch(url, fetchOptions)
@ -69,7 +69,7 @@ async function Http<T>(
throw new Error(`HTTP error! status: ${res.status}`)
}
const data = options.isBlob ? res.arrayBuffer() : res.json()
const data = options.isBlob ? await res.arrayBuffer() : await res.json()
if (fullResponse) {
return { data, resp: res }

View File

@ -227,8 +227,7 @@ const responseInterceptor = async <T>(
}
const res: any = await data.data
return Promise.resolve(res)
return Promise.resolve(res.data)
} catch (err) {
return Promise.reject(`http error: ${err}`)
}

View File

@ -93,8 +93,7 @@ export const useCachedStore = defineStore('cached', () => {
const getGroupAtUserBaseInfo = async () => {
if (currentRoomId.value === 1) return
const data = await apis.getAllUserBaseInfo({ params: { roomId: currentRoomId.value } })
currentAtUsersList.value = data
currentAtUsersList.value = await apis.getAllUserBaseInfo({ params: { roomId: currentRoomId.value } })
}
/**

View File

@ -143,11 +143,9 @@ export const useChatStore = defineStore('chat', () => {
currentMessageOptions.value && (currentMessageOptions.value.isLoading = true)
const data = await apis
.getMsgList({
params: {
pageSize: size,
cursor: currentMessageOptions.value?.cursor,
roomId: currentRoomId.value
}
pageSize: size,
cursor: currentMessageOptions.value?.cursor,
roomId: currentRoomId.value
})
.finally(() => {
currentMessageOptions.value && (currentMessageOptions.value.isLoading = false)

View File

@ -102,7 +102,7 @@ const initConnection = () => {
connection?.removeEventListener('error', onConnectError)
// 建立链接
// 本地配置到 .env 里面修改。生产配置在 .env.production 里面
connection = new WebSocket(`${import.meta.env.VITE_WEBSOCKET_URL}/websocket${token ? `?token=${token}` : ''}`)
connection = new WebSocket(`${import.meta.env.VITE_WEBSOCKET_URL}${token ? `?token=${token}` : ''}`)
// 收到消息
connection.addEventListener('message', onConnectMsg)
// 建立链接