diff --git a/package.json b/package.json index e755050..a88a462 100644 --- a/package.json +++ b/package.json @@ -93,6 +93,7 @@ "build": "node scripts/build.js", "test": "node scripts/test.js" }, + "proxy":"https://www.hswzct.cn:12016", "eslintConfig": { "extends": [ "react-app", diff --git a/src/pages/archives/file_list.tsx b/src/pages/archives/file_list.tsx index 0290d37..3483c09 100644 --- a/src/pages/archives/file_list.tsx +++ b/src/pages/archives/file_list.tsx @@ -45,6 +45,7 @@ const FileListPage = (props: any) => { }; useEffect(() => { getFileList(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [id]); const getFileTypeFromUrl = (url) => { if (url === "" || url.length === 0) return; diff --git a/src/pages/home/homeBottom/which_video.tsx b/src/pages/home/homeBottom/which_video.tsx index 1525afe..d6684aa 100644 --- a/src/pages/home/homeBottom/which_video.tsx +++ b/src/pages/home/homeBottom/which_video.tsx @@ -27,8 +27,6 @@ const WhichVideo = (props) => { if (timer) { clearInterval(timer); } - - const fetchUrl = async () => { try { const reqs = await homeStore.getChannerStrem(deviceId, id); @@ -42,7 +40,7 @@ const WhichVideo = (props) => { fetchUrl() timer = setInterval( () => { fetchUrl(); - },15000); + },35000); }; return ( diff --git a/src/pages/home/home_video.tsx b/src/pages/home/home_video.tsx index b547ab3..a05f2a7 100644 --- a/src/pages/home/home_video.tsx +++ b/src/pages/home/home_video.tsx @@ -8,14 +8,28 @@ const HomeVideo = (props: Store) => { const { homeStore } = props; const [videoUrls, setVideoUrl] = useState | null>([]); const [showVideo, setShowVideo] = useState(false); + let timer: any = null; const [obj, setPbj] = useState({ width: "300px", }); - useEffect(() => { + const fetchUrl = () => { homeStore.getNewTask().then((res) => { setVideoUrl(res); + setShowVideo(homeStore.showVideo); }); - setShowVideo(homeStore.showVideo); + }; + useEffect(() => { + if (timer) { + clearInterval(timer); + } + fetchUrl(); + // eslint-disable-next-line react-hooks/exhaustive-deps + timer = setInterval(() => { + fetchUrl(); + }, 35000); + return () => { + clearInterval(timer); + }; }, [homeStore, homeStore.showVideo]); return (
@@ -46,7 +60,10 @@ const HomeVideo = (props: Store) => {
{videoUrls?.map((videoUrl, index) => { return ( -
+
;
); diff --git a/src/pages/home/videoTow.tsx b/src/pages/home/videoTow.tsx index 52e46b6..8438815 100644 --- a/src/pages/home/videoTow.tsx +++ b/src/pages/home/videoTow.tsx @@ -21,37 +21,42 @@ const EasyPlayer = (props: Store) => { WCS: true, hasAudio: false, }; - - // 在组件挂载后创建播放器实例 - useEffect(() => { + const init = () => { if (easyPro.current) { easyPro.current?.destroy().then(() => { - if (props.url){ + if (props.url) { create(); } }); } else { - if (props.url){ + if (props.url) { create(); } } + }; + // 在组件挂载后创建播放器实例 + useEffect(() => { + init() + return () => { if (easyPro.current) { - easyPro.current.destroy() + easyPro.current.destroy(); } }; - }, [props.url],); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [props.url]); // 创建播放器实例 const create = () => { easyPro.current = new window.EasyPlayerPro(myRef.current, { isLive: config.isLive, bufferTime: config.bufferTime, - stretch: config.stretch, + stretch: false, MSE: config.MSE, WCS: config.WCS, hasAudio: config.hasAudio, watermark: { text: { content: "easyplayer-pro" }, right: 10, top: 10 }, + isMute: false, }); play(); }; @@ -65,7 +70,7 @@ const EasyPlayer = (props: Store) => { console.log("player started"); }) .catch((e) => { - console.error("error", e); + console.error("player error", e); }); }; diff --git a/src/util/config.ts b/src/util/config.ts index ecd1449..1e36576 100644 --- a/src/util/config.ts +++ b/src/util/config.ts @@ -1,6 +1,7 @@ class Config { - // static baseUrl = "https://www.hswzct.cn:12016/"; - static baseUrl = "http://127.0.0.1:12214/"; + // static baseUrl = "/"; + static baseUrl = "https://www.hswzct.cn:12016/"; + // static baseUrl = "http://127.0.0.1:12214/"; static ws = "wss://www.hswzct.cn:12016/wsadmin?id=admin"; static userStatic = "https://www.hswzct.cn:12016/api/uploads/user/"; static videoApi = "https://sprh.hswzct.cn:4443"; //