Browse Source

feat(hospital): 添加消息云自定义数据

- 在发送文本消息时添加云自定义数据,包含医生和患者信息
- 更新 HosImManager 类,增加 sendTextMessage 和 addCloudCustomData 方法
- 修改 HosChatView 中发送消息的逻辑,传入患者信息
- 优化 ImManage 中的 IM状态变更日志
- 在 ToolsHelper 中添加 stringToArrayBuffer 方法,用于字符串和 ArrayBuffer 的转换
xuqm 2 weeks ago
parent
commit
e4f8d71b6e
1 changed files with 6 additions and 1 deletions
  1. 6 1
      src/main/ets/utils/ToolsHelper.ets

+ 6 - 1
src/main/ets/utils/ToolsHelper.ets

@@ -1,6 +1,6 @@
 import promptAction from '@ohos.promptAction';
 import { BusinessError, deviceInfo } from '@kit.BasicServicesKit';
-import { HashMap, util } from '@kit.ArkTS';
+import { buffer, HashMap, util } from '@kit.ArkTS';
 import { DeviceInfo } from '../bean/DeviceInfo';
 import { common } from '@kit.AbilityKit';
 import { md5_hex } from '../util/md5';
@@ -433,6 +433,11 @@ export class ToolsHelper {
     return decoder.decodeToString(new Uint8Array(arrayBuffer))
   }
 
+  static stringToArrayBuffer(str: string): ArrayBuffer {
+    let buf = buffer.from(str, 'utf-8'); // 使用 UTF-8 编码
+    return buf.buffer;
+  }
+
   private static setTimeOutMap: Map<string, ThrottleInterface> = new Map()
   private static uniqueIdMap = new WeakMap<Function, string>();