From 8bd230ba0b69c7d2b9c85c11823c3cefaa06c30c Mon Sep 17 00:00:00 2001 From: amass <168062547@qq.com> Date: Tue, 20 Jun 2023 15:42:52 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=9C=A8=E9=9F=B3=E4=B9=90=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E7=BB=93=E6=9D=9F=E6=97=B6=EF=BC=8C=E6=9B=B4=E6=96=B0=E6=9A=82?= =?UTF-8?q?=E5=81=9C=E6=8C=89=E9=92=AE=E7=8A=B6=E6=80=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.js | 32 ++++++++++++++++++-------------- src/MainPage.js | 2 +- src/PlayerBar.js | 11 +++++++++-- src/business/recorderSlice.js | 5 ++++- 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/App.js b/src/App.js index 0ea7514..fc1b609 100644 --- a/src/App.js +++ b/src/App.js @@ -1,3 +1,4 @@ +import { useEffect } from 'react'; import { Routes, Route, Navigate, useNavigate } from 'react-router-dom' import { useDispatch } from 'react-redux' import { setAccessToken, setUserInfo, setSelectInfo } from "./business/userSlice.js" @@ -11,21 +12,24 @@ function App() { const navigate = useNavigate(); const [cookies, setCookie, removeCookie] = useCookies(['accessToken']); - if (cookies.accessToken) { - dispatch(setAccessToken(cookies.accessToken)); - yzs.get_user_info(yzs.uniqueDeviceIdentifier(), cookies.accessToken).then(info => { - dispatch(setUserInfo(info)); - yzs.user_select(yzs.uniqueDeviceIdentifier(), cookies.accessToken).then(info => { - dispatch(setSelectInfo(info)); + useEffect(() => { + if (cookies.accessToken) { + dispatch(setAccessToken(cookies.accessToken)); + yzs.get_user_info(yzs.uniqueDeviceIdentifier(), cookies.accessToken).then(info => { + dispatch(setUserInfo(info)); + yzs.user_select(yzs.uniqueDeviceIdentifier(), cookies.accessToken).then(info => { + dispatch(setSelectInfo(info)); + }); + }).catch(error => { + console.log(error) + if (error.returnCode === "uc_0106") { + removeCookie("accessToken"); + navigate("/login"); + } }); - }).catch(error => { - console.log(error) - if (error.returnCode === "uc_0106") { - removeCookie("accessToken"); - navigate("/login"); - } - }); - } + } + }, []); + return (
diff --git a/src/MainPage.js b/src/MainPage.js index 13a318d..52cbcca 100644 --- a/src/MainPage.js +++ b/src/MainPage.js @@ -108,7 +108,7 @@ export default function () { }).catch(error => { console.log("get list failed", error); }); - }, [accessToken, passportId]); + }, [passportId]); const onClick = () => { setOpen(!open); diff --git a/src/PlayerBar.js b/src/PlayerBar.js index fe826e0..c06a1fd 100644 --- a/src/PlayerBar.js +++ b/src/PlayerBar.js @@ -4,7 +4,7 @@ import { useEffect, useRef, useState } from "react"; import pauseIcon from "./assets/play.png"; import playIcon from "./assets/pause.png"; import downloadIcon from "./assets/download.png"; -import { setCurrentTime, togglePauseState, setCurrentWaveData } from "./business/recorderSlice.js" +import { setCurrentTime, setPauseState, togglePauseState, setCurrentWaveData } from "./business/recorderSlice.js" import { audioWaveData } from "./business/utilities" import ProgressBar from "./components/ProgressBar"; @@ -32,6 +32,7 @@ export default function ({ width, currentTime }) { }, [currentBlob]); useEffect(() => { + if (currentBlob.length <= 0) return; audioWaveData(currentBlob, (duration > 20 * 60) ? 200 : 100) .then(data => dispatch(setCurrentWaveData(data))); }, [duration]); @@ -68,6 +69,10 @@ export default function ({ width, currentTime }) { player.current.playbackRate = event.target.value; }; + const onEnded = (event) => { + dispatch(setPauseState(true)); + }; + return -