2024-07-06 16:03:15 +08:00
|
|
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
2024-08-15 21:03:10 +08:00
|
|
|
import { faClose } from "@fortawesome/free-solid-svg-icons";
|
|
|
|
import { Dialog, Toast } from "antd-mobile";
|
2024-07-18 23:20:42 +08:00
|
|
|
import html2canvas from "html2canvas";
|
2024-08-15 21:03:10 +08:00
|
|
|
import { checkRole } from "../auth";
|
2024-08-07 19:33:31 +08:00
|
|
|
import Player from "next-video/player";
|
|
|
|
// export const handleShowVideos = (video) => {
|
|
|
|
// Dialog.className = "videoMask";
|
|
|
|
// Dialog.show({
|
|
|
|
// title: "",
|
|
|
|
// closeOnMaskClick: true,
|
|
|
|
// content: (
|
|
|
|
// <div className="flex flex-col gap-2">
|
|
|
|
// <div className="flex w-full justify-end">
|
|
|
|
// <div
|
|
|
|
// className="flex w-12 h-12 justify-center items-center bg-[#33333348] rounded-full"
|
|
|
|
// key="closeBtn"
|
|
|
|
// onClick={() => Dialog.clear()}
|
|
|
|
// >
|
|
|
|
// <FontAwesomeIcon icon={faClose} size="2xl" />
|
|
|
|
// </div>
|
|
|
|
// </div>
|
|
|
|
// <div className="my-4">
|
|
|
|
// <video
|
|
|
|
// width="100%"
|
|
|
|
// height="100%"
|
|
|
|
// controls
|
|
|
|
// className="w-screen h-[70vh] rounded-lg object-contain"
|
|
|
|
// poster={video.url}
|
|
|
|
// >
|
|
|
|
// <source src={video.mp4} type="video/mp4" />
|
|
|
|
// 您的浏览器不支持 Video 标签。
|
|
|
|
// </video>
|
|
|
|
// </div>
|
|
|
|
// {/* <div
|
|
|
|
// className="flex w-12 h-12 justify-center items-center bg-[#33333348] rounded-full"
|
|
|
|
// key="closeBtn"
|
|
|
|
// // onClick={handleSeeAllPhotos}
|
|
|
|
// >
|
|
|
|
// <FontAwesomeIcon icon={faSave} size="2xl" />
|
|
|
|
// </div> */}
|
|
|
|
// </div>
|
|
|
|
// ),
|
|
|
|
// bodyStyle: {
|
|
|
|
// background: "none",
|
|
|
|
// maxHeight: "none",
|
|
|
|
// height: "100%",
|
|
|
|
// },
|
|
|
|
// });
|
|
|
|
// };
|
|
|
|
export const handleShowVideo = (video) => {
|
2024-07-06 16:03:15 +08:00
|
|
|
Dialog.className = "videoMask";
|
|
|
|
Dialog.show({
|
|
|
|
title: "",
|
2024-08-15 21:03:10 +08:00
|
|
|
bodyStyle: { paddingTop: 0 },
|
2024-07-06 16:03:15 +08:00
|
|
|
content: (
|
2024-08-15 21:03:10 +08:00
|
|
|
<div className="h-screen flex justify-center items-center relative">
|
|
|
|
<div
|
|
|
|
className="h-screen w-screen absolute"
|
|
|
|
onClick={() => Dialog.clear()}
|
|
|
|
></div>
|
2024-08-12 21:31:50 +08:00
|
|
|
<div className="w-screen flex flex-col gap-2 pointer-events-none absolute top-0">
|
2024-08-07 19:33:31 +08:00
|
|
|
<div className="flex w-full justify-end">
|
|
|
|
<div
|
|
|
|
className="pointer-events-auto flex w-12 h-12 justify-center items-center bg-[#33333348] rounded-full"
|
|
|
|
key="closeBtn"
|
|
|
|
onClick={() => Dialog.clear()}
|
|
|
|
>
|
|
|
|
<FontAwesomeIcon icon={faClose} size="2xl" />
|
|
|
|
</div>
|
2024-07-06 16:03:15 +08:00
|
|
|
</div>
|
2024-08-13 11:29:27 +08:00
|
|
|
<div className="my-2 pointer-events-auto">
|
2024-08-07 19:33:31 +08:00
|
|
|
{/* <video
|
2024-07-06 16:03:15 +08:00
|
|
|
width="100%"
|
|
|
|
height="100%"
|
|
|
|
controls
|
2024-08-07 19:33:31 +08:00
|
|
|
muted={true}
|
2024-07-06 16:03:15 +08:00
|
|
|
className="w-screen h-[70vh] rounded-lg object-contain"
|
2024-08-07 19:33:31 +08:00
|
|
|
poster={video?.url}
|
|
|
|
// autoPlay={true}
|
2024-07-06 16:03:15 +08:00
|
|
|
>
|
|
|
|
<source src={video.mp4} type="video/mp4" />
|
|
|
|
您的浏览器不支持 Video 标签。
|
2024-08-07 19:33:31 +08:00
|
|
|
</video> */}
|
|
|
|
{/* <Video as={ReactPlayer} src={video.mp4} /> */}
|
|
|
|
<Player
|
|
|
|
src={video.mp4}
|
|
|
|
poster={video?.url.src}
|
|
|
|
blurDataURL={video?.url.blurDataURL}
|
|
|
|
autoPlay={true}
|
2024-08-13 11:29:27 +08:00
|
|
|
style={{ height: "calc(100vh - 180px)" }}
|
2024-08-07 19:33:31 +08:00
|
|
|
/>
|
|
|
|
{/* <Player
|
|
|
|
src="https://www.mydomain.com/remote-video.mp4"
|
|
|
|
poster="https://www.mydomain.com/remote-poster.webp"
|
|
|
|
blurDataURL="data:image/webp;base64,UklGRlA..."
|
|
|
|
/> */}
|
|
|
|
</div>
|
|
|
|
{/* <div
|
2024-07-06 16:03:15 +08:00
|
|
|
className="flex w-12 h-12 justify-center items-center bg-[#33333348] rounded-full"
|
|
|
|
key="closeBtn"
|
2024-08-07 19:33:31 +08:00
|
|
|
onClick={() => saveFile(video.mp4)}
|
2024-07-06 16:03:15 +08:00
|
|
|
>
|
|
|
|
<FontAwesomeIcon icon={faSave} size="2xl" />
|
2024-07-23 20:56:25 +08:00
|
|
|
</div> */}
|
2024-08-07 19:33:31 +08:00
|
|
|
</div>
|
2024-07-06 16:03:15 +08:00
|
|
|
</div>
|
|
|
|
),
|
|
|
|
bodyStyle: {
|
|
|
|
background: "none",
|
|
|
|
maxHeight: "none",
|
|
|
|
height: "100%",
|
|
|
|
},
|
2024-08-07 19:33:31 +08:00
|
|
|
closeOnMaskClick: true,
|
2024-07-06 16:03:15 +08:00
|
|
|
});
|
|
|
|
};
|
2024-07-18 23:20:42 +08:00
|
|
|
//保存div内容为图片
|
|
|
|
export const saveImage = async (divId) => {
|
2024-08-15 21:03:10 +08:00
|
|
|
if (typeof window == "undefined") return;
|
2024-07-18 23:20:42 +08:00
|
|
|
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;
|
|
|
|
}
|
2024-08-15 21:03:10 +08:00
|
|
|
if (typeof window == "undefined") return;
|
2024-07-18 23:20:42 +08:00
|
|
|
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); // 下载后移除元素
|
|
|
|
};
|