From b3cd899b70b48669b50730c720e3d7d74235b1c7 Mon Sep 17 00:00:00 2001 From: unknown <18119604035@163.com> Date: Sun, 30 Jul 2023 16:14:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=AF=A6=E6=83=85=E8=AF=BE?= =?UTF-8?q?=E4=BB=B6=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/course/index.tsx | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/pages/course/index.tsx b/src/pages/course/index.tsx index 51f82b2..4c8ebfa 100644 --- a/src/pages/course/index.tsx +++ b/src/pages/course/index.tsx @@ -49,6 +49,7 @@ const CoursePage = () => { const [tabKey, setTabKey] = useState(Number(result.get("tab") || 1)); const [attachments, setAttachments] = useState([]); const [items, setItems] = useState([]); + const [downLoadTemplateURL, setDownLoadTemplateURL] = useState(""); useEffect(() => { getDetail(); @@ -105,19 +106,12 @@ const CoursePage = () => { navigate(`/course/${cid}/hour/${id}`); }; - const isAndroid = () => { - const u = navigator.userAgent; - - if (u.indexOf("Android") > -1 || u.indexOf("Linux") > -1) { - return true; - } - - return false; - }; - const downLoadFile = (cid: number, id: number) => { vod.downloadAttachment(cid, id).then((res: any) => { if (isWechat()) { + if (isIOS()) { + Toast.show("请点击右上角···浏览器打开下载"); + } var input = document.createElement("input"); input.value = res.data.download_url; document.body.appendChild(input); @@ -127,14 +121,11 @@ const CoursePage = () => { window.open(res.data.download_url); } else { if (isIOS()) { - Toast.show("请点击右上角···浏览器打开下载"); - var input = document.createElement("input"); - input.value = res.data.download_url; - document.body.appendChild(input); - input.select(); - document.execCommand("Copy"); - document.body.removeChild(input); - window.open(res.data.download_url); + setDownLoadTemplateURL(res.data.download_url); + setTimeout(() => { + let $do: any = document.querySelector("#downLoadExcel"); + $do.click(); + }, 500); } else { window.open(res.data.download_url); } @@ -144,6 +135,12 @@ const CoursePage = () => { return (
+