feat(chat): 支持视频消息并优化图片消息
- 新增 ChatItemVideoView 组件用于显示视频消息 - 重构 ChatItemView 组件,支持文本、图片和视频消息 - 添加 VideoPreviewView 组件用于预览视频消息 - 优化 ImagePreviewView组件,增加图片下载功能 - 更新 MessageHelper,添加 videoPreviewController - 调整 HosChatView,集成新的消息预览功能
这个提交包含在:
父节点
8196f908fe
当前提交
62f6fb563d
@ -4,6 +4,8 @@ import { LogHelper } from '../../../../Index';
|
|||||||
import { SZYXLocalStorageHelper } from '../utils/SZYXLocalStorageHelper';
|
import { SZYXLocalStorageHelper } from '../utils/SZYXLocalStorageHelper';
|
||||||
import { SZYXLocalStorageKeys } from '../utils/SZYXLocalStorageKeys';
|
import { SZYXLocalStorageKeys } from '../utils/SZYXLocalStorageKeys';
|
||||||
import { HttpHelperX, HttpParamsForm, HttpParamsGet, HttpParamsPost } from './HttpHelperX';
|
import { HttpHelperX, HttpParamsForm, HttpParamsGet, HttpParamsPost } from './HttpHelperX';
|
||||||
|
import { BusinessError } from '@kit.BasicServicesKit';
|
||||||
|
import { image } from '@kit.ImageKit';
|
||||||
|
|
||||||
|
|
||||||
export class HttpHelper {
|
export class HttpHelper {
|
||||||
@ -275,7 +277,7 @@ export class HttpHelper {
|
|||||||
|
|
||||||
if (typeof data.result === 'string') {
|
if (typeof data.result === 'string') {
|
||||||
resolve(JSON.parse(data.result) as T)
|
resolve(JSON.parse(data.result) as T)
|
||||||
}else{
|
} else {
|
||||||
resolve(data.result as T)
|
resolve(data.result as T)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -321,4 +323,23 @@ export class HttpHelper {
|
|||||||
this.httpHandlerList.length)
|
this.httpHandlerList.length)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
downloadImage(url: string): Promise<image.ImageSource> {
|
||||||
|
return new Promise<image.ImageSource>((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('下载图片失败'))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
正在加载...
在新工单中引用
屏蔽一个用户