+ return
{lyric.text}
}) :
) :
{typeof currentLyric === "string" ? currentLyric : ""}
}
diff --git a/src/RecordLyrics.module.css b/src/RecordLyrics.module.css
deleted file mode 100644
index 13494e3..0000000
--- a/src/RecordLyrics.module.css
+++ /dev/null
@@ -1,9 +0,0 @@
-.lyricsBrowser {
- margin-top: 16px;
- padding-bottom: 40px;
- padding: 24px;
-}
-
-.lyricItem {
- padding-bottom: 40px;
-}
\ No newline at end of file
diff --git a/src/business/request.js b/src/business/request.js
index e7c7969..43858f1 100644
--- a/src/business/request.js
+++ b/src/business/request.js
@@ -183,10 +183,11 @@ const yzs = {
'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
},
}).then(response => response.json()).then((json) => {
- console.log("flushToken: ", json.result.flushToken);
+ if (json.returnCode != "uc_0000") {
+ throw json.message;
+ }
+ // console.log("flushToken: ", json.result.flushToken);
return json.result.flushToken;
- }).catch(error => {
- console.log(error);
});
},
dynamic_code_login: function (udid, userCell, phoneCode) {
diff --git a/src/business/utilities.js b/src/business/utilities.js
index 868cd1a..14f17d1 100644
--- a/src/business/utilities.js
+++ b/src/business/utilities.js
@@ -1,3 +1,12 @@
+// 间隔多长时间取一个采样点
+// duration 秒,有小数点
+const sampleInterval = (duration) => {
+ let interval = (duration > 20 * 60) ? 200 : 100;
+ let isFirefox = window.navigator.userAgent.includes("Firefox");
+ if (isFirefox && (interval < 400)) interval = 400; // firefox canvas width 不能过长
+ return interval;
+}
+
// interval 间隔ms采点
function audioWaveData(url, interval) {
if (url.length <= 0) return;
@@ -24,4 +33,4 @@ function audioWaveData(url, interval) {
});
}
-export { audioWaveData };
\ No newline at end of file
+export { sampleInterval, audioWaveData };
\ No newline at end of file
diff --git a/src/components/ProgressBar.js b/src/components/ProgressBar.js
index 3558ca3..2338e1f 100644
--- a/src/components/ProgressBar.js
+++ b/src/components/ProgressBar.js
@@ -1,4 +1,6 @@
import { useRef, useCallback, useState, useEffect } from "react";
+import { sampleInterval } from "../business/utilities"
+import { useMemo } from "react";
const pointWidth = 2;
const pointMargin = 3;
@@ -82,7 +84,7 @@ const paintCanvas = ({
// duration ms
export default function ({ width, duration, currentTime, playing, seek, waveData }) {
- const interval = (duration > 20 * 60 * 1000) ? 200 : 100; // ms
+ const interval = useMemo(() => sampleInterval(duration / 1000), [duration]);
const container = useRef(null);
const canvas = useRef(null);
const [scrollLeft, setScrollLeft] = useState(0);
diff --git a/src/RecordList.js b/src/components/RecordList.js
similarity index 90%
rename from src/RecordList.js
rename to src/components/RecordList.js
index 0ef1d61..8447ad0 100644
--- a/src/RecordList.js
+++ b/src/components/RecordList.js
@@ -8,16 +8,14 @@ import ListItemButton from '@mui/material/ListItemButton';
import ListItemText from '@mui/material/ListItemText';
import Typography from '@mui/material/Typography';
import Toolbar from '@mui/material/Toolbar';
-import { setCurrentIndex } from "./business/recorderSlice.js"
+import { setCurrentIndex } from "../business/recorderSlice.js"
import AccessTimeFilledIcon from '@mui/icons-material/AccessTimeFilled';
const drawerWidth = 240;
-export default function ({ open, fetchRecord }) {
+export default function ({ open, recordList, currentIndex, fetchRecord }) {
const dispatch = useDispatch();
const accessToken = useSelector(state => state.user.accessToken);
- const currentIndex = useSelector(state => state.recorder.currentIndex);
- const recordList = useSelector(state => state.recorder.list);
const onSelected = (event, index) => {
console.log("onSelected", index, recordList.at(index).transResultUrl)
dispatch(setCurrentIndex(index));