From 95b38c85781e8a0f16940c2635e0c21b8840b80b Mon Sep 17 00:00:00 2001 From: zx <834688422@qq.com> Date: Mon, 22 Apr 2024 18:47:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=B8=8B=E8=BD=BDbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/OnlineList/index.tsx | 4 +-- .../Mylist/MusicList/MusicDownloadModal.tsx | 32 +++++++++++-------- .../Home/Views/Mylist/MusicList/index.tsx | 4 +-- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/components/OnlineList/index.tsx b/src/components/OnlineList/index.tsx index 23504f0..9f4a863 100644 --- a/src/components/OnlineList/index.tsx +++ b/src/components/OnlineList/index.tsx @@ -107,14 +107,14 @@ export default forwardRef(({ { hancelExitSelect() }} /> { hancelExitSelect() }} /> { handelDownload(info.musicInfo, "128k") }} /> + onDownloadInfo={(info) => { }} /> { handlePlay(info.musicInfo) }} onPlayLater={info => { hancelExitSelect(); handlePlayLater(info.musicInfo, info.selectedList, hancelExitSelect) }} onCopyName={info => { handleShare(info.musicInfo) }} onAdd={handleAddMusic} - onDownload={info => musicDownloadModalRef.current?.show(info)} + onDownload={info => musicDownloadModalRef.current?.show(info.musicInfo)} onDislikeMusic={info => { void handleDislikeMusic(info.musicInfo) }} /> {/* */} diff --git a/src/screens/Home/Views/Mylist/MusicList/MusicDownloadModal.tsx b/src/screens/Home/Views/Mylist/MusicList/MusicDownloadModal.tsx index 535029e..63f91ea 100644 --- a/src/screens/Home/Views/Mylist/MusicList/MusicDownloadModal.tsx +++ b/src/screens/Home/Views/Mylist/MusicList/MusicDownloadModal.tsx @@ -9,7 +9,7 @@ import { handelDownload } from './listAction' import { getOtherSource } from '@/core/music/utils' interface TitleType { - updateTitle: (musicInfo: SelectInfo['musicInfo']) => void + updateTitle: (musicInfo: LX.Music.MusicInfo) => void } const Title = forwardRef((props, ref) => { const [title, setTitle] = useState('') @@ -40,11 +40,11 @@ export interface SelectInfo { const initSelectInfo = {} interface MusicDownloadModalProps { - onDownloadInfo: (info: SelectInfo) => void + onDownloadInfo: (info: LX.Music.MusicInfo) => void } export interface MusicDownloadModalType { - show: (listInfo: any) => void + show: (info: LX.Music.MusicInfo) => void } @@ -52,7 +52,7 @@ export default forwardRef(({ on const alertRef = useRef(null) const titleRef = useRef(null) const inputRef = useRef(null) - const selectedInfo = useRef(initSelectInfo as SelectInfo) + const selectedInfo = useRef(initSelectInfo as LX.Music.MusicInfo) const [selectedQuality, setSelectedQuality] = useState("128k"); const [playQualityList, setPlayQualityList] = useState([]); const [visible, setVisible] = useState(false) @@ -62,13 +62,15 @@ export default forwardRef(({ on } const calcQualitys = () => { + console.log("calcQualitys"); + console.log("calcQualitys" + selectedInfo.current.name); setPlayQualityList([]) const map = new Map(); map.set("128k", "标准音质"); map.set("320k", "高品音质"); map.set("flac", "无损音质"); map.set("flac24bit", "Hi-Res音质"); - const qualitys = selectedInfo.current?.musicInfo.meta.qualitys; + const qualitys = selectedInfo.current.meta.qualitys; let qualityMap: QualityMap = {}; for (let index = 0; index < qualitys.length; index++) { @@ -85,7 +87,7 @@ export default forwardRef(({ on if (Object.values(qualityMap).length == map.size) { return; } - getOtherSource(selectedInfo.current?.musicInfo, true).then(res => { + getOtherSource(selectedInfo.current, true).then(res => { if (res.length == 0) { setPlayQualityList(Object.values(qualityMap)); return; @@ -118,23 +120,26 @@ export default forwardRef(({ on } const handleShow = () => { + console.log("handleShow"); + alertRef.current?.setVisible(true) requestAnimationFrame(() => { - titleRef.current?.updateTitle(selectedInfo.current.musicInfo) + titleRef.current?.updateTitle(selectedInfo.current) setTimeout(() => { inputRef.current?.focus() }, 300) }) } useImperativeHandle(ref, () => ({ - show(listInfo) { - selectedInfo.current = listInfo - + show(info) { + console.log("useImperativeHandle"); + console.log(info); + selectedInfo.current = info if (visible) { calcQualitys(); handleShow() - } - else { + } else { + calcQualitys(); setVisible(true) requestAnimationFrame(() => { handleShow() @@ -146,8 +151,7 @@ export default forwardRef(({ on const handleDownloadMusic = () => { setSelectedQuality("128k"); alertRef.current?.setVisible(false) - handelDownload(selectedInfo.current?.musicInfo, selectedQuality); - onDownloadInfo(selectedInfo.current); + handelDownload(selectedInfo.current, selectedQuality); } interface MusicOption { diff --git a/src/screens/Home/Views/Mylist/MusicList/index.tsx b/src/screens/Home/Views/Mylist/MusicList/index.tsx index 56812c3..6023b1b 100644 --- a/src/screens/Home/Views/Mylist/MusicList/index.tsx +++ b/src/screens/Home/Views/Mylist/MusicList/index.tsx @@ -152,7 +152,7 @@ export default () => { { handleUpdateMusicPosition(postion, info.listId, info.musicInfo, info.selectedList, hancelExitSelect) }} /> { handelDownload(info.musicInfo, "128k") }} /> + onDownloadInfo={(info) => { }} /> { handlePlay(info.listId, info.index) }} @@ -160,7 +160,7 @@ export default () => { onRemove={info => { hancelExitSelect(); handleRemove(info.listId, info.musicInfo, info.selectedList, hancelExitSelect) }} onDislikeMusic={info => { void handleDislikeMusic(info.musicInfo) }} onCopyName={info => { handleShare(info.musicInfo) }} - onDownload={info => musicDownloadModalRef.current?.show(info)} + onDownload={info => musicDownloadModalRef.current?.show(info.musicInfo)} onAdd={handleAddMusic} onMove={handleMoveMusic} onEditMetadata={handleEditMetadata}