更新依赖&版本号(1.2.0-beta.9)

This commit is contained in:
lyswhut 2023-12-10 19:20:30 +08:00
parent f7793cf750
commit 6a830ff056
53 changed files with 123 additions and 94 deletions

32
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "lx-music-mobile",
"version": "1.2.0-beta.8",
"version": "1.2.0-beta.9",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "lx-music-mobile",
"version": "1.2.0-beta.8",
"version": "1.2.0-beta.9",
"hasInstallScript": true,
"license": "Apache-2.0",
"dependencies": {
@ -40,14 +40,14 @@
"@react-native/metro-config": "^0.73.2",
"@react-native/typescript-config": "^0.74.0",
"@tsconfig/react-native": "^3.0.2",
"@types/react": "^18.2.42",
"@types/react": "^18.2.43",
"@types/react-native": "^0.70.19",
"@types/react-native-background-timer": "^2.0.2",
"@types/react-native-vector-icons": "^6.4.18",
"babel-plugin-module-resolver": "^5.0.0",
"changelog-parser": "^3.0.1",
"eslint-config-standard": "^17.1.0",
"eslint-config-standard-with-typescript": "^40.0.0",
"eslint-config-standard-with-typescript": "^42.0.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"typescript": "^5.3.3"
@ -3334,9 +3334,9 @@
"license": "MIT"
},
"node_modules/@types/react": {
"version": "18.2.42",
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.42.tgz",
"integrity": "sha512-c1zEr96MjakLYus/wPnuWDo1/zErfdU9rNsIGmE+NV71nx88FG9Ttgo5dqorXTu/LImX2f63WBP986gJkMPNbA==",
"version": "18.2.43",
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.43.tgz",
"integrity": "sha512-nvOV01ZdBdd/KW6FahSbcNplt2jCJfyWdTos61RYHV+FVv5L/g9AOX1bmbVcWcLFL8+KHQfh1zVIQrud6ihyQA==",
"dev": true,
"dependencies": {
"@types/prop-types": "*",
@ -5234,9 +5234,9 @@
}
},
"node_modules/eslint-config-standard-with-typescript": {
"version": "40.0.0",
"resolved": "https://registry.npmjs.org/eslint-config-standard-with-typescript/-/eslint-config-standard-with-typescript-40.0.0.tgz",
"integrity": "sha512-GXUJcwIXiTQaS3H4etv8a1lejVVdZYaxZNz3g7vt6GoJosQqMTurbmSC4FVGyHiGT/d1TjFr3+47A3xsHhsG+Q==",
"version": "42.0.0",
"resolved": "https://registry.npmjs.org/eslint-config-standard-with-typescript/-/eslint-config-standard-with-typescript-42.0.0.tgz",
"integrity": "sha512-m1/2g/Sicun1uFZOFigJVeOqo9fE7OkMsNtilcpHwdCdcGr21qsGqYiyxYSvvHfJwY7w5OTQH0hxk8sM2N5Ohg==",
"dev": true,
"dependencies": {
"@typescript-eslint/parser": "^6.4.0",
@ -13007,9 +13007,9 @@
"dev": true
},
"@types/react": {
"version": "18.2.42",
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.42.tgz",
"integrity": "sha512-c1zEr96MjakLYus/wPnuWDo1/zErfdU9rNsIGmE+NV71nx88FG9Ttgo5dqorXTu/LImX2f63WBP986gJkMPNbA==",
"version": "18.2.43",
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.43.tgz",
"integrity": "sha512-nvOV01ZdBdd/KW6FahSbcNplt2jCJfyWdTos61RYHV+FVv5L/g9AOX1bmbVcWcLFL8+KHQfh1zVIQrud6ihyQA==",
"dev": true,
"requires": {
"@types/prop-types": "*",
@ -14446,9 +14446,9 @@
"requires": {}
},
"eslint-config-standard-with-typescript": {
"version": "40.0.0",
"resolved": "https://registry.npmjs.org/eslint-config-standard-with-typescript/-/eslint-config-standard-with-typescript-40.0.0.tgz",
"integrity": "sha512-GXUJcwIXiTQaS3H4etv8a1lejVVdZYaxZNz3g7vt6GoJosQqMTurbmSC4FVGyHiGT/d1TjFr3+47A3xsHhsG+Q==",
"version": "42.0.0",
"resolved": "https://registry.npmjs.org/eslint-config-standard-with-typescript/-/eslint-config-standard-with-typescript-42.0.0.tgz",
"integrity": "sha512-m1/2g/Sicun1uFZOFigJVeOqo9fE7OkMsNtilcpHwdCdcGr21qsGqYiyxYSvvHfJwY7w5OTQH0hxk8sM2N5Ohg==",
"dev": true,
"requires": {
"@typescript-eslint/parser": "^6.4.0",

View File

@ -1,6 +1,6 @@
{
"name": "lx-music-mobile",
"version": "1.2.0-beta.8",
"version": "1.2.0-beta.9",
"versionCode": 62,
"private": true,
"scripts": {
@ -74,14 +74,14 @@
"@react-native/metro-config": "^0.73.2",
"@react-native/typescript-config": "^0.74.0",
"@tsconfig/react-native": "^3.0.2",
"@types/react": "^18.2.42",
"@types/react": "^18.2.43",
"@types/react-native": "^0.70.19",
"@types/react-native-background-timer": "^2.0.2",
"@types/react-native-vector-icons": "^6.4.18",
"babel-plugin-module-resolver": "^5.0.0",
"changelog-parser": "^3.0.1",
"eslint-config-standard": "^17.1.0",
"eslint-config-standard-with-typescript": "^40.0.0",
"eslint-config-standard-with-typescript": "^42.0.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"typescript": "^5.3.3"

View File

@ -52,7 +52,7 @@ export default forwardRef<MusicAddModalType, MusicAddModalProps>(({ onAdded }, r
dialogRef.current?.setVisible(false)
if (selectInfo.isMove) {
void moveListMusics(selectInfo.listId, listInfo.id,
[selectInfo.musicInfo as LX.Music.MusicInfo],
[selectInfo.musicInfo!],
settingState.setting['list.addMusicLocationType'],
).then(() => {
onAdded?.()
@ -62,7 +62,7 @@ export default forwardRef<MusicAddModalType, MusicAddModalProps>(({ onAdded }, r
})
} else {
void addListMusics(listInfo.id,
[selectInfo.musicInfo as LX.Music.MusicInfo],
[selectInfo.musicInfo!],
settingState.setting['list.addMusicLocationType'],
).then(() => {
onAdded?.()

View File

@ -17,7 +17,7 @@ const caches = new Map<string, PathItem[]>()
const handleReadDir = async(path: string, dirOnly: boolean, filter?: RegExp, isRefresh = false) => {
const cacheKey = `${path}_${dirOnly ? 'true' : 'false'}_${filter ? filter.toString() : 'null'}`
if (!isRefresh && caches.has(cacheKey)) return caches.get(cacheKey) as PathItem[]
if (!isRefresh && caches.has(cacheKey)) return caches.get(cacheKey)!
return readDir(path).then(paths => {
// console.log('read')
// prevPath = path

View File

@ -44,7 +44,7 @@ export default ({ isHome }: { isHome: boolean }) => {
// console.log('')
// console.log(playMusicInfo)
if (!musicInfo.id) return
navigations.pushPlayDetailScreen(commonState.componentIds.home as string)
navigations.pushPlayDetailScreen(commonState.componentIds.home!)
// toast(global.i18n.t('play_detail_todo_tip'), 'long')
}

View File

@ -21,7 +21,7 @@ export default ({ isHome }: { isHome: boolean }) => {
// console.log('')
// console.log(playMusicInfo)
if (!musicInfo.id) return
navigations.pushPlayDetailScreen(commonState.componentIds.home as string)
navigations.pushPlayDetailScreen(commonState.componentIds.home!)
// toast(global.i18n.t('play_detail_todo_tip'), 'long')
}

View File

@ -151,7 +151,7 @@ const timeStr2Intv = (timeStr: string) => {
let intv = 0
let unit = 1
while (intvArr.length) {
intv += parseInt(intvArr.pop() as string) * unit
intv += parseInt(intvArr.pop()!) * unit
unit *= 60
}
return intv
@ -160,7 +160,7 @@ const migratePlayInfo = async() => {
const playInfo = await getData<any>(storageDataPrefixOld.playInfo)
if (playInfo == null) return
if (playInfo.list !== undefined) delete playInfo.list
if (playInfo.maxTime) playInfo.maxTime = timeStr2Intv(playInfo.maxTime)
if (playInfo.maxTime) playInfo.maxTime = timeStr2Intv(playInfo.maxTime as string)
await saveData(storageDataPrefix.playInfo, playInfo)
}
/**

View File

@ -4,7 +4,7 @@ export default (setting: any): Partial<LX.AppSetting> => {
setting = { ...setting }
// 迁移 v1 之前的配置
if (compareVer(setting.version, '2.0') < 0) {
if (compareVer(setting.version as string, '2.0') < 0) {
setting['player.startupAutoPlay'] = setting.startupAutoPlay
setting['player.togglePlayMethod'] = setting.player?.togglePlayMethod
setting['player.isPlayHighQuality'] = setting.player?.highQuality

View File

@ -9,7 +9,7 @@ export const getList = async(source: Source): Promise<string[]> => {
if (source == 'all') continue
task.push(
hotSearchState.sourceList[source]?.length
? Promise.resolve({ source, list: hotSearchState.sourceList[source] as Lists[number]['list'] })
? Promise.resolve({ source, list: hotSearchState.sourceList[source]! })
: ((musicSdk[source]?.hotSearch.getList() as Promise<Lists[number]>) ?? Promise.reject(new Error('source not found: ' + source))).catch((err: any) => {
console.log(err)
return { source, list: [] }
@ -20,7 +20,7 @@ export const getList = async(source: Source): Promise<string[]> => {
return hotSearchActions.setList(source, results)
})
} else {
if (hotSearchState.sourceList[source]?.length) return hotSearchState.sourceList[source] as string[]
if (hotSearchState.sourceList[source]?.length) return hotSearchState.sourceList[source]!
if (!musicSdk[source]?.hotSearch) {
hotSearchActions.setList(source, [])
return []
@ -28,6 +28,7 @@ export const getList = async(source: Source): Promise<string[]> => {
return musicSdk[source]?.hotSearch.getList().catch((err: any) => {
console.log(err)
return { source, list: [] }
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
}).then(data => hotSearchActions.setList(source, data.list))
}
}

View File

@ -14,7 +14,7 @@ const delaySavePlayInfo = throttleBackgroundTimer(() => {
void savePlayInfo({
time: playerState.progress.nowPlayTime,
maxTime: playerState.progress.maxPlayTime,
listId: playerState.playMusicInfo.listId as string,
listId: playerState.playMusicInfo.listId!,
index: playerState.playInfo.playIndex,
})
}, 2000)
@ -121,7 +121,7 @@ export default () => {
void savePlayInfo({
time: playerState.progress.nowPlayTime,
maxTime: playerState.progress.maxPlayTime,
listId: playerState.playMusicInfo.listId as string,
listId: playerState.playMusicInfo.listId!,
index: playerState.playInfo.playIndex,
})
}

View File

@ -10,9 +10,11 @@ const handleUpdateSourceNmaes = () => {
kg: 'kg',
mg: 'mg',
wy: 'wy',
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
all: global.i18n.t(prefix + 'all' as any),
}
for (const { id } of musicSdk.sources) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
sourceNames[id as LX.OnlineSource] = global.i18n.t(prefix + id as any)
}
commonActions.setSourceNames(sourceNames)

View File

@ -71,7 +71,7 @@ export default async(setting: LX.AppSetting) => {
// eslint-disable-next-line @typescript-eslint/promise-function-async
}).then(res => {
// console.log(res)
if (!/^https?:/.test(res.data.url)) return Promise.reject(new Error('Get url failed'))
if (!/^https?:/.test(res.data.url as string)) return Promise.reject(new Error('Get url failed'))
return { type, url: res.data.url }
}).catch(async err => {
console.log(err.message)

View File

@ -52,8 +52,8 @@ const getListLimit = async(source: LX.OnlineSource, bangId: string, page: number
const prevPageKey = `${source}__${bangId}__${page - 1}`
const tempListKey = `${source}__${bangId}__temp`
let listCache = cache.get(listKey) as CacheValue
if (!listCache) cache.set(listKey, listCache = new Map())
let listCache = cache.get(listKey)!
if (!listCache) cache.set(listKey, listCache = new Map<string, PageCache | LX.Music.MusicInfoOnline[]>())
let sourcePage = 0
{
const prevPageData = listCache.get(prevPageKey) as PageCache
@ -113,7 +113,7 @@ export const getListDetail = async(id: string, page: number, isRefresh = false):
let listCache = cache.get(listKey)
if (!listCache || isRefresh) {
cache.set(listKey, listCache = new Map())
cache.set(listKey, listCache = new Map<string, PageCache | LX.Music.MusicInfoOnline[]>())
}
let pageCache = listCache.get(pageKey) as PageCache
@ -132,9 +132,9 @@ export const getListDetailAll = async(id: string, isRefresh = false): Promise<LX
const [source, bangId] = id.split('__') as [LX.OnlineSource, string]
// console.log(tabId)
const listKey = `${source}__${bangId}`
let listCache = cache.get(listKey) as CacheValue
let listCache = cache.get(listKey)!
if (!listCache || isRefresh) {
cache.set(listKey, listCache = new Map())
cache.set(listKey, listCache = new Map<string, PageCache | LX.Music.MusicInfoOnline[]>())
}
const loadData = async(page: number): Promise<ListDetailInfo> => {

View File

@ -167,7 +167,7 @@ export const getOnlineOtherSourceMusicUrl = async({ musicInfos, quality, onToggl
let musicInfo: LX.Music.MusicInfoOnline | null = null
let itemQuality: LX.Quality | null = null
// eslint-disable-next-line no-cond-assign
while (musicInfo = (musicInfos.shift() as LX.Music.MusicInfoOnline)) {
while (musicInfo = (musicInfos.shift()!)) {
if (retryedSource.includes(musicInfo.source)) continue
retryedSource.push(musicInfo.source)
if (!assertApiSupport(musicInfo.source)) continue
@ -261,7 +261,7 @@ export const getOnlineOtherSourcePicUrl = async({ musicInfos, onToggleSource, is
}> => {
let musicInfo: LX.Music.MusicInfoOnline | null = null
// eslint-disable-next-line no-cond-assign
while (musicInfo = (musicInfos.shift() as LX.Music.MusicInfoOnline)) {
while (musicInfo = (musicInfos.shift()!)) {
if (retryedSource.includes(musicInfo.source)) continue
retryedSource.push(musicInfo.source)
// if (!assertApiSupport(musicInfo.source)) continue
@ -344,7 +344,7 @@ export const getOnlineOtherSourceLyricInfo = async({ musicInfos, onToggleSource,
}> => {
let musicInfo: LX.Music.MusicInfoOnline | null = null
// eslint-disable-next-line no-cond-assign
while (musicInfo = (musicInfos.shift() as LX.Music.MusicInfoOnline)) {
while (musicInfo = (musicInfos.shift()!)) {
if (retryedSource.includes(musicInfo.source)) continue
retryedSource.push(musicInfo.source)
// if (!assertApiSupport(musicInfo.source)) continue

View File

@ -128,7 +128,7 @@ export const setMusicUrl = (musicInfo: LX.Music.MusicInfo | LX.Download.ListItem
setResource(musicInfo, url, playerState.progress.nowPlayTime)
}).catch((err: any) => {
console.log(err)
setStatusText(err.message)
setStatusText(err.message as string)
global.app_event.error()
addDelayNextTimeout()
}).finally(() => {

View File

@ -32,7 +32,7 @@ const timeoutTools = {
clearTimeout() {
if (!this.bgTimeout) return
BackgroundTimer.clearTimeout(this.bgTimeout)
clearInterval(this.timeout as NodeJS.Timer)
clearInterval(this.timeout!)
this.bgTimeout = null
this.timeout = null
this.time = -1

View File

@ -1,4 +1,4 @@
import searchMusicState, { type ListInfo, type Source } from '@/store/search/music/state'
import searchMusicState, { type Source } from '@/store/search/music/state'
import searchMusicActions, { type SearchResult } from '@/store/search/music/action'
import musicSdk from '@/utils/musicSdk'
@ -18,7 +18,7 @@ export const clearListInfo: typeof searchMusicActions.clearListInfo = (source) =
export const search = async(text: string, page: number, sourceId: Source): Promise<LX.Music.MusicInfoOnline[]> => {
const listInfo = searchMusicState.listInfos[sourceId] as ListInfo
const listInfo = searchMusicState.listInfos[sourceId]!
if (!text) return []
const key = `${page}__${text}`
if (sourceId == 'all') {

View File

@ -1,4 +1,4 @@
import searchSonglistState, { type SearchListInfo, type Source, type ListInfoItem } from '@/store/search/songlist/state'
import searchSonglistState, { type Source, type ListInfoItem } from '@/store/search/songlist/state'
import searchSonglistActions, { type SearchResult } from '@/store/search/songlist/action'
import musicSdk from '@/utils/musicSdk'
@ -18,7 +18,7 @@ export const clearListInfo: typeof searchSonglistActions.clearListInfo = (source
export const search = async(text: string, page: number, sourceId: Source): Promise<ListInfoItem[]> => {
const listInfo = searchSonglistState.listInfos[sourceId] as SearchListInfo
const listInfo = searchSonglistState.listInfos[sourceId]!
// if (!text) return []
const key = `${page}__${sourceId}__${text}`
if (listInfo.key == key && listInfo.list.length) return listInfo.list
@ -26,7 +26,7 @@ export const search = async(text: string, page: number, sourceId: Source): Promi
listInfo.key = key
let task = []
for (const source of searchSonglistState.sources) {
if (source == 'all' || (page > 1 && page > (searchSonglistState.maxPages[source] as number))) continue
if (source == 'all' || (page > 1 && page > (searchSonglistState.maxPages[source]!))) continue
task.push(((musicSdk[source]?.songList.search(text, page, searchSonglistState.listInfos.all.limit) as Promise<SearchResult>) ?? Promise.reject(new Error('source not found: ' + source))).catch((error: any) => {
console.log(error)
return {

View File

@ -1,4 +1,4 @@
import songlistState, { type TagInfo, type ListDetailInfo, type ListInfo, type SortInfo, type ListInfoItem } from '@/store/songlist/state'
import songlistState, { type TagInfo, type ListDetailInfo, type ListInfo, type ListInfoItem } from '@/store/songlist/state'
import songlistActions from '@/store/songlist/action'
import { deduplicationList, toNewMusicInfo } from '@/utils'
import musicSdk from '@/utils/musicSdk'
@ -28,7 +28,7 @@ export const setSelectListInfo = (info: ListInfoItem) => {
* @returns
*/
export const getSortList = (source: LX.OnlineSource) => {
return songlistState.sortList[source] as SortInfo[]
return songlistState.sortList[source]!
}
/**

View File

@ -44,24 +44,31 @@ export const setUserApiAllowShowUpdateAlert = async(id: string, enable: boolean)
export const log = {
r_info(...params: any[]) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
writeLog.info(...params)
},
r_warn(...params: any[]) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
writeLog.warn(...params)
},
r_error(...params: any[]) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
writeLog.error(...params)
},
log(...params: any[]) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
if (global.lx.isEnableUserApiLog) writeLog.info(...params)
},
info(...params: any[]) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
if (global.lx.isEnableUserApiLog) writeLog.info(...params)
},
warn(...params: any[]) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
if (global.lx.isEnableUserApiLog) writeLog.warn(...params)
},
error(...params: any[]) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
if (global.lx.isEnableUserApiLog) writeLog.error(...params)
},
}

View File

@ -26,6 +26,7 @@ export default class Event {
let targetListeners = this.listeners.get(eventName)
if (!targetListeners) return
for (const listener of targetListeners) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
listener(...args)
}
})

View File

@ -14,7 +14,7 @@ export const usePlaybackState = () => {
void setPlayerState()
const sub = TrackPlayer.addEventListener(Event.PlaybackState, data => {
setState(data.state)
setState(data.state as State)
})
return () => { sub.remove() }
@ -99,6 +99,7 @@ export function useProgress(updateInterval: number) {
}
useEffect(() => {
// @ts-expect-error
if (!pollTrackPlayerStates.includes(playerState)) return
void getProgress()

View File

@ -137,7 +137,7 @@ const handlePlayMusic = async(musicInfo: LX.Player.PlayMusic, url: string, time:
await TrackPlayer.skip(queue.findIndex(t => t.id == track.id))
if (currentTrackIndex == null) {
if (!isTempTrack(track.id)) {
if (!isTempTrack(track.id as string)) {
if (time) await TrackPlayer.seekTo(time)
if (global.lx.restorePlayInfo) {
await TrackPlayer.pause()
@ -152,7 +152,7 @@ const handlePlayMusic = async(musicInfo: LX.Player.PlayMusic, url: string, time:
}
} else {
await TrackPlayer.pause()
if (!isTempTrack(track.id)) {
if (!isTempTrack(track.id as string)) {
await TrackPlayer.seekTo(time)
await TrackPlayer.play()
}

View File

@ -73,7 +73,7 @@ const registerPlaybackService = async() => {
})
TrackPlayer.addEventListener(TPEvent.RemoteSeek, async({ position }) => {
global.app_event.setProgress(position)
global.app_event.setProgress(position as number)
})
TrackPlayer.addEventListener(TPEvent.PlaybackState, async info => {

View File

@ -133,7 +133,7 @@ const playMusic = ((fn: (musicInfo: LX.Player.PlayMusic, url: string, time: numb
_url = ''
_time = 0
isDelayRun = false
fn(musicInfo as LX.Player.PlayMusic, url, time)
fn(musicInfo!, url, time)
}, delay)
} else {
isDelayRun = true

View File

@ -117,6 +117,7 @@ export const getDataMultiple = async<T extends readonly string[]>(keys: T) => {
if (value && partKeyPrefixRxp.test(value)) {
promises.push(handleGetData(value))
} else {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
promises.push(Promise.resolve(value ? JSON.parse(value) : value))
}
}

View File

@ -59,7 +59,7 @@ const disconnectServer = async(isResetStatus = true) => handleDisconnect().then(
}
}).catch((err: any) => {
log.error(`disconnect error: ${err.message as string}`)
sendSyncMessage(err.message)
sendSyncMessage(err.message as string)
})
export {

View File

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import { log as writeLog } from '@/utils/log'
export default {

View File

@ -20,7 +20,7 @@ export default memo(({ musicInfo }: {
const t = useI18n()
const back = () => {
void pop(commonState.componentIds.comment as string)
void pop(commonState.componentIds.comment!)
}
return (

View File

@ -35,7 +35,7 @@ const readListData = async(path: string) => {
listData = configData.data
break
default:
showImportTip(configData.type)
showImportTip(configData.type as string)
return null
}
return listData

View File

@ -1,7 +1,7 @@
import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react'
import OnlineList, { type OnlineListType, type OnlineListProps } from '@/components/OnlineList'
import { search } from '@/core/search/music'
import searchMusicState, { type ListInfo, type Source } from '@/store/search/music/state'
import searchMusicState, { type Source } from '@/store/search/music/state'
// export type MusicListProps = Pick<OnlineListProps,
// 'onLoadMore'
@ -66,7 +66,7 @@ export default forwardRef<MusicListType, {}>((props, ref) => {
}
const handleLoadMore: OnlineListProps['onLoadMore'] = () => {
listRef.current?.setStatus('loading')
const info = searchMusicState.listInfos[searchInfoRef.current.source] as ListInfo
const info = searchMusicState.listInfos[searchInfoRef.current.source]!
const page = info?.list.length ? info.page + 1 : 1
search(searchInfoRef.current.text, page, searchInfoRef.current.source).then((list) => {
// const result = setListInfo(listDetail, searchMusicState.listDetailInfo.id, page)

View File

@ -2,7 +2,7 @@ import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react'
import { search } from '@/core/search/songlist'
import Songlist, { type SonglistProps, type SonglistType } from '@/screens/Home/Views/SongList/components/Songlist'
import searchSonglistState, { type SearchListInfo, type Source } from '@/store/search/songlist/state'
import searchSonglistState, { type Source } from '@/store/search/songlist/state'
// export type MusicListProps = Pick<OnlineListProps,
// 'onLoadMore'
@ -67,7 +67,7 @@ export default forwardRef<MusicListType, {}>((props, ref) => {
}
const handleLoadMore: SonglistProps['onLoadMore'] = () => {
listRef.current?.setStatus('loading')
const info = searchSonglistState.listInfos[searchInfoRef.current.source] as SearchListInfo
const info = searchSonglistState.listInfos[searchInfoRef.current.source]!
const page = info.list.length ? info.page + 1 : 1
search(searchInfoRef.current.text, page, searchInfoRef.current.source).then((list) => {
// const result = setListInfo(listDetail, searchSonglistState.listDetailInfo.id, page)

View File

@ -122,27 +122,34 @@ const importPlayList = async(path: string) => {
await overwriteListMusics(LIST_IDS.DEFAULT, filterMusicList((configData.data as LX.List.MyDefaultListInfoFull).list.map(m => toNewMusicInfo(m))))
break
case 'playList':
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
await importOldListData(configData.data)
break
case 'playList_v2':
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
await importNewListData(configData.data)
break
case 'allData':
// 兼容0.6.2及以前版本的列表数据
if (configData.defaultList) await overwriteListMusics(LIST_IDS.DEFAULT, filterMusicList((configData.defaultList as LX.List.MyDefaultListInfoFull).list.map(m => toNewMusicInfo(m))))
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
else await importOldListData(configData.playList)
break
case 'allData_v2':
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
await importNewListData(configData.playList)
break
case 'playListPart':
configData.data.list = filterMusicList((configData.data as LX.ConfigFile.MyListInfoPart['data']).list.map(m => toNewMusicInfo(m)))
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
void handleImportListPart(configData.data)
return true
case 'playListPart_v2':
configData.data.list = filterMusicList((configData.data as LX.ConfigFile.MyListInfoPart['data']).list).map(m => fixNewMusicInfoQuality(m))
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
void handleImportListPart(configData.data)
return true
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
default: showImportTip(configData.type)
}
}

View File

@ -41,7 +41,7 @@ export default forwardRef<OpenListType, {}>((props, ref) => {
desc: undefined,
source: songlistInfoRef.current.source,
})
navigations.pushSonglistDetailScreen(commonState.componentIds.home as string, id)
navigations.pushSonglistDetailScreen(commonState.componentIds.home!, id)
}
// const handleSourceChange: ModalProps['onSourceChange'] = (source) => {

View File

@ -26,7 +26,7 @@ export default forwardRef<SortTabType, SortTabProps>(({ onSortChange }, ref) =>
useImperativeHandle(ref, () => ({
setSource(source, activeTab) {
scrollViewRef.current?.scrollTo({ x: 0 })
setSortList(songlistState.sortList[source] as SortInfo[])
setSortList(songlistState.sortList[source]!)
setActiveId(activeTab)
},
}))

View File

@ -34,7 +34,7 @@ export default forwardRef<SonglistType, SonglistProps>(({
const handleOpenDetail = (item: ListInfoItem, index: number) => {
// console.log(item)
setSelectListInfo(item)
navigations.pushSonglistDetailScreen(commonState.componentIds.home as string, item.id)
navigations.pushSonglistDetailScreen(commonState.componentIds.home!, item.id)
}
return (

View File

@ -13,7 +13,7 @@ export default () => {
musicAddModalRef.current?.show({
musicInfo: 'progress' in musicInfo ? musicInfo.metadata.musicInfo : musicInfo,
isMove: false,
listId: playerState.playMusicInfo.listId as string,
listId: playerState.playMusicInfo.listId!,
})
}

View File

@ -5,7 +5,7 @@ import commonState from '@/store/common/state'
export default () => {
const handleShowCommentScreen = () => {
navigations.pushCommentScreen(commonState.componentIds.playDetail as string)
navigations.pushCommentScreen(commonState.componentIds.playDetail!)
}
return <Btn icon="comment" onPress={handleShowCommentScreen} />

View File

@ -33,7 +33,7 @@ export default memo(() => {
const popupRef = useRef<SettingPopupType>(null)
const back = () => {
void pop(commonState.componentIds.playDetail as string)
void pop(commonState.componentIds.playDetail!)
}
const showSetting = () => {
popupRef.current?.show()

View File

@ -5,7 +5,7 @@ import commonState from '@/store/common/state'
export default () => {
const handleShowCommentScreen = () => {
navigations.pushCommentScreen(commonState.componentIds.playDetail as string)
navigations.pushCommentScreen(commonState.componentIds.playDetail!)
}
return <Btn icon="comment" onPress={handleShowCommentScreen} />

View File

@ -13,7 +13,7 @@ export default () => {
musicAddModalRef.current?.show({
musicInfo: 'progress' in musicInfo ? musicInfo.metadata.musicInfo : musicInfo,
isMove: false,
listId: playerState.playMusicInfo.listId as string,
listId: playerState.playMusicInfo.listId!,
})
}

View File

@ -33,7 +33,7 @@ export default memo(() => {
const popupRef = useRef<SettingPopupType>(null)
const back = () => {
void pop(commonState.componentIds.playDetail as string)
void pop(commonState.componentIds.playDetail!)
}
const showSetting = () => {
popupRef.current?.show()

View File

@ -17,7 +17,7 @@ export default memo(() => {
const t = useI18n()
const back = () => {
void pop(commonState.componentIds.songlistDetail as string)
void pop(commonState.componentIds.songlistDetail!)
}
const handlePlayAll = () => {

View File

@ -1,4 +1,4 @@
import state, { type InitState, type ListInfo, type Source } from './state'
import state, { type InitState, type Source } from './state'
import { sortInsert, similar, arrPush } from '@/utils/common'
import { deduplicationList, toNewMusicInfo } from '@/utils'
@ -21,6 +21,7 @@ export interface SearchResult {
const handleSortList = (list: LX.Music.MusicInfoOnline[], keyword: string) => {
let arr: any[] = []
for (const item of list) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
sortInsert(arr, {
num: similar(keyword, `${item.name} ${item.singer}`),
data: item,
@ -59,7 +60,7 @@ const setLists = (results: SearchResult[], page: number, text: string): LX.Music
const setList = (datas: SearchResult, page: number, text: string): LX.Music.MusicInfoOnline[] => {
// console.log(datas.source, datas.list)
let listInfo = state.listInfos[datas.source] as ListInfo
let listInfo = state.listInfos[datas.source]!
const list = datas.list.map(s => toNewMusicInfo(s) as LX.Music.MusicInfoOnline)
listInfo.list = deduplicationList(page == 1 ? list : [...listInfo.list, ...list])
if (page == 1 || (datas.total && datas.list.length)) listInfo.total = datas.total
@ -87,7 +88,7 @@ export default {
}
},
clearListInfo(sourceId: Source) {
let listInfo = state.listInfos[sourceId] as ListInfo
let listInfo = state.listInfos[sourceId]!
listInfo.list = []
listInfo.page = 0
listInfo.maxPage = 0

View File

@ -1,6 +1,6 @@
import { sortInsert, similar } from '@/utils/common'
import type { InitState, ListInfoItem, SearchListInfo, Source } from './state'
import type { InitState, ListInfoItem, Source } from './state'
import state from './state'
export interface SearchResult {
@ -20,6 +20,7 @@ export interface SearchResult {
const handleSortList = (list: ListInfoItem[], keyword: string) => {
let arr: any[] = []
for (const item of list) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
sortInsert(arr, {
num: similar(keyword, item.name),
data: item,
@ -57,7 +58,7 @@ const setLists = (results: SearchResult[], page: number, text: string): ListInfo
const setList = (datas: SearchResult, page: number, text: string): ListInfoItem[] => {
// console.log(datas.source, datas.list)
let listInfo = state.listInfos[datas.source] as SearchListInfo
let listInfo = state.listInfos[datas.source]!
listInfo.list = page == 1 ? datas.list : [...listInfo.list, ...datas.list]
if (page == 1 || (datas.total && datas.list.length)) listInfo.total = datas.total
else listInfo.total = datas.limit * page
@ -83,7 +84,7 @@ export default {
}
},
clearListInfo(sourceId: Source) {
let listInfo = state.listInfos[sourceId] as SearchListInfo
let listInfo = state.listInfos[sourceId]!
listInfo.page = 1
listInfo.limit = 20
listInfo.total = 0

View File

@ -21,7 +21,7 @@ export const sizeFormate = (size: number): string => {
* @param date
* @returns
*/
export const toDateObj = (date: any): Date | '' => {
export const toDateObj = (date?: number | string | Date): Date | '' => {
// console.log(date)
if (!date) return ''
switch (typeof date) {
@ -44,7 +44,7 @@ const numFix = (n: number): string => n < 10 ? (`0${n}`) : n.toString()
* @param _date
* @param format Y-M-D h:m:s Y年 M月 D日 h时 m分 s秒
*/
export const dateFormat = (_date: any, format = 'Y-M-D h:m:s') => {
export const dateFormat = (_date: number | string | Date, format = 'Y-M-D h:m:s') => {
// console.log(date)
const date = toDateObj(_date)
if (!date) return ''

View File

@ -33,7 +33,7 @@ export const toNewMusicInfo = (oldMusicInfo: any): LX.Music.MusicInfo => {
if (oldMusicInfo.source == 'local') {
meta.filePath = oldMusicInfo.filePath ?? oldMusicInfo.songmid ?? ''
meta.ext = oldMusicInfo.ext ?? /\.(\w+)$/.exec(meta.filePath)?.[1] ?? ''
meta.ext = oldMusicInfo.ext ?? /\.(\w+)$/.exec(meta.filePath as string)?.[1] ?? ''
} else {
meta.qualitys = oldMusicInfo.types
meta._qualitys = oldMusicInfo._types

View File

@ -186,7 +186,7 @@ export const userListsUpdatePosition = (position: number, ids: string[]) => {
const map = new Map<string, LX.List.UserListInfo>()
for (const item of newUserLists) map.set(item.id, item)
for (const id of ids) {
const listInfo = map.get(id) as LX.List.UserListInfo
const listInfo = map.get(id)!
listInfo.locationUpdateTime = Date.now()
updateLists.push(listInfo)
map.delete(id)
@ -207,7 +207,7 @@ export const getListMusicSync = (id: string | null) => {
*/
export const getListMusics = async(listId: string): Promise<LX.Music.MusicInfo[]> => {
if (!listId) return []
if (allMusicList.has(listId)) return allMusicList.get(listId) as LX.Music.MusicInfo[]
if (allMusicList.has(listId)) return allMusicList.get(listId)!
const list = await getListMusicsFromStore(listId)
return setMusicList(listId, list)
}
@ -303,7 +303,7 @@ export const listMusicUpdatePosition = async(listId: string, position: number, i
const map = new Map<string, LX.Music.MusicInfo>()
for (const item of targetList) map.set(item.id, item)
for (const id of ids) {
infos.push(map.get(id) as LX.Music.MusicInfo)
infos.push(map.get(id)!)
map.delete(id)
}
const list = targetList.filter(mInfo => map.has(mInfo.id))

View File

@ -186,7 +186,7 @@ export const setAlpha = async(alpha: number): Promise<void> => {
* set text size
* @param size text size
*/
export const setTextSize = async(size: any): Promise<void> => {
export const setTextSize = async(size: number): Promise<void> => {
if (!isShowLyric) return Promise.resolve()
return LyricModule.setTextSize(getTextSize(size))
}
@ -234,10 +234,11 @@ export const openOverlayPermissionActivity = async(): Promise<void> => {
return LyricModule.openOverlayPermissionActivity()
}
export const onPositionChange = (callback: (position: { x: number, y: number }) => void): () => void => {
export const onPositionChange = (handler: (position: { x: number, y: number }) => void): () => void => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const eventEmitter = new NativeEventEmitter(LyricModule)
const eventListener = eventEmitter.addListener('set-position', event => {
callback(event)
handler(event as { x: number, y: number })
})
return () => {

View File

@ -76,15 +76,16 @@ export interface Actions {
}
export type ActionsEvent = { [K in keyof Actions]: { action: K, data: Actions[K] } }[keyof Actions]
export const onScriptAction = (callback: (event: ActionsEvent) => void): () => void => {
export const onScriptAction = (handler: (event: ActionsEvent) => void): () => void => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const eventEmitter = new NativeEventEmitter(UserApiModule)
const eventListener = eventEmitter.addListener('api-action', event => {
if (event.data) event.data = JSON.parse(event.data)
if (event.data) event.data = JSON.parse(event.data as string)
if (event.action == 'init') {
if (event.data.info) event.data.info = { ...loadScriptInfo, ...event.data.info }
else event.data.info = { ...loadScriptInfo }
}
callback(event)
handler(event as ActionsEvent)
})
return () => {

View File

@ -58,10 +58,11 @@ export const getSystemLocales = async(): Promise<string> => {
return UtilsModule.getSystemLocales()
}
export const onScreenStateChange = (callback: (state: 'ON' | 'OFF') => void): () => void => {
export const onScreenStateChange = (handler: (state: 'ON' | 'OFF') => void): () => void => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const eventEmitter = new NativeEventEmitter(UtilsModule)
const eventListener = eventEmitter.addListener('screen-state', event => {
callback(event.state)
handler(event.state as 'ON' | 'OFF')
})
return () => {
@ -73,11 +74,12 @@ export const getWindowSize = async(): Promise<{ width: number, height: number }>
return UtilsModule.getWindowSize()
}
export const onWindowSizeChange = (callback: (size: { width: number, height: number }) => void): () => void => {
export const onWindowSizeChange = (handler: (size: { width: number, height: number }) => void): () => void => {
UtilsModule.listenWindowSizeChanged()
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const eventEmitter = new NativeEventEmitter(UtilsModule)
const eventListener = eventEmitter.addListener('screen-size-changed', event => {
callback(event)
handler(event as { width: number, height: number })
})
return () => {

View File

@ -169,7 +169,7 @@ export const handleReadFile = async<T = unknown>(path: string): Promise<T> => {
// 修复PC v1.14.0出现的导出数据被序列化两次的问题
if (typeof data != 'object') {
try {
data = JSON.parse(data)
data = JSON.parse(data as string)
} catch (err) {
return data
}
@ -509,6 +509,7 @@ export const createStyle = <T extends StyleSheet.NamedStyles<T>>(styles: T | Sty
for (const [n, s] of Object.entries(newStyle)) {
newStyle[n] = trasformeStyle(s)
}
// @ts-expect-error
return StyleSheet.create(newStyle as StyleSheet.NamedStyles<T>)
}

View File

@ -3,6 +3,7 @@
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
"module": "ESNext",
"types": ["react-native", "node"],
/* Completeness */
"skipLibCheck": true, /* Skip type checking all .d.ts files. */