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

View File

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

View File

@ -52,7 +52,7 @@ export default forwardRef<MusicAddModalType, MusicAddModalProps>(({ onAdded }, r
dialogRef.current?.setVisible(false) dialogRef.current?.setVisible(false)
if (selectInfo.isMove) { if (selectInfo.isMove) {
void moveListMusics(selectInfo.listId, listInfo.id, void moveListMusics(selectInfo.listId, listInfo.id,
[selectInfo.musicInfo as LX.Music.MusicInfo], [selectInfo.musicInfo!],
settingState.setting['list.addMusicLocationType'], settingState.setting['list.addMusicLocationType'],
).then(() => { ).then(() => {
onAdded?.() onAdded?.()
@ -62,7 +62,7 @@ export default forwardRef<MusicAddModalType, MusicAddModalProps>(({ onAdded }, r
}) })
} else { } else {
void addListMusics(listInfo.id, void addListMusics(listInfo.id,
[selectInfo.musicInfo as LX.Music.MusicInfo], [selectInfo.musicInfo!],
settingState.setting['list.addMusicLocationType'], settingState.setting['list.addMusicLocationType'],
).then(() => { ).then(() => {
onAdded?.() 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 handleReadDir = async(path: string, dirOnly: boolean, filter?: RegExp, isRefresh = false) => {
const cacheKey = `${path}_${dirOnly ? 'true' : 'false'}_${filter ? filter.toString() : 'null'}` 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 => { return readDir(path).then(paths => {
// console.log('read') // console.log('read')
// prevPath = path // prevPath = path

View File

@ -44,7 +44,7 @@ export default ({ isHome }: { isHome: boolean }) => {
// console.log('') // console.log('')
// console.log(playMusicInfo) // console.log(playMusicInfo)
if (!musicInfo.id) return 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') // toast(global.i18n.t('play_detail_todo_tip'), 'long')
} }

View File

@ -21,7 +21,7 @@ export default ({ isHome }: { isHome: boolean }) => {
// console.log('') // console.log('')
// console.log(playMusicInfo) // console.log(playMusicInfo)
if (!musicInfo.id) return 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') // toast(global.i18n.t('play_detail_todo_tip'), 'long')
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -71,7 +71,7 @@ export default async(setting: LX.AppSetting) => {
// eslint-disable-next-line @typescript-eslint/promise-function-async // eslint-disable-next-line @typescript-eslint/promise-function-async
}).then(res => { }).then(res => {
// console.log(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 } return { type, url: res.data.url }
}).catch(async err => { }).catch(async err => {
console.log(err.message) 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 prevPageKey = `${source}__${bangId}__${page - 1}`
const tempListKey = `${source}__${bangId}__temp` const tempListKey = `${source}__${bangId}__temp`
let listCache = cache.get(listKey) as CacheValue let listCache = cache.get(listKey)!
if (!listCache) cache.set(listKey, listCache = new Map()) if (!listCache) cache.set(listKey, listCache = new Map<string, PageCache | LX.Music.MusicInfoOnline[]>())
let sourcePage = 0 let sourcePage = 0
{ {
const prevPageData = listCache.get(prevPageKey) as PageCache 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) let listCache = cache.get(listKey)
if (!listCache || isRefresh) { 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 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] const [source, bangId] = id.split('__') as [LX.OnlineSource, string]
// console.log(tabId) // console.log(tabId)
const listKey = `${source}__${bangId}` const listKey = `${source}__${bangId}`
let listCache = cache.get(listKey) as CacheValue let listCache = cache.get(listKey)!
if (!listCache || isRefresh) { 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> => { 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 musicInfo: LX.Music.MusicInfoOnline | null = null
let itemQuality: LX.Quality | null = null let itemQuality: LX.Quality | null = null
// eslint-disable-next-line no-cond-assign // 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 if (retryedSource.includes(musicInfo.source)) continue
retryedSource.push(musicInfo.source) retryedSource.push(musicInfo.source)
if (!assertApiSupport(musicInfo.source)) continue if (!assertApiSupport(musicInfo.source)) continue
@ -261,7 +261,7 @@ export const getOnlineOtherSourcePicUrl = async({ musicInfos, onToggleSource, is
}> => { }> => {
let musicInfo: LX.Music.MusicInfoOnline | null = null let musicInfo: LX.Music.MusicInfoOnline | null = null
// eslint-disable-next-line no-cond-assign // 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 if (retryedSource.includes(musicInfo.source)) continue
retryedSource.push(musicInfo.source) retryedSource.push(musicInfo.source)
// if (!assertApiSupport(musicInfo.source)) continue // if (!assertApiSupport(musicInfo.source)) continue
@ -344,7 +344,7 @@ export const getOnlineOtherSourceLyricInfo = async({ musicInfos, onToggleSource,
}> => { }> => {
let musicInfo: LX.Music.MusicInfoOnline | null = null let musicInfo: LX.Music.MusicInfoOnline | null = null
// eslint-disable-next-line no-cond-assign // 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 if (retryedSource.includes(musicInfo.source)) continue
retryedSource.push(musicInfo.source) retryedSource.push(musicInfo.source)
// if (!assertApiSupport(musicInfo.source)) continue // 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) setResource(musicInfo, url, playerState.progress.nowPlayTime)
}).catch((err: any) => { }).catch((err: any) => {
console.log(err) console.log(err)
setStatusText(err.message) setStatusText(err.message as string)
global.app_event.error() global.app_event.error()
addDelayNextTimeout() addDelayNextTimeout()
}).finally(() => { }).finally(() => {

View File

@ -32,7 +32,7 @@ const timeoutTools = {
clearTimeout() { clearTimeout() {
if (!this.bgTimeout) return if (!this.bgTimeout) return
BackgroundTimer.clearTimeout(this.bgTimeout) BackgroundTimer.clearTimeout(this.bgTimeout)
clearInterval(this.timeout as NodeJS.Timer) clearInterval(this.timeout!)
this.bgTimeout = null this.bgTimeout = null
this.timeout = null this.timeout = null
this.time = -1 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 searchMusicActions, { type SearchResult } from '@/store/search/music/action'
import musicSdk from '@/utils/musicSdk' 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[]> => { 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 [] if (!text) return []
const key = `${page}__${text}` const key = `${page}__${text}`
if (sourceId == 'all') { 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 searchSonglistActions, { type SearchResult } from '@/store/search/songlist/action'
import musicSdk from '@/utils/musicSdk' 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[]> => { 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 [] // if (!text) return []
const key = `${page}__${sourceId}__${text}` const key = `${page}__${sourceId}__${text}`
if (listInfo.key == key && listInfo.list.length) return listInfo.list 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 listInfo.key = key
let task = [] let task = []
for (const source of searchSonglistState.sources) { 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) => { 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) console.log(error)
return { 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 songlistActions from '@/store/songlist/action'
import { deduplicationList, toNewMusicInfo } from '@/utils' import { deduplicationList, toNewMusicInfo } from '@/utils'
import musicSdk from '@/utils/musicSdk' import musicSdk from '@/utils/musicSdk'
@ -28,7 +28,7 @@ export const setSelectListInfo = (info: ListInfoItem) => {
* @returns * @returns
*/ */
export const getSortList = (source: LX.OnlineSource) => { 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 = { export const log = {
r_info(...params: any[]) { r_info(...params: any[]) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
writeLog.info(...params) writeLog.info(...params)
}, },
r_warn(...params: any[]) { r_warn(...params: any[]) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
writeLog.warn(...params) writeLog.warn(...params)
}, },
r_error(...params: any[]) { r_error(...params: any[]) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
writeLog.error(...params) writeLog.error(...params)
}, },
log(...params: any[]) { log(...params: any[]) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
if (global.lx.isEnableUserApiLog) writeLog.info(...params) if (global.lx.isEnableUserApiLog) writeLog.info(...params)
}, },
info(...params: any[]) { info(...params: any[]) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
if (global.lx.isEnableUserApiLog) writeLog.info(...params) if (global.lx.isEnableUserApiLog) writeLog.info(...params)
}, },
warn(...params: any[]) { warn(...params: any[]) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
if (global.lx.isEnableUserApiLog) writeLog.warn(...params) if (global.lx.isEnableUserApiLog) writeLog.warn(...params)
}, },
error(...params: any[]) { error(...params: any[]) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
if (global.lx.isEnableUserApiLog) writeLog.error(...params) if (global.lx.isEnableUserApiLog) writeLog.error(...params)
}, },
} }

View File

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

View File

@ -14,7 +14,7 @@ export const usePlaybackState = () => {
void setPlayerState() void setPlayerState()
const sub = TrackPlayer.addEventListener(Event.PlaybackState, data => { const sub = TrackPlayer.addEventListener(Event.PlaybackState, data => {
setState(data.state) setState(data.state as State)
}) })
return () => { sub.remove() } return () => { sub.remove() }
@ -99,6 +99,7 @@ export function useProgress(updateInterval: number) {
} }
useEffect(() => { useEffect(() => {
// @ts-expect-error
if (!pollTrackPlayerStates.includes(playerState)) return if (!pollTrackPlayerStates.includes(playerState)) return
void getProgress() 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)) await TrackPlayer.skip(queue.findIndex(t => t.id == track.id))
if (currentTrackIndex == null) { if (currentTrackIndex == null) {
if (!isTempTrack(track.id)) { if (!isTempTrack(track.id as string)) {
if (time) await TrackPlayer.seekTo(time) if (time) await TrackPlayer.seekTo(time)
if (global.lx.restorePlayInfo) { if (global.lx.restorePlayInfo) {
await TrackPlayer.pause() await TrackPlayer.pause()
@ -152,7 +152,7 @@ const handlePlayMusic = async(musicInfo: LX.Player.PlayMusic, url: string, time:
} }
} else { } else {
await TrackPlayer.pause() await TrackPlayer.pause()
if (!isTempTrack(track.id)) { if (!isTempTrack(track.id as string)) {
await TrackPlayer.seekTo(time) await TrackPlayer.seekTo(time)
await TrackPlayer.play() await TrackPlayer.play()
} }

View File

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

View File

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

View File

@ -117,6 +117,7 @@ export const getDataMultiple = async<T extends readonly string[]>(keys: T) => {
if (value && partKeyPrefixRxp.test(value)) { if (value && partKeyPrefixRxp.test(value)) {
promises.push(handleGetData(value)) promises.push(handleGetData(value))
} else { } else {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
promises.push(Promise.resolve(value ? JSON.parse(value) : value)) 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) => { }).catch((err: any) => {
log.error(`disconnect error: ${err.message as string}`) log.error(`disconnect error: ${err.message as string}`)
sendSyncMessage(err.message) sendSyncMessage(err.message as string)
}) })
export { export {

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react' import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react'
import OnlineList, { type OnlineListType, type OnlineListProps } from '@/components/OnlineList' import OnlineList, { type OnlineListType, type OnlineListProps } from '@/components/OnlineList'
import { search } from '@/core/search/music' 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, // export type MusicListProps = Pick<OnlineListProps,
// 'onLoadMore' // 'onLoadMore'
@ -66,7 +66,7 @@ export default forwardRef<MusicListType, {}>((props, ref) => {
} }
const handleLoadMore: OnlineListProps['onLoadMore'] = () => { const handleLoadMore: OnlineListProps['onLoadMore'] = () => {
listRef.current?.setStatus('loading') 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 const page = info?.list.length ? info.page + 1 : 1
search(searchInfoRef.current.text, page, searchInfoRef.current.source).then((list) => { search(searchInfoRef.current.text, page, searchInfoRef.current.source).then((list) => {
// const result = setListInfo(listDetail, searchMusicState.listDetailInfo.id, page) // 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 { search } from '@/core/search/songlist'
import Songlist, { type SonglistProps, type SonglistType } from '@/screens/Home/Views/SongList/components/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, // export type MusicListProps = Pick<OnlineListProps,
// 'onLoadMore' // 'onLoadMore'
@ -67,7 +67,7 @@ export default forwardRef<MusicListType, {}>((props, ref) => {
} }
const handleLoadMore: SonglistProps['onLoadMore'] = () => { const handleLoadMore: SonglistProps['onLoadMore'] = () => {
listRef.current?.setStatus('loading') 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 const page = info.list.length ? info.page + 1 : 1
search(searchInfoRef.current.text, page, searchInfoRef.current.source).then((list) => { search(searchInfoRef.current.text, page, searchInfoRef.current.source).then((list) => {
// const result = setListInfo(listDetail, searchSonglistState.listDetailInfo.id, page) // 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)))) await overwriteListMusics(LIST_IDS.DEFAULT, filterMusicList((configData.data as LX.List.MyDefaultListInfoFull).list.map(m => toNewMusicInfo(m))))
break break
case 'playList': case 'playList':
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
await importOldListData(configData.data) await importOldListData(configData.data)
break break
case 'playList_v2': case 'playList_v2':
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
await importNewListData(configData.data) await importNewListData(configData.data)
break break
case 'allData': case 'allData':
// 兼容0.6.2及以前版本的列表数据 // 兼容0.6.2及以前版本的列表数据
if (configData.defaultList) await overwriteListMusics(LIST_IDS.DEFAULT, filterMusicList((configData.defaultList as LX.List.MyDefaultListInfoFull).list.map(m => toNewMusicInfo(m)))) 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) else await importOldListData(configData.playList)
break break
case 'allData_v2': case 'allData_v2':
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
await importNewListData(configData.playList) await importNewListData(configData.playList)
break break
case 'playListPart': case 'playListPart':
configData.data.list = filterMusicList((configData.data as LX.ConfigFile.MyListInfoPart['data']).list.map(m => toNewMusicInfo(m))) 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) void handleImportListPart(configData.data)
return true return true
case 'playListPart_v2': case 'playListPart_v2':
configData.data.list = filterMusicList((configData.data as LX.ConfigFile.MyListInfoPart['data']).list).map(m => fixNewMusicInfoQuality(m)) 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) void handleImportListPart(configData.data)
return true return true
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
default: showImportTip(configData.type) default: showImportTip(configData.type)
} }
} }

View File

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

View File

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

View File

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

View File

@ -13,7 +13,7 @@ export default () => {
musicAddModalRef.current?.show({ musicAddModalRef.current?.show({
musicInfo: 'progress' in musicInfo ? musicInfo.metadata.musicInfo : musicInfo, musicInfo: 'progress' in musicInfo ? musicInfo.metadata.musicInfo : musicInfo,
isMove: false, 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 () => { export default () => {
const handleShowCommentScreen = () => { const handleShowCommentScreen = () => {
navigations.pushCommentScreen(commonState.componentIds.playDetail as string) navigations.pushCommentScreen(commonState.componentIds.playDetail!)
} }
return <Btn icon="comment" onPress={handleShowCommentScreen} /> return <Btn icon="comment" onPress={handleShowCommentScreen} />

View File

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

View File

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

View File

@ -13,7 +13,7 @@ export default () => {
musicAddModalRef.current?.show({ musicAddModalRef.current?.show({
musicInfo: 'progress' in musicInfo ? musicInfo.metadata.musicInfo : musicInfo, musicInfo: 'progress' in musicInfo ? musicInfo.metadata.musicInfo : musicInfo,
isMove: false, 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 popupRef = useRef<SettingPopupType>(null)
const back = () => { const back = () => {
void pop(commonState.componentIds.playDetail as string) void pop(commonState.componentIds.playDetail!)
} }
const showSetting = () => { const showSetting = () => {
popupRef.current?.show() popupRef.current?.show()

View File

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

View File

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

View File

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

View File

@ -33,7 +33,7 @@ export const toNewMusicInfo = (oldMusicInfo: any): LX.Music.MusicInfo => {
if (oldMusicInfo.source == 'local') { if (oldMusicInfo.source == 'local') {
meta.filePath = oldMusicInfo.filePath ?? oldMusicInfo.songmid ?? '' 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 { } else {
meta.qualitys = oldMusicInfo.types meta.qualitys = oldMusicInfo.types
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>() const map = new Map<string, LX.List.UserListInfo>()
for (const item of newUserLists) map.set(item.id, item) for (const item of newUserLists) map.set(item.id, item)
for (const id of ids) { for (const id of ids) {
const listInfo = map.get(id) as LX.List.UserListInfo const listInfo = map.get(id)!
listInfo.locationUpdateTime = Date.now() listInfo.locationUpdateTime = Date.now()
updateLists.push(listInfo) updateLists.push(listInfo)
map.delete(id) map.delete(id)
@ -207,7 +207,7 @@ export const getListMusicSync = (id: string | null) => {
*/ */
export const getListMusics = async(listId: string): Promise<LX.Music.MusicInfo[]> => { export const getListMusics = async(listId: string): Promise<LX.Music.MusicInfo[]> => {
if (!listId) return [] 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) const list = await getListMusicsFromStore(listId)
return setMusicList(listId, list) 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>() const map = new Map<string, LX.Music.MusicInfo>()
for (const item of targetList) map.set(item.id, item) for (const item of targetList) map.set(item.id, item)
for (const id of ids) { for (const id of ids) {
infos.push(map.get(id) as LX.Music.MusicInfo) infos.push(map.get(id)!)
map.delete(id) map.delete(id)
} }
const list = targetList.filter(mInfo => map.has(mInfo.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 * set text size
* @param size 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() if (!isShowLyric) return Promise.resolve()
return LyricModule.setTextSize(getTextSize(size)) return LyricModule.setTextSize(getTextSize(size))
} }
@ -234,10 +234,11 @@ export const openOverlayPermissionActivity = async(): Promise<void> => {
return LyricModule.openOverlayPermissionActivity() 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 eventEmitter = new NativeEventEmitter(LyricModule)
const eventListener = eventEmitter.addListener('set-position', event => { const eventListener = eventEmitter.addListener('set-position', event => {
callback(event) handler(event as { x: number, y: number })
}) })
return () => { 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 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 eventEmitter = new NativeEventEmitter(UserApiModule)
const eventListener = eventEmitter.addListener('api-action', event => { 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.action == 'init') {
if (event.data.info) event.data.info = { ...loadScriptInfo, ...event.data.info } if (event.data.info) event.data.info = { ...loadScriptInfo, ...event.data.info }
else event.data.info = { ...loadScriptInfo } else event.data.info = { ...loadScriptInfo }
} }
callback(event) handler(event as ActionsEvent)
}) })
return () => { return () => {

View File

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

View File

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

View File

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