perf: 上传进度的模拟

dev/timezone
Lei OT 1 year ago
parent 56b132dd38
commit c51a1f37ec

@ -1,4 +1,4 @@
import { cloneDeep, isEmpty, olog } from "@/utils/commons";
import { cloneDeep, isEmpty, olog, fixTo2Decimals } from "@/utils/commons";
import dayjs from "dayjs";
import { v4 as uuid } from "uuid";
@ -722,3 +722,5 @@ export const phoneNumberToWAID = (input) => {
return formattedNumber;
}
export const uploadProgressSimulate = () => fixTo2Decimals(Math.random() * (0.8 - 0.2) + 0.2);

@ -3,7 +3,7 @@ import { useState } from 'react';
import { FileAddOutlined } from '@ant-design/icons';
import { v4 as uuid } from 'uuid';
import { API_HOST, OSS_URL as aliOSSHost } from '@/config';
import { whatsappSupportFileTypes } from '@/channel/whatsappUtils';
import { whatsappSupportFileTypes, uploadProgressSimulate } from '@/channel/whatsappUtils';
import { isEmpty, sanitizeFilename } from '@/utils/commons';
// import useConversationStore from '@/stores/ConversationStore';
@ -40,7 +40,7 @@ const ImageUpload = ({ disabled, invokeUploadFileMessage, invokeSendUploadMessag
type: fileTypeSupport,
name: file.name,
// status: 'loading',
data: { uri: previewSrc, dataUri: '', link: '', width: '100%', height: 150, loading: 0.01 },
data: { uri: previewSrc, dataUri: '', link: '', width: '100%', height: 150, loading: uploadProgressSimulate() },
id: uuid(),
};
file.msgData = msgObj;

@ -19,7 +19,7 @@ import {
} from '@ant-design/icons';
import { isEmpty, } from '@/utils/commons';
import { v4 as uuid } from 'uuid';
import { sentMsgTypeMapped, whatsappSupportFileTypes } from '@/channel/whatsappUtils';
import { sentMsgTypeMapped, whatsappSupportFileTypes, uploadProgressSimulate } from '@/channel/whatsappUtils';
import InputTemplate from './Input/Template';
import InputEmoji from './Input/Emoji';
import InputMediaUpload from './Input/MediaUpload';
@ -143,7 +143,7 @@ const InputComposer = ({ mobile }) => {
type: fileTypeSupport,
name: file.name,
uploadStatus: 'loading',
data: { dataUri: '', link: '', width: '100%', height: 150, loading: 0.01 },
data: { dataUri: '', link: '', width: '100%', height: 150, loading: uploadProgressSimulate() },
id: uuid(),
};
//

Loading…
Cancel
Save