mirror of
https://gitee.com/HuLaSpark/HuLa.git
synced 2024-11-29 10:18:35 +08:00
fix(util): 🐛 http请求异常bug
BREAKING CHANGE: http请求异常bug
This commit is contained in:
parent
d9e204e180
commit
6e82a099a2
@ -1,7 +1,7 @@
|
||||
# 后端服务地址
|
||||
VITE_SERVICE_URL="http://127.0.0.1:9190"
|
||||
VITE_SERVICE_URL="https://hulaspark.com"
|
||||
# websocket服务地址
|
||||
VITE_WEBSOCKET_URL="ws://127.0.0.1:8090"
|
||||
VITE_WEBSOCKET_URL="wss://hulaspark.com"
|
||||
# 项目标题
|
||||
VITE_APP_TITLE="HuLa—IM"
|
||||
# 项目名称
|
||||
|
@ -135,10 +135,10 @@ const footerOptions = ref<OPT.Details[]>([
|
||||
// TODO 需要增加独立窗口功能 (nyh -> 2024-03-25 16:01:23)
|
||||
router.push('/message')
|
||||
apis.sessionDetailWithFriends({ uid: item.value.uid as number }).then((res) => {
|
||||
globalStore.currentSession.roomId = res.data.roomId
|
||||
globalStore.currentSession.roomId = res.roomId
|
||||
globalStore.currentSession.type = RoomTypeEnum.SINGLE
|
||||
chatStore.updateSessionLastActiveTime(res.data.roomId, res.data)
|
||||
handleMsgClick(res.data as any)
|
||||
chatStore.updateSessionLastActiveTime(res.roomId, res)
|
||||
handleMsgClick(res as any)
|
||||
})
|
||||
Mitt.emit(MittEnum.TO_SEND_MSG, { url: 'message' })
|
||||
}
|
||||
|
@ -74,9 +74,9 @@ export const useChatMain = (activeItem?: SessionItem) => {
|
||||
label: '撤回',
|
||||
icon: 'corner-down-left',
|
||||
click: async (item: MessageType) => {
|
||||
const res = await apis.recallMsg({ roomId: 1, msgId: item.message.id })
|
||||
if (res.errMsg) {
|
||||
window.$message.error(res.errMsg)
|
||||
const res = (await apis.recallMsg({ roomId: 1, msgId: item.message.id })) as any
|
||||
if (res) {
|
||||
window.$message.error(res)
|
||||
return
|
||||
}
|
||||
chatStore.updateRecallStatus({ msgId: item.message.id })
|
||||
|
@ -200,8 +200,8 @@ export const useMsgInput = (messageInputDom: Ref) => {
|
||||
body: { content: msg.content, replyMsgId: msg.reply !== 0 ? msg.reply : undefined }
|
||||
})
|
||||
.then(async (res) => {
|
||||
if (res.data.message.type === MsgEnum.TEXT) {
|
||||
await chatStore.pushMsg(res.data)
|
||||
if (res.message.type === MsgEnum.TEXT) {
|
||||
await chatStore.pushMsg(res)
|
||||
}
|
||||
// 发完消息就要刷新会话列表,
|
||||
// FIXME 如果当前会话已经置顶了,可以不用刷新
|
||||
|
@ -83,8 +83,8 @@ export const useUpload = () => {
|
||||
const thumbFile = new File([blob], name, { type: 'image/jpeg' })
|
||||
// 转成File对象 并上传
|
||||
apis.getUploadUrl({ fileName: name, scene: '1' }).then(async (res) => {
|
||||
if (res.data.uploadUrl && res.data.downloadUrl) {
|
||||
await upload(res.data.uploadUrl, thumbFile, true)
|
||||
if (res.uploadUrl && res.downloadUrl) {
|
||||
await upload(res.uploadUrl, thumbFile, true)
|
||||
// 等待上传完成
|
||||
const timer = setInterval(() => {
|
||||
if (!isUploading.value) {
|
||||
@ -92,7 +92,7 @@ export const useUpload = () => {
|
||||
resolve({
|
||||
thumbWidth: canvas.width,
|
||||
thumbHeight: canvas.height,
|
||||
thumbUrl: res.data.downloadUrl,
|
||||
thumbUrl: res.downloadUrl,
|
||||
thumbSize: thumbFile.size,
|
||||
tempUrl
|
||||
})
|
||||
@ -198,7 +198,7 @@ export const useUpload = () => {
|
||||
return
|
||||
}
|
||||
|
||||
const { downloadUrl, uploadUrl } = (await apis.getUploadUrl({ fileName: info.name, scene: '1' })).data
|
||||
const { downloadUrl, uploadUrl } = await apis.getUploadUrl({ fileName: info.name, scene: '1' })
|
||||
|
||||
if (uploadUrl && downloadUrl) {
|
||||
fileInfo.value = { ...info, downloadUrl }
|
||||
|
@ -120,9 +120,9 @@ export const leftHook = () => {
|
||||
window.$message.error('改名次数不足')
|
||||
return
|
||||
}
|
||||
apis.modifyUserName(editInfo.value.content.name).then((res) => {
|
||||
if (!res.success) {
|
||||
window.$message.error(res.errMsg)
|
||||
apis.modifyUserName(editInfo.value.content.name).then((res: any) => {
|
||||
if (!res) {
|
||||
window.$message.error(res)
|
||||
return
|
||||
}
|
||||
// 更新本地缓存的用户信息
|
||||
@ -137,8 +137,8 @@ export const leftHook = () => {
|
||||
/** 佩戴徽章 */
|
||||
const toggleWarningBadge = async (badge: BadgeType) => {
|
||||
if (!badge?.id) return
|
||||
const res = await apis.setUserBadge(badge.id)
|
||||
if (res.success) {
|
||||
const res: any = await apis.setUserBadge(badge.id)
|
||||
if (res) {
|
||||
window.$message.success('佩戴成功')
|
||||
/** 获取用户信息 */
|
||||
apis.getUserInfo().then((res) => {
|
||||
|
@ -43,8 +43,7 @@ export default {
|
||||
/** 获取群成员统计 */
|
||||
getMemberStatistic: () => GET<GroupStatisticType>(urls.getMemberStatistic),
|
||||
/** 房间内的所有群成员列表-@专用 */
|
||||
getAllUserBaseInfo: (params?: any) =>
|
||||
GET<Pick<CacheUserItem, 'avatar' | 'name' | 'uid'>[]>(urls.getAllUserBaseInfo, params),
|
||||
getAllUserBaseInfo: (params?: any) => GET<CacheUserItem[]>(urls.getAllUserBaseInfo, params),
|
||||
/** 批量获取成员详细信息 */
|
||||
getUserInfoBatch: (users: CacheUserReq[]) => POST<CacheUserItem[]>(urls.getUserInfoBatch, { reqList: users }),
|
||||
/** 批量获取徽章信息 */
|
||||
|
@ -42,7 +42,7 @@ export const useCachedStore = defineStore('cached', () => {
|
||||
.filter((item) => !item.lastModifyTime || isDiffNow10Min(item.lastModifyTime))
|
||||
if (!result.length) return
|
||||
const itemIdSet: Set<number> = new Set()
|
||||
const { data } = await apis.getUserInfoBatch(result)
|
||||
const data = await apis.getUserInfoBatch(result)
|
||||
data?.forEach((item: CacheUserItem) => {
|
||||
// 更新最后更新时间。
|
||||
userCachedList[item.uid] = {
|
||||
@ -70,7 +70,7 @@ export const useCachedStore = defineStore('cached', () => {
|
||||
})
|
||||
.filter((item) => !item.lastModifyTime || isDiffNow10Min(item.lastModifyTime))
|
||||
if (!result.length) return
|
||||
const { data } = await apis.getBadgesBatch(result)
|
||||
const data = await apis.getBadgesBatch(result)
|
||||
data?.forEach(
|
||||
(item: CacheBadgeItem) =>
|
||||
// 更新最后更新时间。
|
||||
@ -85,7 +85,7 @@ export const useCachedStore = defineStore('cached', () => {
|
||||
/** 房间内的所有群成员列表-@专用 */
|
||||
const initAllUserBaseInfo = async () => {
|
||||
if (localStorage.getItem('IS_INIT_USER_BASE') === null) {
|
||||
const { data } = await apis.getAllUserBaseInfo({ params: { roomId: currentRoomId.value } })
|
||||
const data = await apis.getAllUserBaseInfo({ params: { roomId: currentRoomId.value } })
|
||||
data?.forEach((item: CacheUserItem) => (userCachedList[item.uid] = item))
|
||||
localStorage.setItem('IS_INIT_USER_BASE', 'true')
|
||||
}
|
||||
@ -93,7 +93,7 @@ export const useCachedStore = defineStore('cached', () => {
|
||||
|
||||
const getGroupAtUserBaseInfo = async () => {
|
||||
if (currentRoomId.value === 1) return
|
||||
const { data } = await apis.getAllUserBaseInfo({ params: { roomId: currentRoomId.value } })
|
||||
const data = await apis.getAllUserBaseInfo({ params: { roomId: currentRoomId.value } })
|
||||
currentAtUsersList.value = data
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ export const useChatStore = defineStore('chat', () => {
|
||||
|
||||
const getMsgList = async (size = pageSize) => {
|
||||
currentMessageOptions.value && (currentMessageOptions.value.isLoading = true)
|
||||
const { data } = await apis
|
||||
const data = await apis
|
||||
.getMsgList({
|
||||
params: {
|
||||
pageSize: size,
|
||||
@ -200,7 +200,7 @@ export const useChatStore = defineStore('chat', () => {
|
||||
sessionOptions.isLoading = false
|
||||
})
|
||||
if (!response) return
|
||||
const { data } = response
|
||||
const data = response
|
||||
if (!data) {
|
||||
return
|
||||
}
|
||||
@ -281,7 +281,7 @@ export const useChatStore = defineStore('chat', () => {
|
||||
detailResponse = await apis.sessionDetail({ id: msg.message.roomId })
|
||||
}
|
||||
if (detailResponse) {
|
||||
const { data } = detailResponse
|
||||
const data = detailResponse
|
||||
updateSessionLastActiveTime(msg.message.roomId, data)
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ export const useContactStore = defineStore('contact', () => {
|
||||
contactsOptions.isLoading = false
|
||||
})
|
||||
if (!res) return
|
||||
const { data } = res
|
||||
const data = res
|
||||
isFresh ? contactsList.splice(0, contactsList.length, ...data.list) : contactsList.push(...data.list)
|
||||
contactsOptions.cursor = data.cursor
|
||||
contactsOptions.isLast = data.isLast
|
||||
@ -39,7 +39,7 @@ export const useContactStore = defineStore('contact', () => {
|
||||
//
|
||||
})
|
||||
if (!res) return
|
||||
const { data } = res
|
||||
const data = res
|
||||
if (typeof data?.unReadCount === 'number') {
|
||||
globalStore.unReadMark.newFriendUnreadCount = data.unReadCount
|
||||
}
|
||||
@ -61,7 +61,7 @@ export const useContactStore = defineStore('contact', () => {
|
||||
// 每次加载完新的好友邀请列表都要更新申请未读数
|
||||
await getNewFriendCount()
|
||||
if (!res) return
|
||||
const { data } = res
|
||||
const data = res
|
||||
isFresh
|
||||
? requestFriendsList.splice(0, requestFriendsList.length, ...data.list)
|
||||
: requestFriendsList.push(...data.list)
|
||||
|
@ -17,10 +17,7 @@ export const useEmojiStore = defineStore('emoji', () => {
|
||||
isLoading.value = false
|
||||
})
|
||||
if (!res) return
|
||||
const {
|
||||
data: { data }
|
||||
} = res
|
||||
emojiList.value = data
|
||||
emojiList.value = res
|
||||
}
|
||||
|
||||
/**
|
||||
@ -30,7 +27,7 @@ export const useEmojiStore = defineStore('emoji', () => {
|
||||
const { uid } = userStore.userInfo
|
||||
if (!uid || !emojiUrl) return
|
||||
apis.addEmoji({ uid, expressionUrl: emojiUrl }).then((res) => {
|
||||
if (res.success) {
|
||||
if (res) {
|
||||
window.$message.success('添加成功')
|
||||
}
|
||||
})
|
||||
|
@ -95,7 +95,7 @@ export const useGroupStore = defineStore('group', () => {
|
||||
}
|
||||
})
|
||||
if (!res) return
|
||||
const { data } = res
|
||||
const data = res
|
||||
const tempNew = cloneDeep(uniqueUserList(refresh ? data.list : [...data.list, ...userList.value]))
|
||||
tempNew.sort(sorAction)
|
||||
userList.value = tempNew
|
||||
@ -112,7 +112,7 @@ export const useGroupStore = defineStore('group', () => {
|
||||
|
||||
// 获取群成员数量统计
|
||||
const getCountStatistic = async () => {
|
||||
const { data } = await apis.groupDetail({ id: currentRoomId.value })
|
||||
const data = await apis.groupDetail({ id: currentRoomId.value })
|
||||
countInfo.value = data
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ export const useSettingStore = defineStore(StoresEnum.SETTING, {
|
||||
})
|
||||
.filter((item) => !item.lastModifyTime || isDiffNow10Min(item.lastModifyTime))
|
||||
if (!result.length) return
|
||||
const { data } = await apis.getBadgesBatch(result)
|
||||
const data = await apis.getBadgesBatch(result)
|
||||
data?.forEach(
|
||||
(item: CacheBadgeItem) =>
|
||||
// 更新最后更新时间。
|
||||
|
@ -23,7 +23,7 @@ export const useUserStore = defineStore('user', () => {
|
||||
apis
|
||||
.getUserDetail()
|
||||
.then((res) => {
|
||||
userInfo.value = { ...userInfo.value, ...res.data.data }
|
||||
userInfo.value = { ...userInfo.value, ...res }
|
||||
})
|
||||
.catch(() => {
|
||||
// 删除缓存
|
||||
|
Loading…
Reference in New Issue
Block a user