mirror of
https://github.com/PlayEdu/h5.git
synced 2025-06-22 00:52:50 +08:00
课程详情课件下载
This commit is contained in:
parent
22533dc828
commit
b9901b12cb
@ -4,7 +4,7 @@ import styles from "./index.module.scss";
|
|||||||
import { useNavigate, useLocation, useParams } from "react-router-dom";
|
import { useNavigate, useLocation, useParams } from "react-router-dom";
|
||||||
import backIcon from "../../assets/images/commen/icon-back-n.png";
|
import backIcon from "../../assets/images/commen/icon-back-n.png";
|
||||||
import { course as vod } from "../../api/index";
|
import { course as vod } from "../../api/index";
|
||||||
import { isEmptyObject } from "../../utils/index";
|
import { isEmptyObject, isWechat } from "../../utils/index";
|
||||||
import { Empty } from "../../components";
|
import { Empty } from "../../components";
|
||||||
import { HourCompenent } from "./compenents/hour";
|
import { HourCompenent } from "./compenents/hour";
|
||||||
|
|
||||||
@ -117,13 +117,19 @@ const CoursePage = () => {
|
|||||||
|
|
||||||
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) => {
|
||||||
var input = document.createElement("input");
|
if (isWechat()) {
|
||||||
input.value = res.data.download_url;
|
const input = document.createElement("input");
|
||||||
document.body.appendChild(input);
|
document.body.appendChild(input);
|
||||||
input.select();
|
input.setAttribute("value", res.data.download_url);
|
||||||
document.execCommand("Copy");
|
input.select();
|
||||||
document.body.removeChild(input);
|
if (document.execCommand("copy")) {
|
||||||
Toast.show("下载链接已复制,请在浏览器中粘贴下载");
|
document.execCommand("copy");
|
||||||
|
Toast.show("下载链接已复制,请在浏览器中粘贴下载");
|
||||||
|
}
|
||||||
|
document.body.removeChild(input);
|
||||||
|
} else {
|
||||||
|
window.open(res.data.download_url);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -80,3 +80,8 @@ export function isMobile() {
|
|||||||
export function isEmptyObject(obj: Object) {
|
export function isEmptyObject(obj: Object) {
|
||||||
return Object.keys(obj).length === 0;
|
return Object.keys(obj).length === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isWechat() {
|
||||||
|
let ua = window.navigator.userAgent.toLowerCase();
|
||||||
|
return /micromessenger/.test(ua);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user