mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-05-23 22:37:41 +08:00
code lint
This commit is contained in:
parent
341bf55c5d
commit
538a140487
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
const baseRule = {
|
const baseRule = {
|
||||||
'no-new': 'off',
|
'no-new': 'off',
|
||||||
camelcase: 'off',
|
camelcase: 'off',
|
||||||
@ -6,8 +5,8 @@ const baseRule = {
|
|||||||
'space-before-function-paren': ['error', 'never'],
|
'space-before-function-paren': ['error', 'never'],
|
||||||
'no-var': 'error',
|
'no-var': 'error',
|
||||||
'no-fallthrough': 'off',
|
'no-fallthrough': 'off',
|
||||||
'prefer-promise-reject-errors': 'off',
|
|
||||||
eqeqeq: 'off',
|
eqeqeq: 'off',
|
||||||
|
'require-atomic-updates': ['error', { allowProperties: true }],
|
||||||
'no-multiple-empty-lines': [1, { max: 2 }],
|
'no-multiple-empty-lines': [1, { max: 2 }],
|
||||||
'comma-dangle': [2, 'always-multiline'],
|
'comma-dangle': [2, 'always-multiline'],
|
||||||
'standard/no-callback-literal': 'off',
|
'standard/no-callback-literal': 'off',
|
||||||
|
@ -40,7 +40,7 @@ const handleInit = async() => {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
isInited = true
|
isInited ||= true
|
||||||
}
|
}
|
||||||
|
|
||||||
initNavigation(async() => {
|
initNavigation(async() => {
|
||||||
|
@ -57,7 +57,7 @@ export default async() => {
|
|||||||
|
|
||||||
// syncSetting()
|
// syncSetting()
|
||||||
|
|
||||||
isInited = true
|
isInited ||= true
|
||||||
|
|
||||||
return handlePushedHomeScreen
|
return handlePushedHomeScreen
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ export const getMusicUrl = async({ musicInfo, isRefresh, onToggleSource = () =>
|
|||||||
// if (path) return path
|
// if (path) return path
|
||||||
// }
|
// }
|
||||||
|
|
||||||
return await getOnlineMusicUrl({ musicInfo: musicInfo.metadata.musicInfo, isRefresh, onToggleSource })
|
return getOnlineMusicUrl({ musicInfo: musicInfo.metadata.musicInfo, isRefresh, onToggleSource })
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getPicUrl = async({ musicInfo, isRefresh, listId, onToggleSource = () => {} }: {
|
export const getPicUrl = async({ musicInfo, isRefresh, listId, onToggleSource = () => {} }: {
|
||||||
@ -38,7 +38,7 @@ export const getPicUrl = async({ musicInfo, isRefresh, listId, onToggleSource =
|
|||||||
if (onlineMusicInfo.meta.picUrl) return onlineMusicInfo.meta.picUrl
|
if (onlineMusicInfo.meta.picUrl) return onlineMusicInfo.meta.picUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
return await getOnlinePicUrl({ musicInfo: musicInfo.metadata.musicInfo, isRefresh, onToggleSource }).then((url) => {
|
return getOnlinePicUrl({ musicInfo: musicInfo.metadata.musicInfo, isRefresh, onToggleSource }).then((url) => {
|
||||||
// TODO: when listId required save url (update downloadInfo)
|
// TODO: when listId required save url (update downloadInfo)
|
||||||
|
|
||||||
return url
|
return url
|
||||||
@ -52,7 +52,7 @@ export const getLyricInfo = async({ musicInfo, isRefresh, onToggleSource = () =>
|
|||||||
}): Promise<LX.Player.LyricInfo> => {
|
}): Promise<LX.Player.LyricInfo> => {
|
||||||
if (!isRefresh) {
|
if (!isRefresh) {
|
||||||
const lyricInfo = await getCachedLyricInfo(musicInfo.metadata.musicInfo)
|
const lyricInfo = await getCachedLyricInfo(musicInfo.metadata.musicInfo)
|
||||||
if (lyricInfo) return await buildLyricInfo(lyricInfo)
|
if (lyricInfo) return buildLyricInfo(lyricInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
return getOnlineLyricInfo({
|
return getOnlineLyricInfo({
|
||||||
|
@ -31,11 +31,11 @@ export const getMusicUrl = async({
|
|||||||
onToggleSource?: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
onToggleSource?: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
||||||
}): Promise<string> => {
|
}): Promise<string> => {
|
||||||
if ('progress' in musicInfo) {
|
if ('progress' in musicInfo) {
|
||||||
return await getDownloadMusicUrl({ musicInfo, isRefresh, onToggleSource })
|
return getDownloadMusicUrl({ musicInfo, isRefresh, onToggleSource })
|
||||||
} else if (musicInfo.source == 'local') {
|
} else if (musicInfo.source == 'local') {
|
||||||
return await getLocalMusicUrl({ musicInfo, isRefresh, onToggleSource })
|
return getLocalMusicUrl({ musicInfo, isRefresh, onToggleSource })
|
||||||
} else {
|
} else {
|
||||||
return await getOnlineMusicUrl({ musicInfo, isRefresh, quality, onToggleSource })
|
return getOnlineMusicUrl({ musicInfo, isRefresh, quality, onToggleSource })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,11 +51,11 @@ export const getPicPath = async({
|
|||||||
onToggleSource?: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
onToggleSource?: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
||||||
}): Promise<string> => {
|
}): Promise<string> => {
|
||||||
if ('progress' in musicInfo) {
|
if ('progress' in musicInfo) {
|
||||||
return await getDownloadPicUrl({ musicInfo, isRefresh, listId, onToggleSource })
|
return getDownloadPicUrl({ musicInfo, isRefresh, listId, onToggleSource })
|
||||||
} else if (musicInfo.source == 'local') {
|
} else if (musicInfo.source == 'local') {
|
||||||
return await getLocalPicUrl({ musicInfo, isRefresh, listId, onToggleSource })
|
return getLocalPicUrl({ musicInfo, isRefresh, listId, onToggleSource })
|
||||||
} else {
|
} else {
|
||||||
return await getOnlinePicUrl({ musicInfo, isRefresh, listId, onToggleSource })
|
return getOnlinePicUrl({ musicInfo, isRefresh, listId, onToggleSource })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,10 +69,10 @@ export const getLyricInfo = async({
|
|||||||
onToggleSource?: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
onToggleSource?: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
||||||
}): Promise<LX.Player.LyricInfo> => {
|
}): Promise<LX.Player.LyricInfo> => {
|
||||||
if ('progress' in musicInfo) {
|
if ('progress' in musicInfo) {
|
||||||
return await getDownloadLyricInfo({ musicInfo, isRefresh, onToggleSource })
|
return getDownloadLyricInfo({ musicInfo, isRefresh, onToggleSource })
|
||||||
} else if (musicInfo.source == 'local') {
|
} else if (musicInfo.source == 'local') {
|
||||||
return await getLocalLyricInfo({ musicInfo, isRefresh, onToggleSource })
|
return getLocalLyricInfo({ musicInfo, isRefresh, onToggleSource })
|
||||||
} else {
|
} else {
|
||||||
return await getOnlineLyricInfo({ musicInfo, isRefresh, onToggleSource })
|
return getOnlineLyricInfo({ musicInfo, isRefresh, onToggleSource })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ export const getMusicUrl = async({ musicInfo, isRefresh, onToggleSource = () =>
|
|||||||
onToggleSource()
|
onToggleSource()
|
||||||
const otherSource = await getOtherSource(musicInfo)
|
const otherSource = await getOtherSource(musicInfo)
|
||||||
if (!otherSource.length) throw new Error('source not found')
|
if (!otherSource.length) throw new Error('source not found')
|
||||||
return await getOnlineOtherSourceMusicUrl({ musicInfos: [...otherSource], onToggleSource, isRefresh }).then(({ url, quality: targetQuality, musicInfo: targetMusicInfo, isFromCache }) => {
|
return getOnlineOtherSourceMusicUrl({ musicInfos: [...otherSource], onToggleSource, isRefresh }).then(({ url, quality: targetQuality, musicInfo: targetMusicInfo, isFromCache }) => {
|
||||||
// saveLyric(musicInfo, data.lyricInfo)
|
// saveLyric(musicInfo, data.lyricInfo)
|
||||||
if (!isFromCache) void saveMusicUrl(targetMusicInfo, targetQuality, url)
|
if (!isFromCache) void saveMusicUrl(targetMusicInfo, targetQuality, url)
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ export const getPicUrl = async({ musicInfo, listId, isRefresh, onToggleSource =
|
|||||||
onToggleSource()
|
onToggleSource()
|
||||||
const otherSource = await getOtherSource(musicInfo)
|
const otherSource = await getOtherSource(musicInfo)
|
||||||
if (!otherSource.length) throw new Error('source not found')
|
if (!otherSource.length) throw new Error('source not found')
|
||||||
return await getOnlineOtherSourcePicUrl({ musicInfos: [...otherSource], onToggleSource, isRefresh }).then(({ url, musicInfo: targetMusicInfo, isFromCache }) => {
|
return getOnlineOtherSourcePicUrl({ musicInfos: [...otherSource], onToggleSource, isRefresh }).then(({ url, musicInfo: targetMusicInfo, isFromCache }) => {
|
||||||
if (listId) {
|
if (listId) {
|
||||||
musicInfo.meta.picUrl = url
|
musicInfo.meta.picUrl = url
|
||||||
void updateListMusics([{ id: listId, musicInfo }])
|
void updateListMusics([{ id: listId, musicInfo }])
|
||||||
@ -67,7 +67,7 @@ export const getLyricInfo = async({ musicInfo, isRefresh, onToggleSource = () =>
|
|||||||
const lyricInfo = await getCachedLyricInfo(musicInfo)
|
const lyricInfo = await getCachedLyricInfo(musicInfo)
|
||||||
if (lyricInfo) {
|
if (lyricInfo) {
|
||||||
// 存在已编辑、原始歌词
|
// 存在已编辑、原始歌词
|
||||||
if (lyricInfo.rawlrcInfo.lyric) return await buildLyricInfo(lyricInfo)
|
if (lyricInfo.rawlrcInfo.lyric) return buildLyricInfo(lyricInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 尝试读取文件内歌词
|
// 尝试读取文件内歌词
|
||||||
@ -79,7 +79,7 @@ export const getLyricInfo = async({ musicInfo, isRefresh, onToggleSource = () =>
|
|||||||
const otherSource = await getOtherSource(musicInfo)
|
const otherSource = await getOtherSource(musicInfo)
|
||||||
if (!otherSource.length) throw new Error('source not found')
|
if (!otherSource.length) throw new Error('source not found')
|
||||||
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
||||||
return await getOnlineOtherSourceLyricInfo({ musicInfos: [...otherSource], onToggleSource, isRefresh }).then(({ lyricInfo, musicInfo: targetMusicInfo, isFromCache }) => {
|
return getOnlineOtherSourceLyricInfo({ musicInfos: [...otherSource], onToggleSource, isRefresh }).then(({ lyricInfo, musicInfo: targetMusicInfo, isFromCache }) => {
|
||||||
void saveLyric(musicInfo, lyricInfo)
|
void saveLyric(musicInfo, lyricInfo)
|
||||||
|
|
||||||
if (isFromCache) return buildLyricInfo(lyricInfo)
|
if (isFromCache) return buildLyricInfo(lyricInfo)
|
||||||
|
@ -56,7 +56,7 @@ export const getMusicUrl = async({ musicInfo, quality, isRefresh, allowToggleSou
|
|||||||
const cachedUrl = await getStoreMusicUrl(musicInfo, targetQuality)
|
const cachedUrl = await getStoreMusicUrl(musicInfo, targetQuality)
|
||||||
if (cachedUrl && !isRefresh) return cachedUrl
|
if (cachedUrl && !isRefresh) return cachedUrl
|
||||||
|
|
||||||
return await handleGetOnlineMusicUrl({ musicInfo, quality, onToggleSource, isRefresh, allowToggleSource }).then(({ url, quality: targetQuality, musicInfo: targetMusicInfo, isFromCache }) => {
|
return handleGetOnlineMusicUrl({ musicInfo, quality, onToggleSource, isRefresh, allowToggleSource }).then(({ url, quality: targetQuality, musicInfo: targetMusicInfo, isFromCache }) => {
|
||||||
if (targetMusicInfo.id != musicInfo.id && !isFromCache) void saveMusicUrl(targetMusicInfo, targetQuality, url)
|
if (targetMusicInfo.id != musicInfo.id && !isFromCache) void saveMusicUrl(targetMusicInfo, targetQuality, url)
|
||||||
void saveMusicUrl(musicInfo, targetQuality, url)
|
void saveMusicUrl(musicInfo, targetQuality, url)
|
||||||
return url
|
return url
|
||||||
@ -71,7 +71,7 @@ export const getPicUrl = async({ musicInfo, listId, isRefresh, allowToggleSource
|
|||||||
onToggleSource?: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
onToggleSource?: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
||||||
}): Promise<string> => {
|
}): Promise<string> => {
|
||||||
if (musicInfo.meta.picUrl && !isRefresh) return musicInfo.meta.picUrl
|
if (musicInfo.meta.picUrl && !isRefresh) return musicInfo.meta.picUrl
|
||||||
return await handleGetOnlinePicUrl({ musicInfo, onToggleSource, isRefresh, allowToggleSource }).then(({ url, musicInfo: targetMusicInfo, isFromCache }) => {
|
return handleGetOnlinePicUrl({ musicInfo, onToggleSource, isRefresh, allowToggleSource }).then(({ url, musicInfo: targetMusicInfo, isFromCache }) => {
|
||||||
// picRequest = null
|
// picRequest = null
|
||||||
if (listId) {
|
if (listId) {
|
||||||
musicInfo.meta.picUrl = url
|
musicInfo.meta.picUrl = url
|
||||||
@ -89,16 +89,16 @@ export const getLyricInfo = async({ musicInfo, isRefresh, allowToggleSource = tr
|
|||||||
}): Promise<LX.Player.LyricInfo> => {
|
}): Promise<LX.Player.LyricInfo> => {
|
||||||
if (!isRefresh) {
|
if (!isRefresh) {
|
||||||
const lyricInfo = await getCachedLyricInfo(musicInfo)
|
const lyricInfo = await getCachedLyricInfo(musicInfo)
|
||||||
if (lyricInfo) return await buildLyricInfo(lyricInfo)
|
if (lyricInfo) return buildLyricInfo(lyricInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
// lrcRequest = music[musicInfo.source].getLyric(musicInfo)
|
// lrcRequest = music[musicInfo.source].getLyric(musicInfo)
|
||||||
return await handleGetOnlineLyricInfo({ musicInfo, onToggleSource, isRefresh, allowToggleSource }).then(async({ lyricInfo, musicInfo: targetMusicInfo, isFromCache }) => {
|
return handleGetOnlineLyricInfo({ musicInfo, onToggleSource, isRefresh, allowToggleSource }).then(async({ lyricInfo, musicInfo: targetMusicInfo, isFromCache }) => {
|
||||||
// lrcRequest = null
|
// lrcRequest = null
|
||||||
if (isFromCache) return await buildLyricInfo(lyricInfo)
|
if (isFromCache) return buildLyricInfo(lyricInfo)
|
||||||
if (targetMusicInfo.id == musicInfo.id) void saveLyric(musicInfo, lyricInfo)
|
if (targetMusicInfo.id == musicInfo.id) void saveLyric(musicInfo, lyricInfo)
|
||||||
else void saveLyric(targetMusicInfo, lyricInfo)
|
else void saveLyric(targetMusicInfo, lyricInfo)
|
||||||
|
|
||||||
return await buildLyricInfo(lyricInfo)
|
return buildLyricInfo(lyricInfo)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ export const buildLyricInfo = async(lyricInfo: MakeOptional<LX.Player.LyricInfo,
|
|||||||
tasks.push(lyricInfo.rlyric ? langS2T(lyricInfo.rlyric) : Promise.resolve(''))
|
tasks.push(lyricInfo.rlyric ? langS2T(lyricInfo.rlyric) : Promise.resolve(''))
|
||||||
tasks.push(lyricInfo.lxlyric ? langS2T(lyricInfo.lxlyric) : Promise.resolve(''))
|
tasks.push(lyricInfo.lxlyric ? langS2T(lyricInfo.lxlyric) : Promise.resolve(''))
|
||||||
}
|
}
|
||||||
return await Promise.all(tasks).then(([lyric, tlyric, rlyric, lxlyric, lyric_raw, tlyric_raw, rlyric_raw, lxlyric_raw]) => {
|
return Promise.all(tasks).then(([lyric, tlyric, rlyric, lxlyric, lyric_raw, tlyric_raw, rlyric_raw, lxlyric_raw]) => {
|
||||||
const rawlrcInfo = lyric_raw ? {
|
const rawlrcInfo = lyric_raw ? {
|
||||||
lyric: lyric_raw,
|
lyric: lyric_raw,
|
||||||
tlyric: tlyric_raw,
|
tlyric: tlyric_raw,
|
||||||
@ -222,7 +222,7 @@ export const handleGetOnlineMusicUrl = async({ musicInfo, quality, onToggleSourc
|
|||||||
if (!allowToggleSource || err.message == requestMsg.tooManyRequests) throw err
|
if (!allowToggleSource || err.message == requestMsg.tooManyRequests) throw err
|
||||||
onToggleSource()
|
onToggleSource()
|
||||||
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
||||||
return await getOtherSource(musicInfo).then(otherSource => {
|
return getOtherSource(musicInfo).then(otherSource => {
|
||||||
// console.log('find otherSource', otherSource.length)
|
// console.log('find otherSource', otherSource.length)
|
||||||
if (otherSource.length) {
|
if (otherSource.length) {
|
||||||
return getOnlineOtherSourceMusicUrl({
|
return getOnlineOtherSourceMusicUrl({
|
||||||
@ -306,7 +306,7 @@ export const handleGetOnlinePicUrl = async({ musicInfo, isRefresh, onToggleSourc
|
|||||||
if (!allowToggleSource) throw err
|
if (!allowToggleSource) throw err
|
||||||
onToggleSource()
|
onToggleSource()
|
||||||
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
||||||
return await getOtherSource(musicInfo).then(otherSource => {
|
return getOtherSource(musicInfo).then(otherSource => {
|
||||||
// console.log('find otherSource', otherSource.length)
|
// console.log('find otherSource', otherSource.length)
|
||||||
if (otherSource.length) {
|
if (otherSource.length) {
|
||||||
return getOnlineOtherSourcePicUrl({
|
return getOnlineOtherSourcePicUrl({
|
||||||
@ -403,7 +403,7 @@ export const handleGetOnlineLyricInfo = async({ musicInfo, onToggleSource, isRef
|
|||||||
|
|
||||||
onToggleSource()
|
onToggleSource()
|
||||||
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
||||||
return await getOtherSource(musicInfo).then(otherSource => {
|
return getOtherSource(musicInfo).then(otherSource => {
|
||||||
// console.log('find otherSource', otherSource.length)
|
// console.log('find otherSource', otherSource.length)
|
||||||
if (otherSource.length) {
|
if (otherSource.length) {
|
||||||
return getOnlineOtherSourceLyricInfo({
|
return getOnlineOtherSourceLyricInfo({
|
||||||
|
@ -37,7 +37,7 @@ export const search = async(text: string, page: number, sourceId: Source): Promi
|
|||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
return await Promise.all(task).then((results: SearchResult[]) => {
|
return Promise.all(task).then((results: SearchResult[]) => {
|
||||||
if (key != listInfo.key) return []
|
if (key != listInfo.key) return []
|
||||||
setSearchText(text)
|
setSearchText(text)
|
||||||
setSource(sourceId)
|
setSource(sourceId)
|
||||||
|
@ -18,6 +18,7 @@ export const BG_IMAGES = {
|
|||||||
|
|
||||||
let userThemes: LX.Theme[]
|
let userThemes: LX.Theme[]
|
||||||
export const getAllThemes = async() => {
|
export const getAllThemes = async() => {
|
||||||
|
// eslint-disable-next-line require-atomic-updates
|
||||||
userThemes ??= await getUserTheme()
|
userThemes ??= await getUserTheme()
|
||||||
return {
|
return {
|
||||||
themes,
|
themes,
|
||||||
|
@ -69,6 +69,7 @@ export const saveUserTheme = async(themes: LX.Theme[]) => {
|
|||||||
|
|
||||||
|
|
||||||
const initPosition = async() => {
|
const initPosition = async() => {
|
||||||
|
// eslint-disable-next-line require-atomic-updates
|
||||||
listPosition ??= await getData(listScrollPositionKey) ?? {}
|
listPosition ??= await getData(listScrollPositionKey) ?? {}
|
||||||
}
|
}
|
||||||
export const getListPosition = async(id: string): Promise<number> => {
|
export const getListPosition = async(id: string): Promise<number> => {
|
||||||
@ -100,6 +101,7 @@ const saveListPrevSelectIdThrottle = throttle(() => {
|
|||||||
void saveData(listPrevSelectIdKey, listPrevSelectId)
|
void saveData(listPrevSelectIdKey, listPrevSelectId)
|
||||||
}, 200)
|
}, 200)
|
||||||
export const getListPrevSelectId = async() => {
|
export const getListPrevSelectId = async() => {
|
||||||
|
// eslint-disable-next-line require-atomic-updates
|
||||||
listPrevSelectId ??= await getData(listPrevSelectIdKey) ?? LIST_IDS.DEFAULT
|
listPrevSelectId ??= await getData(listPrevSelectIdKey) ?? LIST_IDS.DEFAULT
|
||||||
return listPrevSelectId || LIST_IDS.DEFAULT
|
return listPrevSelectId || LIST_IDS.DEFAULT
|
||||||
}
|
}
|
||||||
@ -113,6 +115,7 @@ const saveListUpdateInfoThrottle = throttle(() => {
|
|||||||
}, 1000)
|
}, 1000)
|
||||||
|
|
||||||
const initListUpdateInfo = async() => {
|
const initListUpdateInfo = async() => {
|
||||||
|
// eslint-disable-next-line require-atomic-updates
|
||||||
listUpdateInfo ??= await getData(listUpdateInfoKey) ?? {}
|
listUpdateInfo ??= await getData(listUpdateInfoKey) ?? {}
|
||||||
}
|
}
|
||||||
export const getListUpdateInfo = async() => {
|
export const getListUpdateInfo = async() => {
|
||||||
@ -169,6 +172,7 @@ export const saveIgnoreVersion = (version: string | null) => {
|
|||||||
}
|
}
|
||||||
// 获取忽略更新的版本号
|
// 获取忽略更新的版本号
|
||||||
export const getIgnoreVersion = async() => {
|
export const getIgnoreVersion = async() => {
|
||||||
|
// eslint-disable-next-line require-atomic-updates
|
||||||
if (ignoreVersion === undefined) ignoreVersion = (await getData<string | null>(ignoreVersionKey)) ?? null
|
if (ignoreVersion === undefined) ignoreVersion = (await getData<string | null>(ignoreVersionKey)) ?? null
|
||||||
return ignoreVersion
|
return ignoreVersion
|
||||||
}
|
}
|
||||||
@ -184,12 +188,14 @@ export const saveIgnoreVersionFailTipTime = (time: number | null) => {
|
|||||||
}
|
}
|
||||||
// 获取忽略更新的版本号
|
// 获取忽略更新的版本号
|
||||||
export const getIgnoreVersionFailTipTime = async() => {
|
export const getIgnoreVersionFailTipTime = async() => {
|
||||||
|
// eslint-disable-next-line require-atomic-updates
|
||||||
if (ignoreVersionFailTipTime === undefined) ignoreVersionFailTipTime = (await getData<number | null>(ignoreVersionFailTipTimeKey))
|
if (ignoreVersionFailTipTime === undefined) ignoreVersionFailTipTime = (await getData<number | null>(ignoreVersionFailTipTimeKey))
|
||||||
return ignoreVersionFailTipTime ?? 0
|
return ignoreVersionFailTipTime ?? 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const getSearchSetting = async() => {
|
export const getSearchSetting = async() => {
|
||||||
|
// eslint-disable-next-line require-atomic-updates
|
||||||
searchSetting ??= await getData(searchSettingKey) ?? { ...DEFAULT_SETTING.search }
|
searchSetting ??= await getData(searchSettingKey) ?? { ...DEFAULT_SETTING.search }
|
||||||
return { ...searchSetting }
|
return { ...searchSetting }
|
||||||
}
|
}
|
||||||
@ -206,16 +212,18 @@ export const saveSearchSetting = async(setting: Partial<typeof DEFAULT_SETTING['
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const getSearchHistory = async() => {
|
export const getSearchHistory = async() => {
|
||||||
|
// eslint-disable-next-line require-atomic-updates
|
||||||
searchHistoryList ??= await getData(searchHistoryListKey) ?? []
|
searchHistoryList ??= await getData(searchHistoryListKey) ?? []
|
||||||
return [...searchHistoryList]
|
return [...searchHistoryList]
|
||||||
}
|
}
|
||||||
export const saveSearchHistory = async(historyList: typeof searchHistoryList) => {
|
export const saveSearchHistory = async(historyList: typeof searchHistoryList) => {
|
||||||
if (!searchHistoryList) await getSearchHistory()
|
// if (!searchHistoryList) await getSearchHistory()
|
||||||
searchHistoryList = historyList
|
searchHistoryList = historyList
|
||||||
saveSearchHistoryThrottle()
|
saveSearchHistoryThrottle()
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getSongListSetting = async() => {
|
export const getSongListSetting = async() => {
|
||||||
|
// eslint-disable-next-line require-atomic-updates
|
||||||
songListSetting ??= await getData(songListSettingKey) ?? { ...DEFAULT_SETTING.songList }
|
songListSetting ??= await getData(songListSettingKey) ?? { ...DEFAULT_SETTING.songList }
|
||||||
return { ...songListSetting }
|
return { ...songListSetting }
|
||||||
}
|
}
|
||||||
@ -226,6 +234,7 @@ export const saveSongListSetting = async(setting: Partial<typeof DEFAULT_SETTING
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const getLeaderboardSetting = async() => {
|
export const getLeaderboardSetting = async() => {
|
||||||
|
// eslint-disable-next-line require-atomic-updates
|
||||||
leaderboardSetting ??= await getData(leaderboardSettingKey) ?? { ...DEFAULT_SETTING.leaderboard }
|
leaderboardSetting ??= await getData(leaderboardSettingKey) ?? { ...DEFAULT_SETTING.leaderboard }
|
||||||
return { ...leaderboardSetting }
|
return { ...leaderboardSetting }
|
||||||
}
|
}
|
||||||
@ -236,7 +245,7 @@ export const saveLeaderboardSetting = async(setting: Partial<typeof DEFAULT_SETT
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const getViewPrevState = async() => {
|
export const getViewPrevState = async() => {
|
||||||
return await getData<{ id: NAV_ID_Type }>(viewPrevStateKey) ?? { ...DEFAULT_SETTING.viewPrevState }
|
return (await getData<{ id: NAV_ID_Type }>(viewPrevStateKey)) ?? { ...DEFAULT_SETTING.viewPrevState }
|
||||||
}
|
}
|
||||||
export const saveViewPrevState = (state: { id: NAV_ID_Type }) => {
|
export const saveViewPrevState = (state: { id: NAV_ID_Type }) => {
|
||||||
saveViewPrevStateThrottle(state)
|
saveViewPrevStateThrottle(state)
|
||||||
@ -397,6 +406,7 @@ export const setSyncAuthKey = async(serverId: string, info: LX.Sync.KeyInfo) =>
|
|||||||
let syncHostInfo: string
|
let syncHostInfo: string
|
||||||
export const getSyncHost = async() => {
|
export const getSyncHost = async() => {
|
||||||
if (syncHostInfo === undefined) {
|
if (syncHostInfo === undefined) {
|
||||||
|
// eslint-disable-next-line require-atomic-updates
|
||||||
syncHostInfo = await getData(syncHostPrefix) ?? ''
|
syncHostInfo = await getData(syncHostPrefix) ?? ''
|
||||||
|
|
||||||
// 清空1.0.0之前版本的同步主机
|
// 清空1.0.0之前版本的同步主机
|
||||||
@ -414,6 +424,7 @@ export const setSyncHost = async(host: string) => {
|
|||||||
let syncHostHistory: string[]
|
let syncHostHistory: string[]
|
||||||
export const getSyncHostHistory = async() => {
|
export const getSyncHostHistory = async() => {
|
||||||
if (syncHostHistory === undefined) {
|
if (syncHostHistory === undefined) {
|
||||||
|
// eslint-disable-next-line require-atomic-updates
|
||||||
syncHostHistory = await getData(syncHostHistoryPrefix) ?? []
|
syncHostHistory = await getData(syncHostHistoryPrefix) ?? []
|
||||||
|
|
||||||
// 清空1.0.0之前版本的同步历史
|
// 清空1.0.0之前版本的同步历史
|
||||||
|
@ -76,7 +76,7 @@ export default {
|
|||||||
// })
|
// })
|
||||||
// requestObj.promise = requestObj.promise.then(({ body, statusCode }) => {
|
// requestObj.promise = requestObj.promise.then(({ body, statusCode }) => {
|
||||||
// if (statusCode !== 200) {
|
// if (statusCode !== 200) {
|
||||||
// if (tryNum > 5) return Promise.reject('歌词获取失败')
|
// if (tryNum > 5) return Promise.reject(new Error('歌词获取失败'))
|
||||||
// let tryRequestObj = this.getLyric(songInfo, ++tryNum)
|
// let tryRequestObj = this.getLyric(songInfo, ++tryNum)
|
||||||
// requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
// requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
||||||
// return tryRequestObj.promise
|
// return tryRequestObj.promise
|
||||||
@ -98,7 +98,7 @@ export default {
|
|||||||
})
|
})
|
||||||
requestObj.promise = requestObj.promise.then(({ body, statusCode }) => {
|
requestObj.promise = requestObj.promise.then(({ body, statusCode }) => {
|
||||||
if (statusCode !== 200) {
|
if (statusCode !== 200) {
|
||||||
if (tryNum > 5) return Promise.reject('歌词获取失败')
|
if (tryNum > 5) return Promise.reject(new Error('歌词获取失败'))
|
||||||
let tryRequestObj = this.searchLyric(name, hash, time, ++tryNum)
|
let tryRequestObj = this.searchLyric(name, hash, time, ++tryNum)
|
||||||
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
||||||
return tryRequestObj.promise
|
return tryRequestObj.promise
|
||||||
@ -121,7 +121,7 @@ export default {
|
|||||||
})
|
})
|
||||||
requestObj.promise = requestObj.promise.then(({ body, statusCode }) => {
|
requestObj.promise = requestObj.promise.then(({ body, statusCode }) => {
|
||||||
if (statusCode !== 200) {
|
if (statusCode !== 200) {
|
||||||
if (tryNum > 5) return Promise.reject('歌词获取失败')
|
if (tryNum > 5) return Promise.reject(new Error('歌词获取失败'))
|
||||||
let tryRequestObj = this.getLyric(id, accessKey, ++tryNum)
|
let tryRequestObj = this.getLyric(id, accessKey, ++tryNum)
|
||||||
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
||||||
return tryRequestObj.promise
|
return tryRequestObj.promise
|
||||||
|
@ -38,10 +38,10 @@ export default {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
return requestObj.promise.then(({ body }) => {
|
return requestObj.promise.then(({ body }) => {
|
||||||
if (body.error_code !== 0) return Promise.reject('图片获取失败')
|
if (body.error_code !== 0) return Promise.reject(new Error('图片获取失败'))
|
||||||
let info = body.data[0].info
|
let info = body.data[0].info
|
||||||
const img = info.imgsize ? info.image.replace('{size}', info.imgsize[0]) : info.image
|
const img = info.imgsize ? info.image.replace('{size}', info.imgsize[0]) : info.image
|
||||||
if (!img) return Promise.reject('Pic get failed')
|
if (!img) return Promise.reject(new Error('Pic get failed'))
|
||||||
return img
|
return img
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -57,7 +57,7 @@ const mrcTools = {
|
|||||||
})
|
})
|
||||||
return requestObj.promise.then(({ statusCode, body }) => {
|
return requestObj.promise.then(({ statusCode, body }) => {
|
||||||
if (statusCode == 200) return body
|
if (statusCode == 200) return body
|
||||||
if (tryNum > 5 || statusCode == 404) return Promise.reject('歌词获取失败')
|
if (tryNum > 5 || statusCode == 404) return Promise.reject(new Error('歌词获取失败'))
|
||||||
return this.getText(url, ++tryNum)
|
return this.getText(url, ++tryNum)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -84,7 +84,7 @@ const mrcTools = {
|
|||||||
let p
|
let p
|
||||||
if (info.mrcUrl) p = this.getMrc(info.mrcUrl)
|
if (info.mrcUrl) p = this.getMrc(info.mrcUrl)
|
||||||
else if (info.lrcUrl) p = this.getLrc(info.lrcUrl)
|
else if (info.lrcUrl) p = this.getLrc(info.lrcUrl)
|
||||||
if (p == null) return Promise.reject('获取歌词失败')
|
if (p == null) return Promise.reject(new Error('获取歌词失败'))
|
||||||
return Promise.all([p, this.getTrc(info.trcUrl)]).then(([lrcInfo, tlyric]) => {
|
return Promise.all([p, this.getTrc(info.trcUrl)]).then(([lrcInfo, tlyric]) => {
|
||||||
lrcInfo.tlyric = tlyric
|
lrcInfo.tlyric = tlyric
|
||||||
return lrcInfo
|
return lrcInfo
|
||||||
@ -102,7 +102,7 @@ export default {
|
|||||||
let requestObj = httpFetch(songInfo.lrcUrl)
|
let requestObj = httpFetch(songInfo.lrcUrl)
|
||||||
requestObj.promise = requestObj.promise.then(({ body, statusCode }) => {
|
requestObj.promise = requestObj.promise.then(({ body, statusCode }) => {
|
||||||
if (statusCode !== 200) {
|
if (statusCode !== 200) {
|
||||||
if (tryNum > 5) return Promise.reject('歌词获取失败')
|
if (tryNum > 5) return Promise.reject(new Error('歌词获取失败'))
|
||||||
let tryRequestObj = this.getLyricWeb(songInfo, ++tryNum)
|
let tryRequestObj = this.getLyricWeb(songInfo, ++tryNum)
|
||||||
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
||||||
return tryRequestObj.promise
|
return tryRequestObj.promise
|
||||||
|
@ -10,7 +10,7 @@ export default {
|
|||||||
})
|
})
|
||||||
requestObj.promise.then(({ body }) => {
|
requestObj.promise.then(({ body }) => {
|
||||||
if (body.returnCode !== '000000') {
|
if (body.returnCode !== '000000') {
|
||||||
if (tryNum > 5) return Promise.reject('图片获取失败')
|
if (tryNum > 5) return Promise.reject(new Error('图片获取失败'))
|
||||||
let tryRequestObj = this.getPic(songId, ++tryNum)
|
let tryRequestObj = this.getPic(songId, ++tryNum)
|
||||||
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
||||||
return tryRequestObj.promise
|
return tryRequestObj.promise
|
||||||
|
@ -170,7 +170,7 @@ export default {
|
|||||||
// return this._requestObj_list.promise.then(({ statusCode, body }) => {
|
// return this._requestObj_list.promise.then(({ statusCode, body }) => {
|
||||||
// if (statusCode !== 200) return this.getList(sortId, tagId, page)
|
// if (statusCode !== 200) return this.getList(sortId, tagId, page)
|
||||||
// let list = body.replace(/[\r\n]/g, '').match(this.regExps.list)
|
// let list = body.replace(/[\r\n]/g, '').match(this.regExps.list)
|
||||||
// if (!list) return Promise.reject('获取列表失败')
|
// if (!list) return Promise.reject(new Error('获取列表失败'))
|
||||||
// return list.map(item => {
|
// return list.map(item => {
|
||||||
// let info = item.match(this.regExps.listInfo)
|
// let info = item.match(this.regExps.listInfo)
|
||||||
// return {
|
// return {
|
||||||
|
@ -33,7 +33,7 @@ export default (songmid) => {
|
|||||||
})
|
})
|
||||||
return requestObj.promise.then(({ body }) => {
|
return requestObj.promise.then(({ body }) => {
|
||||||
// console.log(body)
|
// console.log(body)
|
||||||
if (body.code != 0 || body.req.code != 0) return Promise.reject('获取歌曲信息失败')
|
if (body.code != 0 || body.req.code != 0) return Promise.reject(new Error('获取歌曲信息失败'))
|
||||||
const item = body.req.data.track_info
|
const item = body.req.data.track_info
|
||||||
if (!item.file?.media_mid) return null
|
if (!item.file?.media_mid) return null
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ export default songmid => {
|
|||||||
})
|
})
|
||||||
requestObj.promise = requestObj.promise.then(({ body }) => {
|
requestObj.promise = requestObj.promise.then(({ body }) => {
|
||||||
// console.log(body)
|
// console.log(body)
|
||||||
if (body.code !== 200 || !body.songs.length) return Promise.reject('获取歌曲信息失败')
|
if (body.code !== 200 || !body.songs.length) return Promise.reject(new Error('获取歌曲信息失败'))
|
||||||
return body.songs[0]
|
return body.songs[0]
|
||||||
})
|
})
|
||||||
return requestObj
|
return requestObj
|
||||||
|
@ -19,7 +19,7 @@ export const getDeviceLanguage = async() => {
|
|||||||
// NativeModules.SettingsManager.settings.AppleLanguages[0] // iOS 13
|
// NativeModules.SettingsManager.settings.AppleLanguages[0] // iOS 13
|
||||||
// : await getSystemLocales()
|
// : await getSystemLocales()
|
||||||
// deviceLanguage = typeof deviceLanguage === 'string' ? deviceLanguage.substring(0, 5).toLocaleLowerCase() : ''
|
// deviceLanguage = typeof deviceLanguage === 'string' ? deviceLanguage.substring(0, 5).toLocaleLowerCase() : ''
|
||||||
return await getSystemLocales()
|
return getSystemLocales()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ const address = [
|
|||||||
|
|
||||||
|
|
||||||
const request = async(url, retryNum = 0) => {
|
const request = async(url, retryNum = 0) => {
|
||||||
return await new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
httpGet(url, {
|
httpGet(url, {
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
}, (err, resp, body) => {
|
}, (err, resp, body) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user