{recordList.at(currentIndex).type === 1 ? (typeof currentLyric === "object" ? currentLyric.map((lyric, index) => {
return
- {lyric.text}
- {lyric.translation}
+ {lyric.text}
}) : ) : {typeof currentLyric === "string" ? currentLyric : ""}
}
diff --git a/src/business/recorderSlice.js b/src/business/recorderSlice.js
index b7a0dd1..92a6424 100644
--- a/src/business/recorderSlice.js
+++ b/src/business/recorderSlice.js
@@ -7,6 +7,7 @@ export const recorderSlice = createSlice({
currentIndex: 0,
currentLyric: [],
currentBlob: {},
+ currentTime: 0, // 当前音频播放时间
pause: true,
},
reducers: {
@@ -23,6 +24,9 @@ export const recorderSlice = createSlice({
setCurrentBlob: (state, action) => {
state.currentBlob = action.payload;
},
+ setCurrentTime: (state, action) => {
+ state.currentTime = action.payload;
+ },
togglePauseState: (state) => {
state.pause = !state.pause;
},
@@ -30,6 +34,6 @@ export const recorderSlice = createSlice({
})
// Action creators are generated for each case reducer function
-export const { setCurrentIndex, setList, setCurrentLyric, setCurrentBlob, togglePauseState } = recorderSlice.actions
+export const { setCurrentIndex, setList, setCurrentLyric, setCurrentBlob, togglePauseState, setCurrentTime } = recorderSlice.actions
export default recorderSlice.reducer
\ No newline at end of file
diff --git a/src/components/Waveform.js b/src/components/Waveform.js
index 4885d71..17ae108 100644
--- a/src/components/Waveform.js
+++ b/src/components/Waveform.js
@@ -1,11 +1,10 @@
import { useEffect, useRef, useState, useCallback } from "react";
-import useSetTrackProgress from "./useSetTrackProgress.js"
-import { useResizeDetector } from 'react-resize-detector';
const pointWidth = 2;
const pointMargin = 3;
+const leftPadding = 14; // 留出空间画时间戳
+const rightPadding = 14;
-const trackDuration = 60; //