Commit 065fa1b8 authored by Administrator's avatar Administrator

手机保存

parent 8da33cf8
......@@ -284,17 +284,30 @@ const onDownloadVideo = async () => {
const arr_name = url.split('/');
const file_name = arr_name[arr_name.length - 1]; // 获取文件名
if (isMobile.value) {
const fileBlob = await (await fetch(url)).blob();
const shareData = { files: [new File([fileBlob], file_name, { type: fileBlob.type })] };
if (navigator.canShare(shareData)) {
await navigator.share(shareData);
try {
const fileBlob = await (await fetch(url)).blob();
const blobUrl = URL.createObjectURL(fileBlob);
// 创建一个隐藏的链接元素
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)');
} else {
ElMessage.error({
message: '下载失败'
});
} catch (error) {
console.error('下载失败:', error);
ElMessage.error({
message: '下载失败'
});
}
} else {
await fetch(url)
.then((url) => url.blob())
......@@ -333,7 +346,7 @@ const onDownloadVideo = async () => {
<el-form-item label="文案">
<el-input
v-model="form.text"
:autosize="{ minRows: 2, maxRows: 5 }"
:autosize="{ minRows: 2, maxRows: isMobile ? 10 : 5 }"
type="textarea"
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