diff --git a/publish/changeLog.md b/publish/changeLog.md index 97d519e..5da4859 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -6,3 +6,7 @@ ### 优化 - 优化应用布局对手机系统字体大小的适配 + +### 修复 + +- 尝试修复某些情况下进播放详情歌词界面时报错的问题 diff --git a/src/plugins/lyric.js b/src/plugins/lyric.js index 4394584..53054a0 100644 --- a/src/plugins/lyric.js +++ b/src/plugins/lyric.js @@ -28,6 +28,7 @@ const lrcTools = { onSetLyric(lines) { this.currentLines = lines for (const hook of this.setLyricHooks) hook(lines) + for (const hook of this.playHooks) hook(-1, '') }, addPlayHook(callback) { this.playHooks.push(callback) diff --git a/src/screens/PlayDetail/Portrait/Player/Lyric.js b/src/screens/PlayDetail/Portrait/Player/Lyric.js index 3431cf2..4f1e8e8 100644 --- a/src/screens/PlayDetail/Portrait/Player/Lyric.js +++ b/src/screens/PlayDetail/Portrait/Player/Lyric.js @@ -3,6 +3,8 @@ import { View, Text, StyleSheet, FlatList } from 'react-native' import { useGetter, useDispatch } from '@/store' import { useLayout } from '@/utils/hooks' import { useLrcPlay, useLrcSet } from '@/plugins/lyric' +import { log } from '@/utils/log' +import { toast } from '@/utils/tools' const LrcLine = memo(({ text, line, activeLine }) => { const theme = useGetter('common', 'theme') @@ -41,12 +43,18 @@ export default memo(() => { // const imgWidth = useMemo(() => layout.width * 0.75, [layout.width]) const handleScrollToActive = useCallback((index = lineRef.current) => { + if (index < 0) return if (scrollViewRef.current) { - scrollViewRef.current.scrollToIndex({ - index, - animated: true, - viewPosition: 0.4, - }) + try { + scrollViewRef.current.scrollToIndex({ + index: index, + animated: true, + viewPosition: 0.4, + }) + } catch (err) { + toast('出了点意外...你可以去错误日志查看错误', 'long') + log.warn('Scroll failed: ', err.message) + } } }, [])