From 62f6fb563d240e698ecd70b48b46790c77536458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=8B=A4=E6=B0=91?= Date: Thu, 13 Mar 2025 19:04:11 +0800 Subject: [PATCH] =?UTF-8?q?feat(chat):=20=E6=94=AF=E6=8C=81=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E6=B6=88=E6=81=AF=E5=B9=B6=E4=BC=98=E5=8C=96=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 ChatItemVideoView 组件用于显示视频消息 - 重构 ChatItemView 组件,支持文本、图片和视频消息 - 添加 VideoPreviewView 组件用于预览视频消息 - 优化 ImagePreviewView组件,增加图片下载功能 - 更新 MessageHelper,添加 videoPreviewController - 调整 HosChatView,集成新的消息预览功能 --- src/main/ets/http/HttpHelper.ets | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/ets/http/HttpHelper.ets b/src/main/ets/http/HttpHelper.ets index d328722..a4b64be 100644 --- a/src/main/ets/http/HttpHelper.ets +++ b/src/main/ets/http/HttpHelper.ets @@ -4,6 +4,8 @@ import { LogHelper } from '../../../../Index'; import { SZYXLocalStorageHelper } from '../utils/SZYXLocalStorageHelper'; import { SZYXLocalStorageKeys } from '../utils/SZYXLocalStorageKeys'; import { HttpHelperX, HttpParamsForm, HttpParamsGet, HttpParamsPost } from './HttpHelperX'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { image } from '@kit.ImageKit'; export class HttpHelper { @@ -275,7 +277,7 @@ export class HttpHelper { if (typeof data.result === 'string') { resolve(JSON.parse(data.result) as T) - }else{ + } else { resolve(data.result as T) } } else { @@ -321,4 +323,23 @@ export class HttpHelper { this.httpHandlerList.length) } } + + downloadImage(url: string): Promise { + return new Promise((resolve, reject) => { + http.createHttp() + .request(url, (error: BusinessError, data: http.HttpResponse) => { + if (error) { + reject(error) + return + } + if (data.result instanceof ArrayBuffer) { + let imageData: ArrayBuffer = data.result as ArrayBuffer; + let imageSource: image.ImageSource = image.createImageSource(imageData); + resolve(imageSource) + } else { + reject(new Error('下载图片失败')) + } + }) + }) + } } \ No newline at end of file