diff --git a/index.js b/index.js index 04986f9..e317f5e 100644 --- a/index.js +++ b/index.js @@ -60,11 +60,14 @@ const init = () => { initMusicTools() getPlayInfo().then(info => { if (!info) return - global.restorePlayInfo = info if (info.listId != LIST_ID_PLAY_TEMP) { info.list = global.allList[info.listId] if (info.list) info.list = info.list.list } + + if (!info.list || !info.list[info.index]) return + global.restorePlayInfo = info + store.dispatch(playerAction.setList({ list: { list: info.list, diff --git a/publish/changeLog.md b/publish/changeLog.md index 7ffca0f..eecd5f7 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -1,5 +1,3 @@ ### 修复 -- 修复手机分享的wy歌单、某些tx、kg歌单无法打开的问题 -- 修复打开空的歌单时,点击播放全部会导致应用崩溃的问题 -- 修复企鹅音乐搜索歌曲没有结果的问题 +- 尝试修复软件启动时恢复上一次播放的歌曲可能导致软件崩溃的问题 diff --git a/src/screens/Home/SongList/ListDetail/ButtonBar.js b/src/screens/Home/SongList/ListDetail/ActionBar.js similarity index 98% rename from src/screens/Home/SongList/ListDetail/ButtonBar.js rename to src/screens/Home/SongList/ListDetail/ActionBar.js index 5965758..ba66c1d 100644 --- a/src/screens/Home/SongList/ListDetail/ButtonBar.js +++ b/src/screens/Home/SongList/ListDetail/ActionBar.js @@ -20,7 +20,7 @@ export default memo(() => { const handlePlayAll = useCallback(async() => { if (!listDetailData.info.name) return const list = await getListDetailAll(selectListInfo.id) - if (!list.length) return + // if (!list.length) return setPlayList({ list: { list, diff --git a/src/screens/Home/SongList/ListDetail/Header.js b/src/screens/Home/SongList/ListDetail/Header.js index 8bc1063..233cde4 100644 --- a/src/screens/Home/SongList/ListDetail/Header.js +++ b/src/screens/Home/SongList/ListDetail/Header.js @@ -2,7 +2,7 @@ import React, { memo } from 'react' import { View, Text, StyleSheet, ImageBackground } from 'react-native' import { AppColors, BorderWidths } from '@/theme' import { useGetter } from '@/store' -import ButtonBar from './ButtonBar' +import ButtonBar from './ActionBar' const Header = memo(() => { const selectListInfo = useGetter('songList', 'selectListInfo') diff --git a/src/screens/Home/components/PlayerPortrait/components/Pic.js b/src/screens/Home/components/PlayerPortrait/components/Pic.js index e1e8893..573bd00 100644 --- a/src/screens/Home/components/PlayerPortrait/components/Pic.js +++ b/src/screens/Home/components/PlayerPortrait/components/Pic.js @@ -35,7 +35,7 @@ export default () => { }, [playMusicInfo, setJumpPosition, setNavActiveIndex, setPrevSelectListId]) useEffect(() => { - const url = playMusicInfo ? playMusicInfo.musicInfo.img : null + const url = playMusicInfo && playMusicInfo.musicInfo ? playMusicInfo.musicInfo.img : null if (imgUrl == url) return setImgUrl(url) // eslint-disable-next-line react-hooks/exhaustive-deps diff --git a/src/screens/Home/components/PlayerPortrait/components/Title.js b/src/screens/Home/components/PlayerPortrait/components/Title.js index c6d00ed..bfaf271 100644 --- a/src/screens/Home/components/PlayerPortrait/components/Title.js +++ b/src/screens/Home/components/PlayerPortrait/components/Title.js @@ -8,7 +8,7 @@ export default () => { const downloadFileName = useGetter('common', 'downloadFileName') const playMusicInfo = useGetter('player', 'playMusicInfo') let title = '^-^' - if (playMusicInfo) { + if (playMusicInfo && playMusicInfo.musicInfo) { title = downloadFileName.replace('歌手', playMusicInfo.musicInfo.singer).replace('歌名', playMusicInfo.musicInfo.name) } // console.log(playMusicInfo) diff --git a/src/store/modules/player/action.js b/src/store/modules/player/action.js index d9b0937..8999b4d 100644 --- a/src/store/modules/player/action.js +++ b/src/store/modules/player/action.js @@ -515,6 +515,7 @@ export const getLrc = musicInfo => async(dispatch, getState) => { } export const setList = ({ list, index }) => (dispatch, getState) => { + if (!(list && list.list && list.list[index])) return dispatch(setListInfo(list)) const state = getState() diff --git a/src/store/modules/player/getter.js b/src/store/modules/player/getter.js index 9efd7a9..01bc8b3 100644 --- a/src/store/modules/player/getter.js +++ b/src/store/modules/player/getter.js @@ -1,5 +1,5 @@ import { createSelector } from 'reselect' -import { LIST_ID_PLAY_TEMP, LIST_ID_PLAY_LATER } from '@/config/constant' +import { LIST_ID_PLAY_LATER } from '@/config/constant' // sourceInfo(state, getters, rootState, { sourceNames }) {