mirror of
https://github.com/PlayEdu/h5.git
synced 2025-06-29 02:56:33 +08:00
课程详情课件下载
This commit is contained in:
parent
cf1fc2519c
commit
b3cd899b70
@ -49,6 +49,7 @@ const CoursePage = () => {
|
|||||||
const [tabKey, setTabKey] = useState(Number(result.get("tab") || 1));
|
const [tabKey, setTabKey] = useState(Number(result.get("tab") || 1));
|
||||||
const [attachments, setAttachments] = useState<attachModal[]>([]);
|
const [attachments, setAttachments] = useState<attachModal[]>([]);
|
||||||
const [items, setItems] = useState<tabModal[]>([]);
|
const [items, setItems] = useState<tabModal[]>([]);
|
||||||
|
const [downLoadTemplateURL, setDownLoadTemplateURL] = useState("");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getDetail();
|
getDetail();
|
||||||
@ -105,19 +106,12 @@ const CoursePage = () => {
|
|||||||
navigate(`/course/${cid}/hour/${id}`);
|
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) => {
|
const downLoadFile = (cid: number, id: number) => {
|
||||||
vod.downloadAttachment(cid, id).then((res: any) => {
|
vod.downloadAttachment(cid, id).then((res: any) => {
|
||||||
if (isWechat()) {
|
if (isWechat()) {
|
||||||
|
if (isIOS()) {
|
||||||
|
Toast.show("请点击右上角···浏览器打开下载");
|
||||||
|
}
|
||||||
var input = document.createElement("input");
|
var input = document.createElement("input");
|
||||||
input.value = res.data.download_url;
|
input.value = res.data.download_url;
|
||||||
document.body.appendChild(input);
|
document.body.appendChild(input);
|
||||||
@ -127,14 +121,11 @@ const CoursePage = () => {
|
|||||||
window.open(res.data.download_url);
|
window.open(res.data.download_url);
|
||||||
} else {
|
} else {
|
||||||
if (isIOS()) {
|
if (isIOS()) {
|
||||||
Toast.show("请点击右上角···浏览器打开下载");
|
setDownLoadTemplateURL(res.data.download_url);
|
||||||
var input = document.createElement("input");
|
setTimeout(() => {
|
||||||
input.value = res.data.download_url;
|
let $do: any = document.querySelector("#downLoadExcel");
|
||||||
document.body.appendChild(input);
|
$do.click();
|
||||||
input.select();
|
}, 500);
|
||||||
document.execCommand("Copy");
|
|
||||||
document.body.removeChild(input);
|
|
||||||
window.open(res.data.download_url);
|
|
||||||
} else {
|
} else {
|
||||||
window.open(res.data.download_url);
|
window.open(res.data.download_url);
|
||||||
}
|
}
|
||||||
@ -144,6 +135,12 @@ const CoursePage = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="main-body">
|
<div className="main-body">
|
||||||
|
<a
|
||||||
|
style={{ display: "none" }}
|
||||||
|
id="downLoadExcel"
|
||||||
|
href={downLoadTemplateURL}
|
||||||
|
download={true}
|
||||||
|
></a>
|
||||||
<div className="main-header" style={{ backgroundColor: "#FF4D4F" }}>
|
<div className="main-header" style={{ backgroundColor: "#FF4D4F" }}>
|
||||||
<Image
|
<Image
|
||||||
className="back-icon"
|
className="back-icon"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user