|
@@ -88,8 +88,15 @@ export default defineComponent({
|
|
|
? NaturalTypeEnum.IMG
|
|
|
: file.type.includes('audio')
|
|
|
? NaturalTypeEnum.SONG
|
|
|
- : NaturalTypeEnum.VIDEO;
|
|
|
+ : file.type.includes('video')
|
|
|
+ ? NaturalTypeEnum.VIDEO
|
|
|
+ : 'other';
|
|
|
|
|
|
+ console.log(type, 'type');
|
|
|
+ if (type === 'other') {
|
|
|
+ message.error(`文件格式不支持`);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
const size = type === 'IMG' ? 2 : type === 'SONG' ? 20 : 500;
|
|
|
if (size) {
|
|
|
isLt2M = file.file.size / 1024 / 1024 < size;
|
|
@@ -124,9 +131,7 @@ export default defineComponent({
|
|
|
btnLoading.value = true;
|
|
|
const name = file.file.name;
|
|
|
const suffix = name.slice(name.lastIndexOf('.'));
|
|
|
- const fileName = `${props.path}${
|
|
|
- props.fileName || Date.now() + suffix
|
|
|
- }`;
|
|
|
+ const fileName = `${props.path}${Date.now() + file.id + suffix}`;
|
|
|
const obj = {
|
|
|
filename: fileName,
|
|
|
bucketName: props.bucketName,
|
|
@@ -166,7 +171,7 @@ export default defineComponent({
|
|
|
};
|
|
|
|
|
|
const onFinish = (options: any) => {
|
|
|
- console.log(options, 'onFinish');
|
|
|
+ // console.log(options, 'onFinish');
|
|
|
onFinishAfter(options);
|
|
|
};
|
|
|
const onFinishAfter = async (options: any) => {
|
|
@@ -193,14 +198,15 @@ export default defineComponent({
|
|
|
uploadList.value.push({
|
|
|
coverImg,
|
|
|
content: url,
|
|
|
- id: options.file.id
|
|
|
+ id: options.file.id,
|
|
|
+ name: options.file.name
|
|
|
+ ? options.file.name.slice(0, options.file.name.lastIndexOf('.'))
|
|
|
+ : ''
|
|
|
});
|
|
|
|
|
|
options.file.url = url;
|
|
|
visiable.value = false;
|
|
|
btnLoading.value = false;
|
|
|
-
|
|
|
- console.log(fileListRef.value, 'fileListRef', uploadList.value);
|
|
|
};
|
|
|
const getVideoMsg = (file: any) => {
|
|
|
return new Promise(resolve => {
|
|
@@ -216,7 +222,7 @@ export default defineComponent({
|
|
|
canvas.height = height;
|
|
|
canvas.getContext('2d').drawImage(videoElement, 0, 0, width, height); //绘制canvas
|
|
|
// dataURL = canvas.toDataURL('image/jpeg'); //转换为base64
|
|
|
- console.log(canvas);
|
|
|
+ // console.log(canvas);
|
|
|
canvas.toBlob((blob: any) => {
|
|
|
// console.log(blob);
|
|
|
resolve(blob);
|
|
@@ -266,7 +272,6 @@ export default defineComponent({
|
|
|
};
|
|
|
|
|
|
const onRemove = async (file: any) => {
|
|
|
- console.log(file, 'file');
|
|
|
const index = uploadList.value.findIndex(
|
|
|
(update: any) => update.id === file.file.id
|
|
|
);
|
|
@@ -282,11 +287,20 @@ export default defineComponent({
|
|
|
status = true;
|
|
|
}
|
|
|
});
|
|
|
- return status;
|
|
|
+ return status || fileListRef.value.length <= 0;
|
|
|
});
|
|
|
|
|
|
const onSubmit = async () => {
|
|
|
- emit('confrim', uploadList.value);
|
|
|
+ const list: any = [];
|
|
|
+ fileListRef.value.forEach((file: any) => {
|
|
|
+ const item = uploadList.value.find(
|
|
|
+ (child: any) => child.id === file.id
|
|
|
+ );
|
|
|
+ if (item) {
|
|
|
+ list.push(item);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ emit('confrim', list);
|
|
|
};
|
|
|
|
|
|
return () => (
|