|
@@ -223,6 +223,9 @@ export default defineComponent({
|
|
|
};
|
|
|
|
|
|
const onFinish = (options: any) => {
|
|
|
+ onFinishAfter(options);
|
|
|
+ };
|
|
|
+ const onFinishAfter = async (options: any) => {
|
|
|
const url = ossUploadUrl + state.key;
|
|
|
const type = formatUrlType(url);
|
|
|
let coverImg = '';
|
|
@@ -232,8 +235,7 @@ export default defineComponent({
|
|
|
coverImg = PageEnum.SONG_DEFAULT_COVER;
|
|
|
} else if (type === 'VIDEO') {
|
|
|
// 获取视频封面图
|
|
|
- // await getVideoCoverImg();
|
|
|
- coverImg = 'https://gyt.ks3-cn-beijing.ksyuncs.com/1688997532875.png';
|
|
|
+ coverImg = await getVideoCoverImg();
|
|
|
}
|
|
|
emit('update:fileList', url);
|
|
|
emit('readFileInputEventAsArrayBuffer', tempFiileBuffer.value);
|
|
@@ -246,26 +248,9 @@ export default defineComponent({
|
|
|
visiable.value = false;
|
|
|
btnLoading.value = false;
|
|
|
};
|
|
|
-
|
|
|
- // 获取文件流
|
|
|
- const base64ImgtoFile = (dataurl: string, filename = 'file') => {
|
|
|
- const arr: any = dataurl.split(',');
|
|
|
- const mime = arr[0].match(/:(.*?);/)[1];
|
|
|
- const suffix = mime.split('/')[1];
|
|
|
- const bstr = atob(arr[1]);
|
|
|
- let n = bstr.length;
|
|
|
- const u8arr = new Uint8Array(n);
|
|
|
- while (n--) {
|
|
|
- u8arr[n] = bstr.charCodeAt(n);
|
|
|
- }
|
|
|
- return new File([u8arr], `${filename}.${suffix}`, {
|
|
|
- type: mime
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
const getVideoMsg = (file: any) => {
|
|
|
return new Promise(resolve => {
|
|
|
- let dataURL = '';
|
|
|
+ // let dataURL = '';
|
|
|
const videoElement = document.createElement('video');
|
|
|
videoElement.currentTime = 1;
|
|
|
videoElement.src = URL.createObjectURL(file);
|
|
@@ -276,8 +261,12 @@ export default defineComponent({
|
|
|
canvas.width = width;
|
|
|
canvas.height = height;
|
|
|
canvas.getContext('2d').drawImage(videoElement, 0, 0, width, height); //绘制canvas
|
|
|
- dataURL = canvas.toDataURL('image/jpeg'); //转换为base64
|
|
|
- resolve(dataURL);
|
|
|
+ // dataURL = canvas.toDataURL('image/jpeg'); //转换为base64
|
|
|
+ console.log(canvas);
|
|
|
+ canvas.toBlob((blob: any) => {
|
|
|
+ console.log(blob);
|
|
|
+ resolve(blob);
|
|
|
+ });
|
|
|
});
|
|
|
});
|
|
|
};
|
|
@@ -286,8 +275,7 @@ export default defineComponent({
|
|
|
try {
|
|
|
btnLoading.value = true;
|
|
|
const imgBlob: any = await getVideoMsg(tempFiileBuffer.value);
|
|
|
- console.log(imgBlob, 'downloading');
|
|
|
- const fileName = `${props.path}${Date.now() + '.jpeg'}`;
|
|
|
+ const fileName = `${props.path}${Date.now() + '.png'}`;
|
|
|
const obj = {
|
|
|
filename: fileName,
|
|
|
bucketName: props.bucketName,
|
|
@@ -304,6 +292,7 @@ export default defineComponent({
|
|
|
policy: data.policy,
|
|
|
signature: data.signature,
|
|
|
key: fileName,
|
|
|
+ acl: 'public-read',
|
|
|
KSSAccessKeyId: data.kssAccessKeyId,
|
|
|
name: fileName
|
|
|
} as any;
|
|
@@ -311,12 +300,11 @@ export default defineComponent({
|
|
|
for (const key in fileParams) {
|
|
|
formData.append(key, fileParams[key]);
|
|
|
}
|
|
|
- console.log(base64ImgtoFile(imgBlob), 'base64ImgtoFile(imgBlob)');
|
|
|
- formData.append('file', base64ImgtoFile(imgBlob), fileName);
|
|
|
+
|
|
|
+ formData.append('file', imgBlob);
|
|
|
await axios.post(ossUploadUrl, formData);
|
|
|
|
|
|
const url = ossUploadUrl + fileName;
|
|
|
- console.log(url, '12312312');
|
|
|
return url;
|
|
|
} finally {
|
|
|
btnLoading.value = false;
|