import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faClose} from "@fortawesome/free-solid-svg-icons";
import { Dialog,Toast } from "antd-mobile";
import html2canvas from "html2canvas";
import {checkRole} from "../auth"
export const handleShowVideos = (video) => {
Dialog.className = "videoMask";
Dialog.show({
title: "",
content: (
{/*
*/}
),
bodyStyle: {
background: "none",
maxHeight: "none",
height: "100%",
},
});
};
//保存div内容为图片
export const saveImage = async (divId) => {
const div = document.getElementById(divId);
html2canvas(div, { useCORS: true }).then(function (canvas) {
// 创建一个图片元素
var img = canvas.toDataURL("image/jpg");
// 创建一个链接元素
var link = document.createElement("a");
link.href = img;
// 设置下载的文件名
link.download = "SAVE_IMAGE.jpg";
// 触发点击
link.click();
});
};
//保存图片
export const saveFile = async (href) => {
const isVip = checkRole();
if (!isVip) {
setIsVipModalVisible(true);
Toast.show({
icon: "fail",
content: "仅会员支持下载",
position: "top",
});
return;
}
var link = document.createElement("a");
link.href = href;
link.target = "_blank";
// 设置下载的文件名
link.download = "newfile.mp4";
// 触发点击
// link.click();
link.style.display = "none"; // 设置为隐藏元素
document.body.appendChild(link);
link.click(); // 模拟点击以开始下载
document.body.removeChild(link); // 下载后移除元素
};