From 920d33e8a4512592601346ba5c7549bc91117ef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=8B=A4=E6=B0=91?= Date: Mon, 10 Mar 2025 16:42:44 +0800 Subject: [PATCH] =?UTF-8?q?refactor(hospital):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 ApiConfig 文件,添加分号 - 重命名 ConversationBean 中的属性,首字母大写 - 移除 HosConversationVIew 中的 onLoadMore 方法 - 新增 MessageHelper工具类,用于解析和处理消息 - 优化 HttpHelper 中的 response 处理逻辑 - 在 ToolsHelper 中添加 toString 方法,用于处理 ArrayBuffer --- src/main/ets/http/HttpHelper.ets | 7 ++++++- src/main/ets/utils/ToolsHelper.ets | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/ets/http/HttpHelper.ets b/src/main/ets/http/HttpHelper.ets index eb11a5e..d328722 100644 --- a/src/main/ets/http/HttpHelper.ets +++ b/src/main/ets/http/HttpHelper.ets @@ -272,7 +272,12 @@ export class HttpHelper { this.httpHandlerList.length) } if (data.responseCode === 200) { - resolve((typeof data.result === 'string' ? JSON.parse(data.result) : data.result) as T) + + if (typeof data.result === 'string') { + resolve(JSON.parse(data.result) as T) + }else{ + resolve(data.result as T) + } } else { const err: Error = new Error() err.name = data.responseCode.toString() diff --git a/src/main/ets/utils/ToolsHelper.ets b/src/main/ets/utils/ToolsHelper.ets index cbf92d1..1a6e65f 100644 --- a/src/main/ets/utils/ToolsHelper.ets +++ b/src/main/ets/utils/ToolsHelper.ets @@ -1,6 +1,6 @@ import promptAction from '@ohos.promptAction'; import { BusinessError, deviceInfo } from '@kit.BasicServicesKit'; -import { HashMap } from '@kit.ArkTS'; +import { buffer, HashMap } from '@kit.ArkTS'; import { DeviceInfo } from '../bean/DeviceInfo'; import { common } from '@kit.AbilityKit'; import { md5_hex } from '../util/md5'; @@ -389,6 +389,10 @@ export class ToolsHelper { } + static toString(arrayBuffer: ArrayBuffer) { + return buffer.from(arrayBuffer).toString('base64') + } + private static setTimeOutMap: Map = new Map() private static uniqueIdMap = new WeakMap();