Commit d16b3c3b by qlintonger xeno

添加内容+11

parent 0cd1cbbc
......@@ -416,6 +416,26 @@ export class AgoraHandle {
)
}
sendFile(data) {
const channelID = chatChannelState.value.chatChannelId;
const fromName = userStates.value.currentUserName
this.AnyRemote.sendWSFromCall(
'-2',
'ChatFile', {
msgId: generateMessageId(),
quoteId: "",
channelID,
fromName,
tip: {
fileUrl: data.fileUrl,
fileName: data.fileName,
fileSize: data.fileSize,
fileType: "file"
}
}
)
}
sendVideo(data, fileType = 'video') {
const channelID = chatChannelState.value.chatChannelId;
const fromName = userStates.value.currentUserName
......
......@@ -38,7 +38,8 @@ export const alova = createAlova({
appStore.count++
}
// 设置请求头application/json;charset=UTF-8
const isUpload = method.meta?.isUpload
const isUpload = method.config?.meta?.isUpload
console.log('the upload here', isUpload, method)
if (isUpload && method.data) {
method.data = Object.entries(method.data).reduce(function (q, w) {
if (!(w[1] instanceof File)) {
......
......@@ -40,21 +40,21 @@
</div>
<div class="px-4 py-2">
<a-space size="medium">
<a-upload :custom-request="uploadMuFile" :show-file-list="false" accept="image/*">
<a-upload :custom-request="option => uploadMuFile(option, 'image')" :show-file-list="false" accept="image/*">
<template #upload-button>
<div class="flex-center px-3 py-1 rounded cursor-pointer bg-fill-bg1">
<global-icon :size="15" icon="image"></global-icon>
</div>
</template>
</a-upload>
<a-upload :custom-request="uploadMuFile" :show-file-list="false" accept=".pdf">
<a-upload :custom-request="option => uploadMuFile(option, 'file')" :show-file-list="false" accept=".pdf">
<template #upload-button>
<div class="flex-center px-3 py-1 rounded cursor-pointer bg-fill-bg1">
<global-icon :size="15" icon="pdf"></global-icon>
</div>
</template>
</a-upload>
<a-upload :custom-request="uploadMuFile" :show-file-list="false" accept="video/*">
<a-upload :custom-request="option => uploadMuFile(option, 'video')" :show-file-list="false" accept="video/*">
<template #upload-button>
<div class="flex-center px-3 py-1 rounded cursor-pointer bg-fill-bg1">
<global-icon :size="15" icon="video"></global-icon>
......@@ -91,7 +91,7 @@ function sendMessageText() {
}
}
const uploadMuFile = (option: any) => {
const uploadMuFile = (option: any, type: string) => {
const { onError, fileItem } = option
const params = {
apiPwd: 'Ifar$2_0160_525_Mocp',
......@@ -104,13 +104,27 @@ const uploadMuFile = (option: any) => {
.then((res) => {
if (res.code == 200) {
console.log('发送内容', res)
const dataFormed = {
fileUrl: res.data.url,
fileName: res.data.name,
fileSize: Number.parseInt(res.data.size),
fileType: type
}
if (type === 'pdf') {
AnyR?.agora.sendFile(dataFormed)
} else if (type === 'image') {
AnyR?.agora.sendImage(dataFormed)
} else {
AnyR?.agora.sendVideo(dataFormed)
}
Message.success('发送成功')
} else {
onError(new Error('Upload failed'))
Message.success('发送失败')
Message.error('发送失败')
}
})
.catch((error) => {
console.log('出现错误', error);
onError(error)
}) as any
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment