mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-07-04 01:12:10 +08:00
修复初始化列表信息可能导致崩溃的问题
This commit is contained in:
parent
09029f3771
commit
39bf0b13f6
@ -4,6 +4,7 @@ import { init as musicSdkInit } from '@/utils/musicSdk'
|
|||||||
import { getUserLists, setUserList } from '@/core/list'
|
import { getUserLists, setUserList } from '@/core/list'
|
||||||
import { setNavActiveId } from '../common'
|
import { setNavActiveId } from '../common'
|
||||||
import { getViewPrevState } from '@/utils/data'
|
import { getViewPrevState } from '@/utils/data'
|
||||||
|
import { bootLog } from '@/utils/bootLog'
|
||||||
// import { play, playList } from '../player/player'
|
// import { play, playList } from '../player/player'
|
||||||
|
|
||||||
// const initPrevPlayInfo = async(appSetting: LX.AppSetting) => {
|
// const initPrevPlayInfo = async(appSetting: LX.AppSetting) => {
|
||||||
@ -23,8 +24,9 @@ export default async(appSetting: LX.AppSetting) => {
|
|||||||
// initUserApi(), // 自定义API
|
// initUserApi(), // 自定义API
|
||||||
// ]).catch(err => log.error(err))
|
// ]).catch(err => log.error(err))
|
||||||
void musicSdkInit() // 初始化音乐sdk
|
void musicSdkInit() // 初始化音乐sdk
|
||||||
|
bootLog('User list init...')
|
||||||
setUserList(await getUserLists()) // 获取用户列表
|
setUserList(await getUserLists()) // 获取用户列表
|
||||||
|
bootLog('User list inited.')
|
||||||
setNavActiveId((await getViewPrevState()).id)
|
setNavActiveId((await getViewPrevState()).id)
|
||||||
// await initPrevPlayInfo(appSetting).catch(err => log.error(err)) // 初始化上次的歌曲播放信息
|
// await initPrevPlayInfo(appSetting).catch(err => log.error(err)) // 初始化上次的歌曲播放信息
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import SourceSelector, {
|
|||||||
type SourceSelectorType as _SourceSelectorType,
|
type SourceSelectorType as _SourceSelectorType,
|
||||||
type SourceSelectorProps as _SourceSelectorProps,
|
type SourceSelectorProps as _SourceSelectorProps,
|
||||||
} from '@/components/SourceSelector'
|
} from '@/components/SourceSelector'
|
||||||
import songlistState, { type Source, type InitState } from '@/store/leaderboard/state'
|
import leaderboardState, { type Source, type InitState } from '@/store/leaderboard/state'
|
||||||
|
|
||||||
type Sources = Readonly<InitState['sources']>
|
type Sources = Readonly<InitState['sources']>
|
||||||
type SourceSelectorCommonProps = _SourceSelectorProps<Sources>
|
type SourceSelectorCommonProps = _SourceSelectorProps<Sources>
|
||||||
@ -26,13 +26,13 @@ export default forwardRef<SourceSelectorType, SourceSelectorProps>(({ style, onS
|
|||||||
|
|
||||||
useImperativeHandle(ref, () => ({
|
useImperativeHandle(ref, () => ({
|
||||||
setSource(source) {
|
setSource(source) {
|
||||||
sourceSelectorRef.current?.setSourceList(songlistState.sources, source)
|
sourceSelectorRef.current?.setSourceList(leaderboardState.sources, source)
|
||||||
},
|
},
|
||||||
}), [])
|
}), [])
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={StyleSheet.compose<ViewStyle>(styles.selector, style)}>
|
<View style={StyleSheet.compose<ViewStyle, ViewStyle, ViewStyle>(styles.selector, style)}>
|
||||||
<SourceSelector ref={sourceSelectorRef} onSourceChange={onSourceChange} center />
|
<SourceSelector ref={sourceSelectorRef} onSourceChange={onSourceChange} center />
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
|
@ -235,7 +235,7 @@ export const getUserLists = async(): Promise<LX.List.UserListInfo[]> => {
|
|||||||
const list = await getData<LX.List.UserListInfo[]>(userListKey) ?? []
|
const list = await getData<LX.List.UserListInfo[]>(userListKey) ?? []
|
||||||
for (const info of list) {
|
for (const info of list) {
|
||||||
// 兼容v2.3.0之前版本PC端插入数字类型的ID导致其意外在末尾追加 .0 的问题
|
// 兼容v2.3.0之前版本PC端插入数字类型的ID导致其意外在末尾追加 .0 的问题
|
||||||
if (info.sourceListId?.endsWith('.0')) {
|
if (info.sourceListId?.endsWith?.('.0')) {
|
||||||
info.sourceListId = info.sourceListId.replace(idFixRxp, '')
|
info.sourceListId = info.sourceListId.replace(idFixRxp, '')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user