mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-05-23 22:37:41 +08:00
Merge remote-tracking branch 'upstream/dev' into dev
This commit is contained in:
commit
2571ebcbd1
13177
package-lock.json
generated
13177
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -2,3 +2,11 @@
|
|||||||
|
|
||||||
- 首次使用的提示窗口可以点击背景或者返回键关闭(#577)
|
- 首次使用的提示窗口可以点击背景或者返回键关闭(#577)
|
||||||
- 上移 Toast 位置避免遮挡播放模式图标(#603 @sibojia)
|
- 上移 Toast 位置避免遮挡播放模式图标(#603 @sibojia)
|
||||||
|
|
||||||
|
### 变更
|
||||||
|
|
||||||
|
- 不再缓存换源歌曲信息
|
||||||
|
|
||||||
|
### 其他
|
||||||
|
|
||||||
|
react-native → 0.73.10
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import musicSdk, { findMusic } from '@/utils/musicSdk'
|
import musicSdk, { findMusic } from '@/utils/musicSdk'
|
||||||
import {
|
import {
|
||||||
getOtherSource as getOtherSourceFromStore,
|
// getOtherSource as getOtherSourceFromStore,
|
||||||
saveOtherSource as saveOtherSourceFromStore,
|
// saveOtherSource as saveOtherSourceFromStore,
|
||||||
getMusicUrl as getStoreMusicUrl,
|
getMusicUrl as getStoreMusicUrl,
|
||||||
getPlayerLyric as getStoreLyric,
|
getPlayerLyric as getStoreLyric,
|
||||||
} from '@/utils/data'
|
} from '@/utils/data'
|
||||||
@ -16,11 +16,11 @@ import { apis } from '@/utils/musicSdk/api-source'
|
|||||||
const getOtherSourcePromises = new Map()
|
const getOtherSourcePromises = new Map()
|
||||||
export const existTimeExp = /\[\d{1,2}:.*\d{1,4}\]/
|
export const existTimeExp = /\[\d{1,2}:.*\d{1,4}\]/
|
||||||
|
|
||||||
export const getOtherSource = async (musicInfo: LX.Music.MusicInfo | LX.Download.ListItem, isRefresh = false): Promise<LX.Music.MusicInfoOnline[]> => {
|
export const getOtherSource = async(musicInfo: LX.Music.MusicInfo | LX.Download.ListItem, isRefresh = false): Promise<LX.Music.MusicInfoOnline[]> => {
|
||||||
if (!isRefresh) {
|
// if (!isRefresh) {
|
||||||
const cachedInfo = await getOtherSourceFromStore(musicInfo.id)
|
// const cachedInfo = await getOtherSourceFromStore(musicInfo.id)
|
||||||
if (cachedInfo.length) return cachedInfo
|
// if (cachedInfo.length) return cachedInfo
|
||||||
}
|
// }
|
||||||
let key: string
|
let key: string
|
||||||
let searchMusicInfo: {
|
let searchMusicInfo: {
|
||||||
name: string
|
name: string
|
||||||
@ -61,7 +61,7 @@ export const getOtherSource = async (musicInfo: LX.Music.MusicInfo | LX.Download
|
|||||||
if (timeout) BackgroundTimer.clearTimeout(timeout)
|
if (timeout) BackgroundTimer.clearTimeout(timeout)
|
||||||
})
|
})
|
||||||
}).then((otherSource) => {
|
}).then((otherSource) => {
|
||||||
if (otherSource.length) void saveOtherSourceFromStore(musicInfo.id, otherSource)
|
// if (otherSource.length) void saveOtherSourceFromStore(musicInfo.id, otherSource)
|
||||||
return otherSource
|
return otherSource
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
if (getOtherSourcePromises.has(key)) getOtherSourcePromises.delete(key)
|
if (getOtherSourcePromises.has(key)) getOtherSourcePromises.delete(key)
|
||||||
@ -71,7 +71,7 @@ export const getOtherSource = async (musicInfo: LX.Music.MusicInfo | LX.Download
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const buildLyricInfo = async (lyricInfo: MakeOptional<LX.Player.LyricInfo, 'rawlrcInfo'>): Promise<LX.Player.LyricInfo> => {
|
export const buildLyricInfo = async(lyricInfo: MakeOptional<LX.Player.LyricInfo, 'rawlrcInfo'>): Promise<LX.Player.LyricInfo> => {
|
||||||
if (!settingState.setting['player.isS2t']) {
|
if (!settingState.setting['player.isS2t']) {
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
if (lyricInfo.rawlrcInfo) return lyricInfo
|
if (lyricInfo.rawlrcInfo) return lyricInfo
|
||||||
@ -117,7 +117,7 @@ export const buildLyricInfo = async (lyricInfo: MakeOptional<LX.Player.LyricInfo
|
|||||||
return lyricInfo.rawlrcInfo ? lyricInfo : { ...lyricInfo, rawlrcInfo: { ...lyricInfo } }
|
return lyricInfo.rawlrcInfo ? lyricInfo : { ...lyricInfo, rawlrcInfo: { ...lyricInfo } }
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getCachedLyricInfo = async (musicInfo: LX.Music.MusicInfo): Promise<LX.Player.LyricInfo | null> => {
|
export const getCachedLyricInfo = async(musicInfo: LX.Music.MusicInfo): Promise<LX.Player.LyricInfo | null> => {
|
||||||
let lrcInfo = await getStoreLyric(musicInfo)
|
let lrcInfo = await getStoreLyric(musicInfo)
|
||||||
// lrcInfo = {}
|
// lrcInfo = {}
|
||||||
if (existTimeExp.test(lrcInfo.lyric) && lrcInfo.tlyric != null) {
|
if (existTimeExp.test(lrcInfo.lyric) && lrcInfo.tlyric != null) {
|
||||||
@ -146,7 +146,7 @@ export const getCachedLyricInfo = async (musicInfo: LX.Music.MusicInfo): Promise
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getOnlineOtherSourceMusicUrlByLocal = async (musicInfo: LX.Music.MusicInfoLocal, isRefresh: boolean): Promise<{
|
export const getOnlineOtherSourceMusicUrlByLocal = async(musicInfo: LX.Music.MusicInfoLocal, isRefresh: boolean): Promise<{
|
||||||
url: string
|
url: string
|
||||||
quality: LX.Quality
|
quality: LX.Quality
|
||||||
isFromCache: boolean
|
isFromCache: boolean
|
||||||
@ -170,7 +170,7 @@ export const getOnlineOtherSourceMusicUrlByLocal = async (musicInfo: LX.Music.Mu
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getOnlineOtherSourceLyricByLocal = async (musicInfo: LX.Music.MusicInfoLocal, isRefresh: boolean): Promise<{
|
export const getOnlineOtherSourceLyricByLocal = async(musicInfo: LX.Music.MusicInfoLocal, isRefresh: boolean): Promise<{
|
||||||
lyricInfo: LX.Music.LyricInfo
|
lyricInfo: LX.Music.LyricInfo
|
||||||
isFromCache: boolean
|
isFromCache: boolean
|
||||||
}> => {
|
}> => {
|
||||||
@ -191,7 +191,7 @@ export const getOnlineOtherSourceLyricByLocal = async (musicInfo: LX.Music.Music
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getOnlineOtherSourcePicByLocal = async (musicInfo: LX.Music.MusicInfoLocal): Promise<{
|
export const getOnlineOtherSourcePicByLocal = async(musicInfo: LX.Music.MusicInfoLocal): Promise<{
|
||||||
url: string
|
url: string
|
||||||
}> => {
|
}> => {
|
||||||
if (!await global.lx.apiInitPromise[0]) throw new Error('source init failed')
|
if (!await global.lx.apiInitPromise[0]) throw new Error('source init failed')
|
||||||
@ -208,21 +208,23 @@ export const getOnlineOtherSourcePicByLocal = async (musicInfo: LX.Music.MusicIn
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// export const getPlayQuality = (highQuality: boolean, musicInfo: LX.Music.MusicInfoOnline): LX.Quality => {
|
export const TRY_QUALITYS_LIST = ['flac24bit', 'flac', '320k'] as const
|
||||||
// let type: LX.Quality = '128k'
|
type TryQualityType = typeof TRY_QUALITYS_LIST[number]
|
||||||
// let list = global.lx.qualityList[musicInfo.source]
|
export const getPlayQuality = (highQuality: LX.Quality, musicInfo: LX.Music.MusicInfoOnline): LX.Quality => {
|
||||||
// if (highQuality && musicInfo.meta._qualitys['flac'] && list && list.includes('flac')) type = 'flac'
|
|
||||||
// return type
|
|
||||||
// }
|
|
||||||
|
|
||||||
export const getPlayQuality = (playQuality: LX.Quality, musicInfo: LX.Music.MusicInfoOnline): LX.Quality => {
|
|
||||||
let type: LX.Quality = '128k'
|
let type: LX.Quality = '128k'
|
||||||
let list = global.lx.qualityList[musicInfo.source]
|
if (TRY_QUALITYS_LIST.includes(highQuality as TryQualityType)) {
|
||||||
if (musicInfo.meta._qualitys[playQuality] && list && list.includes(playQuality)) type = playQuality
|
let list = global.lx.qualityList[musicInfo.source]
|
||||||
|
|
||||||
|
let t = TRY_QUALITYS_LIST
|
||||||
|
.slice(TRY_QUALITYS_LIST.indexOf(highQuality as TryQualityType))
|
||||||
|
.find(q => musicInfo.meta._qualitys[q] && list?.includes(q))
|
||||||
|
|
||||||
|
if (t) type = t
|
||||||
|
}
|
||||||
return type
|
return type
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getOnlineOtherSourceMusicUrl = async ({ musicInfos, quality, onToggleSource, isRefresh, retryedSource = [] }: {
|
export const getOnlineOtherSourceMusicUrl = async({ musicInfos, quality, onToggleSource, isRefresh, retryedSource = [] }: {
|
||||||
musicInfos: LX.Music.MusicInfoOnline[]
|
musicInfos: LX.Music.MusicInfoOnline[]
|
||||||
quality?: LX.Quality
|
quality?: LX.Quality
|
||||||
onToggleSource: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
onToggleSource: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
||||||
@ -243,7 +245,6 @@ export const getOnlineOtherSourceMusicUrl = async ({ musicInfos, quality, onTogg
|
|||||||
if (retryedSource.includes(musicInfo.source)) continue
|
if (retryedSource.includes(musicInfo.source)) continue
|
||||||
retryedSource.push(musicInfo.source)
|
retryedSource.push(musicInfo.source)
|
||||||
if (!assertApiSupport(musicInfo.source)) continue
|
if (!assertApiSupport(musicInfo.source)) continue
|
||||||
// itemQuality = quality ?? getPlayQuality(settingState.setting['player.isPlayHighQuality'], musicInfo)
|
|
||||||
itemQuality = quality ?? getPlayQuality(settingState.setting['player.playQuality'], musicInfo)
|
itemQuality = quality ?? getPlayQuality(settingState.setting['player.playQuality'], musicInfo)
|
||||||
if (!musicInfo.meta._qualitys[itemQuality]) continue
|
if (!musicInfo.meta._qualitys[itemQuality]) continue
|
||||||
|
|
||||||
@ -277,7 +278,7 @@ export const getOnlineOtherSourceMusicUrl = async ({ musicInfos, quality, onTogg
|
|||||||
/**
|
/**
|
||||||
* 获取在线音乐URL
|
* 获取在线音乐URL
|
||||||
*/
|
*/
|
||||||
export const handleGetOnlineMusicUrl = async ({ musicInfo, quality, onToggleSource, isRefresh, allowToggleSource }: {
|
export const handleGetOnlineMusicUrl = async({ musicInfo, quality, onToggleSource, isRefresh, allowToggleSource }: {
|
||||||
musicInfo: LX.Music.MusicInfoOnline
|
musicInfo: LX.Music.MusicInfoOnline
|
||||||
quality?: LX.Quality
|
quality?: LX.Quality
|
||||||
isRefresh: boolean
|
isRefresh: boolean
|
||||||
@ -301,7 +302,7 @@ export const handleGetOnlineMusicUrl = async ({ musicInfo, quality, onToggleSour
|
|||||||
}
|
}
|
||||||
return reqPromise.then(({ url, type }: { url: string, type: LX.Quality }) => {
|
return reqPromise.then(({ url, type }: { url: string, type: LX.Quality }) => {
|
||||||
return { musicInfo, url, quality: type, isFromCache: false }
|
return { musicInfo, url, quality: type, isFromCache: false }
|
||||||
}).catch(async (err: any) => {
|
}).catch(async(err: any) => {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
if (!allowToggleSource || err.message == requestMsg.tooManyRequests) throw err
|
if (!allowToggleSource || err.message == requestMsg.tooManyRequests) throw err
|
||||||
onToggleSource()
|
onToggleSource()
|
||||||
@ -323,7 +324,7 @@ export const handleGetOnlineMusicUrl = async ({ musicInfo, quality, onToggleSour
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const getOnlineOtherSourcePicUrl = async ({ musicInfos, onToggleSource, isRefresh, retryedSource = [] }: {
|
export const getOnlineOtherSourcePicUrl = async({ musicInfos, onToggleSource, isRefresh, retryedSource = [] }: {
|
||||||
musicInfos: LX.Music.MusicInfoOnline[]
|
musicInfos: LX.Music.MusicInfoOnline[]
|
||||||
onToggleSource: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
onToggleSource: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
||||||
isRefresh: boolean
|
isRefresh: boolean
|
||||||
@ -366,7 +367,7 @@ export const getOnlineOtherSourcePicUrl = async ({ musicInfos, onToggleSource, i
|
|||||||
/**
|
/**
|
||||||
* 获取在线歌曲封面
|
* 获取在线歌曲封面
|
||||||
*/
|
*/
|
||||||
export const handleGetOnlinePicUrl = async ({ musicInfo, isRefresh, onToggleSource, allowToggleSource }: {
|
export const handleGetOnlinePicUrl = async({ musicInfo, isRefresh, onToggleSource, allowToggleSource }: {
|
||||||
musicInfo: LX.Music.MusicInfoOnline
|
musicInfo: LX.Music.MusicInfoOnline
|
||||||
onToggleSource: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
onToggleSource: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
||||||
isRefresh: boolean
|
isRefresh: boolean
|
||||||
@ -385,7 +386,7 @@ export const handleGetOnlinePicUrl = async ({ musicInfo, isRefresh, onToggleSour
|
|||||||
}
|
}
|
||||||
return reqPromise.then((url: string) => {
|
return reqPromise.then((url: string) => {
|
||||||
return { musicInfo, url, isFromCache: false }
|
return { musicInfo, url, isFromCache: false }
|
||||||
}).catch(async (err: any) => {
|
}).catch(async(err: any) => {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
if (!allowToggleSource) throw err
|
if (!allowToggleSource) throw err
|
||||||
onToggleSource()
|
onToggleSource()
|
||||||
@ -406,7 +407,7 @@ export const handleGetOnlinePicUrl = async ({ musicInfo, isRefresh, onToggleSour
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const getOnlineOtherSourceLyricInfo = async ({ musicInfos, onToggleSource, isRefresh, retryedSource = [] }: {
|
export const getOnlineOtherSourceLyricInfo = async({ musicInfos, onToggleSource, isRefresh, retryedSource = [] }: {
|
||||||
musicInfos: LX.Music.MusicInfoOnline[]
|
musicInfos: LX.Music.MusicInfoOnline[]
|
||||||
onToggleSource: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
onToggleSource: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
||||||
isRefresh: boolean
|
isRefresh: boolean
|
||||||
@ -441,7 +442,7 @@ export const getOnlineOtherSourceLyricInfo = async ({ musicInfos, onToggleSource
|
|||||||
reqPromise = Promise.reject(err)
|
reqPromise = Promise.reject(err)
|
||||||
}
|
}
|
||||||
// retryedSource.includes(musicInfo.source)
|
// retryedSource.includes(musicInfo.source)
|
||||||
return reqPromise.then(async (lyricInfo: LX.Music.LyricInfo) => {
|
return reqPromise.then(async(lyricInfo: LX.Music.LyricInfo) => {
|
||||||
return existTimeExp.test(lyricInfo.lyric) ? {
|
return existTimeExp.test(lyricInfo.lyric) ? {
|
||||||
lyricInfo,
|
lyricInfo,
|
||||||
musicInfo,
|
musicInfo,
|
||||||
@ -457,7 +458,7 @@ export const getOnlineOtherSourceLyricInfo = async ({ musicInfos, onToggleSource
|
|||||||
/**
|
/**
|
||||||
* 获取在线歌词信息
|
* 获取在线歌词信息
|
||||||
*/
|
*/
|
||||||
export const handleGetOnlineLyricInfo = async ({ musicInfo, onToggleSource, isRefresh, allowToggleSource }: {
|
export const handleGetOnlineLyricInfo = async({ musicInfo, onToggleSource, isRefresh, allowToggleSource }: {
|
||||||
musicInfo: LX.Music.MusicInfoOnline
|
musicInfo: LX.Music.MusicInfoOnline
|
||||||
onToggleSource: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
onToggleSource: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
||||||
isRefresh: boolean
|
isRefresh: boolean
|
||||||
@ -475,13 +476,13 @@ export const handleGetOnlineLyricInfo = async ({ musicInfo, onToggleSource, isRe
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
reqPromise = Promise.reject(err)
|
reqPromise = Promise.reject(err)
|
||||||
}
|
}
|
||||||
return reqPromise.then(async (lyricInfo: LX.Music.LyricInfo) => {
|
return reqPromise.then(async(lyricInfo: LX.Music.LyricInfo) => {
|
||||||
return existTimeExp.test(lyricInfo.lyric) ? {
|
return existTimeExp.test(lyricInfo.lyric) ? {
|
||||||
musicInfo,
|
musicInfo,
|
||||||
lyricInfo,
|
lyricInfo,
|
||||||
isFromCache: false,
|
isFromCache: false,
|
||||||
} : Promise.reject(new Error('failed'))
|
} : Promise.reject(new Error('failed'))
|
||||||
}).catch(async (err: any) => {
|
}).catch(async(err: any) => {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
if (!allowToggleSource) throw err
|
if (!allowToggleSource) throw err
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user