diff --git a/components/Map/MapSelector.js b/components/Map/MapSelector.js index aeace24..53dc09f 100644 --- a/components/Map/MapSelector.js +++ b/components/Map/MapSelector.js @@ -34,11 +34,8 @@ const MapSelector = (props) => { // 初始化地图 const initMap = async () => { - await dynamicLoadJs("https://api.map.baidu.com/api?v=1.0&type=webgl&ak=OElqFYoKiAH8KFtph8ftLKF5NlNrbCUr"); - if (!window.BMapGL) { - console.error("BMapGL is not loaded"); - return; + await dynamicLoadJs("https://api.map.baidu.com/api?v=1.0&type=webgl&ak=OElqFYoKiAH8KFtph8ftLKF5NlNrbCUr"); } setLoading(true); diff --git a/components/Video/AliPlayer.js b/components/Video/AliPlayer.js index 1a64676..be44308 100644 --- a/components/Video/AliPlayer.js +++ b/components/Video/AliPlayer.js @@ -44,8 +44,11 @@ const AliPlayer = forwardRef(({ const onCreateAliPlayer = async () => { if (!containerRef.current) return; - await dynamicLoadJs("https://g.alicdn.com/apsara-media-box/imp-web-player/2.16.3/aliplayer-min.js"); - await dynamicLoadCss("https://g.alicdn.com/apsara-media-box/imp-web-player/2.16.3/skins/default/aliplayer-min.css"); + if (!window.Aliplayer) { + await dynamicLoadJs("https://g.alicdn.com/apsara-media-box/imp-web-player/2.16.3/aliplayer-min.js"); + await dynamicLoadCss("https://g.alicdn.com/apsara-media-box/imp-web-player/2.16.3/skins/default/aliplayer-min.css"); + } + onDisposeAliPlayer(); const skinLayout = [ @@ -79,51 +82,49 @@ const AliPlayer = forwardRef(({ }); } - if (typeof window.Aliplayer !== "undefined") { - playerRef.current = new window.Aliplayer( - { - id: className, - ...(source - ? { source } - : { - vid, - playauth: playAuth, - qualitySort: "asc", - format: "m3u8", - encryptType: 1, - mediaType: "video", - isLive: true, - rePlay: false, - playsinline: true, - controlBarVisibility: "hover", - }), - cover, - width, - height, - autoplay, - isLive, - useH5Prism: true, - skinLayout, - }, - (player) => { - if (autoplay) { - player.play(); - } + playerRef.current = new window.Aliplayer( + { + id: className, + ...(source + ? { source } + : { + vid, + playauth: playAuth, + qualitySort: "asc", + format: "m3u8", + encryptType: 1, + mediaType: "video", + isLive: true, + rePlay: false, + playsinline: true, + controlBarVisibility: "hover", + }), + cover, + width, + height, + autoplay, + isLive, + useH5Prism: true, + skinLayout, + }, + (player) => { + if (autoplay) { + player.play(); + } - player.on("ended", () => { - onEnded && onEnded(); - }); + player.on("ended", () => { + onEnded && onEnded(); + }); - player.on("timeupdate", () => { - onTimeupdate && onTimeupdate(player.getCurrentTime()); - }); + player.on("timeupdate", () => { + onTimeupdate && onTimeupdate(player.getCurrentTime()); + }); - if (playTime > 0) { - player.seek(playTime); - } - }, - ); - } + if (playTime > 0) { + player.seek(playTime); + } + }, + ); }; useEffect(() => {