Commit 065fa1b8 authored by Administrator's avatar Administrator

手机保存

parent 8da33cf8
...@@ -284,17 +284,30 @@ const onDownloadVideo = async () => { ...@@ -284,17 +284,30 @@ const onDownloadVideo = async () => {
const arr_name = url.split('/'); const arr_name = url.split('/');
const file_name = arr_name[arr_name.length - 1]; // 获取文件名 const file_name = arr_name[arr_name.length - 1]; // 获取文件名
if (isMobile.value) { if (isMobile.value) {
const fileBlob = await (await fetch(url)).blob(); try {
const shareData = { files: [new File([fileBlob], file_name, { type: fileBlob.type })] }; const fileBlob = await (await fetch(url)).blob();
if (navigator.canShare(shareData)) { const blobUrl = URL.createObjectURL(fileBlob);
await navigator.share(shareData);
// 创建一个隐藏的链接元素
const link = document.createElement('a');
link.href = blobUrl;
link.download = file_name; // 设置下载文件名
// 触发点击事件
document.body.appendChild(link); // 将链接添加到 DOM
link.click(); // 模拟点击下载
document.body.removeChild(link); // 移除链接
// 释放 URL 对象
URL.revokeObjectURL(blobUrl);
ElMessage('下载成功了 (Download success)'); ElMessage('下载成功了 (Download success)');
} else { } catch (error) {
ElMessage.error({ console.error('下载失败:', error);
message: '下载失败' ElMessage.error({
}); message: '下载失败'
});
} }
} else { } else {
await fetch(url) await fetch(url)
.then((url) => url.blob()) .then((url) => url.blob())
...@@ -333,7 +346,7 @@ const onDownloadVideo = async () => { ...@@ -333,7 +346,7 @@ const onDownloadVideo = async () => {
<el-form-item label="文案"> <el-form-item label="文案">
<el-input <el-input
v-model="form.text" v-model="form.text"
:autosize="{ minRows: 2, maxRows: 5 }" :autosize="{ minRows: 2, maxRows: isMobile ? 10 : 5 }"
type="textarea" type="textarea"
placeholder="Please input" placeholder="Please input"
/> />
......
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