page: 📄 blob相关

This commit is contained in:
Bunny 2024-08-01 22:19:09 +08:00
parent 9133a8c8e4
commit 022d35b8ea
3 changed files with 22 additions and 3 deletions

View File

@ -1 +1 @@
{"version":1722474202768}
{"version":1722520010238}

View File

@ -0,0 +1,18 @@
<script lang="ts" setup>
import { onMounted, ref } from 'vue';
const objectURL = ref();
/**
* * Blob相关测试
*/
const blobTest = () => {
const blob = new Blob(['这时一段文本内容'], { type: 'text/plain;charset=utf-8' });
objectURL.value = URL.createObjectURL(blob);
};
onMounted(() => blobTest());
</script>
<template>
<textarea :value="objectURL" class="w-[500px] h-[300px]" />
</template>

View File

@ -28,8 +28,9 @@ const onDownloadImage = () => {
* * 下载视频
*/
const onDownloadVideo = () => {
const imageBlob = fetch(video.value).then(res => res.blob());
imageBlob.then(blob => downloadBlob(blob, 'blob视频.mp4'));
fetch(video.value)
.then(res => res.blob())
.then(blob => downloadBlob(blob, 'blob视频.mp4'));
downloadURI(video.value, 'a标签视频.mp4');
};