lint code

pull/1583/head
lyswhut 2023-08-30 14:30:47 +08:00
parent 358142c1cc
commit 2fff8652ca
48 changed files with 123 additions and 106 deletions

View File

@ -5,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',

View File

@ -16,7 +16,7 @@ module.exports = async(context) => {
const resPath = `${appOutDir}/${productFilename}.app/Contents/Resources` const resPath = `${appOutDir}/${productFilename}.app/Contents/Resources`
// 创建APP语言包文件 // 创建APP语言包文件
return await Promise.all( return Promise.all(
Object.entries(macLanguagesInfoPlistStrings).map(([lang, config]) => { Object.entries(macLanguagesInfoPlistStrings).map(([lang, config]) => {
let infos = Object.entries(config).map(([k, v]) => `"${k}" = "${v}";`).join('\n') let infos = Object.entries(config).map(([k, v]) => `"${k}" = "${v}";`).join('\n')
return fs.writeFile(`${resPath}/${lang}.lproj/InfoPlist.strings`, infos) return fs.writeFile(`${resPath}/${lang}.lproj/InfoPlist.strings`, infos)

View File

@ -30,7 +30,7 @@ export function mainHandle<V>(name: string, listener: LX.IpcMainInvokeEventListe
export function mainHandle<T, V>(name: string, listener: LX.IpcMainInvokeEventListenerParamsValue<T, V>): void export function mainHandle<T, V>(name: string, listener: LX.IpcMainInvokeEventListenerParamsValue<T, V>): void
export function mainHandle<T, V>(name: string, listener: LX.IpcMainInvokeEventListenerParamsValue<T, V>): void { export function mainHandle<T, V>(name: string, listener: LX.IpcMainInvokeEventListenerParamsValue<T, V>): void {
ipcMain.handle(name, async(event, params) => { ipcMain.handle(name, async(event, params) => {
return await listener({ event, params }) return listener({ event, params })
}) })
} }
@ -40,7 +40,7 @@ export function mainHandleOnce<V>(name: string, listener: LX.IpcMainInvokeEventL
export function mainHandleOnce<T, V>(name: string, listener: LX.IpcMainInvokeEventListenerParamsValue<T, V>): void export function mainHandleOnce<T, V>(name: string, listener: LX.IpcMainInvokeEventListenerParamsValue<T, V>): void
export function mainHandleOnce<T, V>(name: string, listener: LX.IpcMainInvokeEventListenerParamsValue<T, V>): void { export function mainHandleOnce<T, V>(name: string, listener: LX.IpcMainInvokeEventListenerParamsValue<T, V>): void {
ipcMain.handleOnce(name, async(event, params) => { ipcMain.handleOnce(name, async(event, params) => {
return await listener({ event, params }) return listener({ event, params })
}) })
} }
export const mainHandleRemove = (name: string) => { export const mainHandleRemove = (name: string) => {

View File

@ -17,7 +17,7 @@ export async function rendererInvoke<V>(name: string): Promise<V>
export async function rendererInvoke<T>(name: string, params: T): Promise<void> export async function rendererInvoke<T>(name: string, params: T): Promise<void>
export async function rendererInvoke<T, V>(name: string, params: T): Promise<V> export async function rendererInvoke<T, V>(name: string, params: T): Promise<V>
export async function rendererInvoke <T, V>(name: string, params?: T): Promise<V> { export async function rendererInvoke <T, V>(name: string, params?: T): Promise<V> {
return await ipcRenderer.invoke(name, params) return ipcRenderer.invoke(name, params)
} }
export function rendererOn(name: string, listener: LX.IpcRendererEventListener): void export function rendererOn(name: string, listener: LX.IpcRendererEventListener): void

View File

@ -15,7 +15,7 @@ export const dirname = (p: string): string => path.dirname(p)
* @param {*} path * @param {*} path
*/ */
export const checkPath = async(path: string): Promise<boolean> => { export const checkPath = async(path: string): Promise<boolean> => {
return await new Promise(resolve => { return new Promise(resolve => {
if (!path) { if (!path) {
resolve(false) resolve(false)
return return
@ -31,7 +31,7 @@ export const checkPath = async(path: string): Promise<boolean> => {
} }
export const getFileStats = async(path: string): Promise<fs.Stats | null> => { export const getFileStats = async(path: string): Promise<fs.Stats | null> => {
return await new Promise(resolve => { return new Promise(resolve => {
if (!path) { if (!path) {
resolve(null) resolve(null)
return return
@ -97,7 +97,7 @@ export const readFile = async(path: string) => fs.promises.readFile(path)
export const toMD5 = (str: string) => crypto.createHash('md5').update(str).digest('hex') export const toMD5 = (str: string) => crypto.createHash('md5').update(str).digest('hex')
export const gzipData = async(str: string): Promise<Buffer> => { export const gzipData = async(str: string): Promise<Buffer> => {
return await new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
gzip(str, (err, result) => { gzip(str, (err, result) => {
if (err) { if (err) {
reject(err) reject(err)
@ -109,7 +109,7 @@ export const gzipData = async(str: string): Promise<Buffer> => {
} }
export const gunzipData = async(buf: Buffer): Promise<string> => { export const gunzipData = async(buf: Buffer): Promise<string> => {
return await new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
gunzip(buf, (err, result) => { gunzip(buf, (err, result) => {
if (err) { if (err) {
reject(err) reject(err)

View File

@ -253,7 +253,7 @@ export const initAppSetting = async() => {
} }
// global.lx.theme = getTheme() // global.lx.theme = getTheme()
isInitialized = true isInitialized ||= true
} }
export const quitApp = () => { export const quitApp = () => {

View File

@ -20,7 +20,7 @@ export default () => {
}) })
mainHandle<string[]>(CMMON_EVENT_NAME.get_system_fonts, async() => { mainHandle<string[]>(CMMON_EVENT_NAME.get_system_fonts, async() => {
return await getFonts() return getFonts()
}) })
} }

View File

@ -4,7 +4,7 @@ import { PLAYER_EVENT_NAME } from '@common/ipcNames'
// 列表操作事件(公共,只注册一次) // 列表操作事件(公共,只注册一次)
export default () => { export default () => {
mainHandle<LX.List.UserListInfo[]>(PLAYER_EVENT_NAME.list_get, async() => { mainHandle<LX.List.UserListInfo[]>(PLAYER_EVENT_NAME.list_get, async() => {
return await global.lx.worker.dbService.getAllUserList() return global.lx.worker.dbService.getAllUserList()
}) })
mainHandle<LX.List.ListActionDataOverwrite>(PLAYER_EVENT_NAME.list_data_overwire, async({ params: listData }) => { mainHandle<LX.List.ListActionDataOverwrite>(PLAYER_EVENT_NAME.list_data_overwire, async({ params: listData }) => {
await global.lx.event_list.list_data_overwrite(listData, false) await global.lx.event_list.list_data_overwrite(listData, false)
@ -22,7 +22,7 @@ export default () => {
await global.lx.event_list.list_update_position(position, ids, false) await global.lx.event_list.list_update_position(position, ids, false)
}) })
mainHandle<string, LX.Music.MusicInfo[]>(PLAYER_EVENT_NAME.list_music_get, async({ params: listId }) => { mainHandle<string, LX.Music.MusicInfo[]>(PLAYER_EVENT_NAME.list_music_get, async({ params: listId }) => {
return await global.lx.worker.dbService.getListMusics(listId) return global.lx.worker.dbService.getListMusics(listId)
}) })
mainHandle<LX.List.ListActionMusicAdd>(PLAYER_EVENT_NAME.list_music_add, async({ params: { id, musicInfos, addMusicLocationType } }) => { mainHandle<LX.List.ListActionMusicAdd>(PLAYER_EVENT_NAME.list_music_add, async({ params: { id, musicInfos, addMusicLocationType } }) => {
await global.lx.event_list.list_music_add(id, musicInfos, addMusicLocationType, false) await global.lx.event_list.list_music_add(id, musicInfos, addMusicLocationType, false)
@ -46,9 +46,9 @@ export default () => {
await global.lx.event_list.list_music_clear(listId, false) await global.lx.event_list.list_music_clear(listId, false)
}) })
mainHandle<LX.List.ListActionCheckMusicExistList, boolean>(PLAYER_EVENT_NAME.list_music_check_exist, async({ params: { listId, musicInfoId } }) => { mainHandle<LX.List.ListActionCheckMusicExistList, boolean>(PLAYER_EVENT_NAME.list_music_check_exist, async({ params: { listId, musicInfoId } }) => {
return await global.lx.worker.dbService.checkListExistMusic(listId, musicInfoId) return global.lx.worker.dbService.checkListExistMusic(listId, musicInfoId)
}) })
mainHandle<string, string[]>(PLAYER_EVENT_NAME.list_music_get_list_ids, async({ params: musicInfoId }) => { mainHandle<string, string[]>(PLAYER_EVENT_NAME.list_music_get_list_ids, async({ params: musicInfoId }) => {
return await global.lx.worker.dbService.getMusicExistListIds(musicInfoId) return global.lx.worker.dbService.getMusicExistListIds(musicInfoId)
}) })
} }

View File

@ -16,8 +16,10 @@ export const initClientInfo = async() => {
if (syncAuthKeys != null) return if (syncAuthKeys != null) return
const syncAuthKeysFilePath = path.join(global.lxDataPath, File.clientDataPath, File.syncAuthKeysJSON) const syncAuthKeysFilePath = path.join(global.lxDataPath, File.clientDataPath, File.syncAuthKeysJSON)
if (await fs.promises.stat(syncAuthKeysFilePath).then(() => true).catch(() => false)) { if (await fs.promises.stat(syncAuthKeysFilePath).then(() => true).catch(() => false)) {
// eslint-disable-next-line require-atomic-updates
syncAuthKeys = JSON.parse((await fs.promises.readFile(syncAuthKeysFilePath)).toString()) syncAuthKeys = JSON.parse((await fs.promises.readFile(syncAuthKeysFilePath)).toString())
} else { } else {
// eslint-disable-next-line require-atomic-updates
syncAuthKeys = {} syncAuthKeys = {}
const syncDataPath = path.join(global.lxDataPath, File.clientDataPath) const syncDataPath = path.join(global.lxDataPath, File.clientDataPath)
if (!await exists(syncDataPath)) { if (!await exists(syncDataPath)) {

View File

@ -12,6 +12,7 @@ const sendListAction = async(wss: LX.Sync.Server.SocketServer, action: LX.Sync.L
let key = '' let key = ''
for (const client of wss.clients) { for (const client of wss.clients) {
if (!client.moduleReadys?.list) continue if (!client.moduleReadys?.list) continue
// eslint-disable-next-line require-atomic-updates
if (!key) key = await userSpace.listManage.createSnapshot() if (!key) key = await userSpace.listManage.createSnapshot()
void client.remoteQueueList.onListSyncAction(action).then(async() => { void client.remoteQueueList.onListSyncAction(action).then(async() => {
return userSpace.listManage.updateDeviceSnapshotKey(client.keyInfo.clientId, key) return userSpace.listManage.updateDeviceSnapshotKey(client.keyInfo.clientId, key)

View File

@ -25,8 +25,10 @@ export const initServerInfo = async() => {
if (serverInfo != null) return if (serverInfo != null) return
const serverInfoFilePath = path.join(global.lxDataPath, File.serverDataPath, File.serverInfoJSON) const serverInfoFilePath = path.join(global.lxDataPath, File.serverDataPath, File.serverInfoJSON)
if (await exists(serverInfoFilePath)) { if (await exists(serverInfoFilePath)) {
// eslint-disable-next-line require-atomic-updates
serverInfo = JSON.parse((await fs.promises.readFile(serverInfoFilePath)).toString()) serverInfo = JSON.parse((await fs.promises.readFile(serverInfoFilePath)).toString())
} else { } else {
// eslint-disable-next-line require-atomic-updates
serverInfo = { serverInfo = {
serverId: randomBytes(4 * 4).toString('base64'), serverId: randomBytes(4 * 4).toString('base64'),
version: 2, version: 2,

View File

@ -28,7 +28,7 @@ export const setApi = async(id: string) => {
} }
const apiList = getUserApis() const apiList = getUserApis()
if (!apiList.some(a => a.id === id)) return if (!apiList.some(a => a.id === id)) return
userApiId = id userApiId ||= id
await loadApi(id) await loadApi(id)
} }

View File

@ -30,6 +30,7 @@ export const createWindow = async(userApi: LX.UserApi.UserApiInfo) => {
dir ??= process.env.NODE_ENV !== 'production' ? webpackUserApiPath : path.join(encodePath(__dirname), 'userApi') dir ??= process.env.NODE_ENV !== 'production' ? webpackUserApiPath : path.join(encodePath(__dirname), 'userApi')
if (!html) { if (!html) {
// eslint-disable-next-line require-atomic-updates
html = await fs.promises.readFile(path.join(dir, 'renderer/user-api.html'), 'utf8') html = await fs.promises.readFile(path.join(dir, 'renderer/user-api.html'), 'utf8')
} }
const preloadUrl = process.env.NODE_ENV !== 'production' const preloadUrl = process.env.NODE_ENV !== 'production'

View File

@ -128,7 +128,7 @@ export const sendEvent = <T = any>(name: string, params?: T) => {
export const showSelectDialog = async(options: Electron.OpenDialogOptions) => { export const showSelectDialog = async(options: Electron.OpenDialogOptions) => {
if (!browserWindow) throw new Error('main window is undefined') if (!browserWindow) throw new Error('main window is undefined')
return await dialog.showOpenDialog(browserWindow, options) return dialog.showOpenDialog(browserWindow, options)
} }
export const showDialog = ({ type, message, detail }: Electron.MessageBoxSyncOptions) => { export const showDialog = ({ type, message, detail }: Electron.MessageBoxSyncOptions) => {
if (!browserWindow) return if (!browserWindow) return
@ -140,7 +140,7 @@ export const showDialog = ({ type, message, detail }: Electron.MessageBoxSyncOpt
} }
export const showSaveDialog = async(options: Electron.SaveDialogOptions) => { export const showSaveDialog = async(options: Electron.SaveDialogOptions) => {
if (!browserWindow) throw new Error('main window is undefined') if (!browserWindow) throw new Error('main window is undefined')
return await dialog.showSaveDialog(browserWindow, options) return dialog.showSaveDialog(browserWindow, options)
} }
export const minimize = () => { export const minimize = () => {
if (!browserWindow) return if (!browserWindow) return
@ -256,7 +256,7 @@ export const clearCache = async() => {
export const getCacheSize = async() => { export const getCacheSize = async() => {
if (!browserWindow) throw new Error('main window is undefined') if (!browserWindow) throw new Error('main window is undefined')
return await browserWindow.webContents.session.getCacheSize() return browserWindow.webContents.session.getCacheSize()
} }
export const getWebContents = (): Electron.WebContents => { export const getWebContents = (): Electron.WebContents => {

View File

@ -70,7 +70,7 @@ export default () => {
// 选择目录 // 选择目录
mainHandle<Electron.OpenDialogOptions, Electron.OpenDialogReturnValue>(WIN_MAIN_RENDERER_EVENT_NAME.show_select_dialog, async({ params: options }) => { mainHandle<Electron.OpenDialogOptions, Electron.OpenDialogReturnValue>(WIN_MAIN_RENDERER_EVENT_NAME.show_select_dialog, async({ params: options }) => {
return await showSelectDialog(options) return showSelectDialog(options)
}) })
// 显示弹窗信息 // 显示弹窗信息
mainOn<Electron.MessageBoxSyncOptions>(WIN_MAIN_RENDERER_EVENT_NAME.show_dialog, ({ params }) => { mainOn<Electron.MessageBoxSyncOptions>(WIN_MAIN_RENDERER_EVENT_NAME.show_dialog, ({ params }) => {
@ -78,7 +78,7 @@ export default () => {
}) })
// 显示保存弹窗 // 显示保存弹窗
mainHandle<Electron.SaveDialogOptions, Electron.SaveDialogReturnValue>(WIN_MAIN_RENDERER_EVENT_NAME.show_save_dialog, async({ params }) => { mainHandle<Electron.SaveDialogOptions, Electron.SaveDialogReturnValue>(WIN_MAIN_RENDERER_EVENT_NAME.show_save_dialog, async({ params }) => {
return await showSaveDialog(params) return showSaveDialog(params)
}) })
@ -87,7 +87,7 @@ export default () => {
}) })
mainHandle<number>(WIN_MAIN_RENDERER_EVENT_NAME.get_cache_size, async() => { mainHandle<number>(WIN_MAIN_RENDERER_EVENT_NAME.get_cache_size, async() => {
return await getCacheSize() return getCacheSize()
}) })
mainOn(WIN_MAIN_RENDERER_EVENT_NAME.open_dev_tools, () => { mainOn(WIN_MAIN_RENDERER_EVENT_NAME.open_dev_tools, () => {

View File

@ -4,7 +4,7 @@ import { mainHandle } from '@common/mainIpc'
export default () => { export default () => {
mainHandle<LX.Download.ListItem[]>(WIN_MAIN_RENDERER_EVENT_NAME.download_list_get, async() => { mainHandle<LX.Download.ListItem[]>(WIN_MAIN_RENDERER_EVENT_NAME.download_list_get, async() => {
return await global.lx.worker.dbService.getDownloadList() return global.lx.worker.dbService.getDownloadList()
}) })
mainHandle<LX.Download.saveDownloadMusicInfo>(WIN_MAIN_RENDERER_EVENT_NAME.download_list_add, async({ params: { list, addMusicLocationType } }) => { mainHandle<LX.Download.saveDownloadMusicInfo>(WIN_MAIN_RENDERER_EVENT_NAME.download_list_add, async({ params: { list, addMusicLocationType } }) => {
await global.lx.worker.dbService.downloadInfoSave(list, addMusicLocationType) await global.lx.worker.dbService.downloadInfoSave(list, addMusicLocationType)

View File

@ -4,7 +4,7 @@ import { mainHandle } from '@common/mainIpc'
import { WIN_MAIN_RENDERER_EVENT_NAME } from '@common/ipcNames' import { WIN_MAIN_RENDERER_EVENT_NAME } from '@common/ipcNames'
const handleInflate = async(data: Buffer) => { const handleInflate = async(data: Buffer) => {
return await new Promise((resolve: (result: Buffer) => void, reject) => { return new Promise((resolve: (result: Buffer) => void, reject) => {
inflate(data, (err, result) => { inflate(data, (err, result) => {
if (err) { if (err) {
reject(err) reject(err)

View File

@ -7,12 +7,12 @@ export default () => {
mainHandle<string, LX.Player.LyricInfo>(WIN_MAIN_RENDERER_EVENT_NAME.get_palyer_lyric, async({ params: id }) => { mainHandle<string, LX.Player.LyricInfo>(WIN_MAIN_RENDERER_EVENT_NAME.get_palyer_lyric, async({ params: id }) => {
// return (getStore(LRC_EDITED, true, false).get(id) as LX.Music.LyricInfo | undefined) ?? // return (getStore(LRC_EDITED, true, false).get(id) as LX.Music.LyricInfo | undefined) ??
// getStore(LRC_RAW, true, false).get(id, {}) as LX.Music.LyricInfo // getStore(LRC_RAW, true, false).get(id, {}) as LX.Music.LyricInfo
return await global.lx.worker.dbService.getPlayerLyric(id) return global.lx.worker.dbService.getPlayerLyric(id)
}) })
// 原始歌词 // 原始歌词
mainHandle<string, LX.Music.LyricInfo>(WIN_MAIN_RENDERER_EVENT_NAME.get_lyric_raw, async({ params: id }) => { mainHandle<string, LX.Music.LyricInfo>(WIN_MAIN_RENDERER_EVENT_NAME.get_lyric_raw, async({ params: id }) => {
return await global.lx.worker.dbService.getRawLyric(id) return global.lx.worker.dbService.getRawLyric(id)
}) })
mainHandle<LX.Music.LyricInfoSave>(WIN_MAIN_RENDERER_EVENT_NAME.save_lyric_raw, async({ params: { id, lyrics } }) => { mainHandle<LX.Music.LyricInfoSave>(WIN_MAIN_RENDERER_EVENT_NAME.save_lyric_raw, async({ params: { id, lyrics } }) => {
await global.lx.worker.dbService.rawLyricAdd(id, lyrics) await global.lx.worker.dbService.rawLyricAdd(id, lyrics)
@ -21,12 +21,12 @@ export default () => {
await global.lx.worker.dbService.rawLyricClear() await global.lx.worker.dbService.rawLyricClear()
}) })
mainHandle(WIN_MAIN_RENDERER_EVENT_NAME.get_lyric_raw_count, async() => { mainHandle(WIN_MAIN_RENDERER_EVENT_NAME.get_lyric_raw_count, async() => {
return await global.lx.worker.dbService.rawLyricCount() return global.lx.worker.dbService.rawLyricCount()
}) })
// 已编辑的歌词 // 已编辑的歌词
mainHandle<string, LX.Music.LyricInfo>(WIN_MAIN_RENDERER_EVENT_NAME.get_lyric_edited, async({ params: id }) => { mainHandle<string, LX.Music.LyricInfo>(WIN_MAIN_RENDERER_EVENT_NAME.get_lyric_edited, async({ params: id }) => {
return await global.lx.worker.dbService.getEditedLyric(id) return global.lx.worker.dbService.getEditedLyric(id)
}) })
mainHandle<LX.Music.LyricInfoSave>(WIN_MAIN_RENDERER_EVENT_NAME.save_lyric_edited, async({ params: { id, lyrics } }) => { mainHandle<LX.Music.LyricInfoSave>(WIN_MAIN_RENDERER_EVENT_NAME.save_lyric_edited, async({ params: { id, lyrics } }) => {
await global.lx.worker.dbService.editedLyricUpdateAddAndUpdate(id, lyrics) await global.lx.worker.dbService.editedLyricUpdateAddAndUpdate(id, lyrics)
@ -38,13 +38,13 @@ export default () => {
await global.lx.worker.dbService.editedLyricClear() await global.lx.worker.dbService.editedLyricClear()
}) })
mainHandle(WIN_MAIN_RENDERER_EVENT_NAME.get_lyric_edited_count, async() => { mainHandle(WIN_MAIN_RENDERER_EVENT_NAME.get_lyric_edited_count, async() => {
return await global.lx.worker.dbService.editedLyricCount() return global.lx.worker.dbService.editedLyricCount()
}) })
// =========================歌曲URL========================= // =========================歌曲URL=========================
mainHandle<string, string>(WIN_MAIN_RENDERER_EVENT_NAME.get_music_url, async({ params: id }) => { mainHandle<string, string>(WIN_MAIN_RENDERER_EVENT_NAME.get_music_url, async({ params: id }) => {
return await global.lx.worker.dbService.getMusicUrl(id) ?? '' return (await global.lx.worker.dbService.getMusicUrl(id)) ?? ''
}) })
mainHandle<LX.Music.MusicUrlInfo>(WIN_MAIN_RENDERER_EVENT_NAME.save_music_url, async({ params: { id, url } }) => { mainHandle<LX.Music.MusicUrlInfo>(WIN_MAIN_RENDERER_EVENT_NAME.save_music_url, async({ params: { id, url } }) => {
await global.lx.worker.dbService.musicUrlSave([{ id, url }]) await global.lx.worker.dbService.musicUrlSave([{ id, url }])
@ -53,12 +53,12 @@ export default () => {
await global.lx.worker.dbService.musicUrlClear() await global.lx.worker.dbService.musicUrlClear()
}) })
mainHandle(WIN_MAIN_RENDERER_EVENT_NAME.get_music_url_count, async() => { mainHandle(WIN_MAIN_RENDERER_EVENT_NAME.get_music_url_count, async() => {
return await global.lx.worker.dbService.musicUrlCount() return global.lx.worker.dbService.musicUrlCount()
}) })
// =========================换源歌曲========================= // =========================换源歌曲=========================
mainHandle<string, LX.Music.MusicInfoOnline[]>(WIN_MAIN_RENDERER_EVENT_NAME.get_other_source, async({ params: id }) => { mainHandle<string, LX.Music.MusicInfoOnline[]>(WIN_MAIN_RENDERER_EVENT_NAME.get_other_source, async({ params: id }) => {
return await global.lx.worker.dbService.getMusicInfoOtherSource(id) return global.lx.worker.dbService.getMusicInfoOtherSource(id)
}) })
mainHandle<LX.Music.MusicInfoOtherSourceSave>(WIN_MAIN_RENDERER_EVENT_NAME.save_other_source, async({ params: { id, list } }) => { mainHandle<LX.Music.MusicInfoOtherSourceSave>(WIN_MAIN_RENDERER_EVENT_NAME.save_other_source, async({ params: { id, list } }) => {
await global.lx.worker.dbService.musicInfoOtherSourceAdd(id, list) await global.lx.worker.dbService.musicInfoOtherSourceAdd(id, list)
@ -67,7 +67,7 @@ export default () => {
await global.lx.worker.dbService.musicInfoOtherSourceClear() await global.lx.worker.dbService.musicInfoOtherSourceClear()
}) })
mainHandle(WIN_MAIN_RENDERER_EVENT_NAME.get_other_source_count, async() => { mainHandle(WIN_MAIN_RENDERER_EVENT_NAME.get_other_source_count, async() => {
return await global.lx.worker.dbService.musicInfoOtherSourceCount() return global.lx.worker.dbService.musicInfoOtherSourceCount()
}) })

View File

@ -18,7 +18,7 @@ export default () => {
}) })
mainHandle<string[], LX.UserApi.UserApiInfo[]>(WIN_MAIN_RENDERER_EVENT_NAME.remove_user_api, async({ params: apiIds }) => { mainHandle<string[], LX.UserApi.UserApiInfo[]>(WIN_MAIN_RENDERER_EVENT_NAME.remove_user_api, async({ params: apiIds }) => {
return await removeApi(apiIds) return removeApi(apiIds)
}) })
mainHandle<LX.UserApi.UserApiSetApiParams>(WIN_MAIN_RENDERER_EVENT_NAME.set_user_api, async({ params: apiId }) => { mainHandle<LX.UserApi.UserApiSetApiParams>(WIN_MAIN_RENDERER_EVENT_NAME.set_user_api, async({ params: apiId }) => {
@ -38,7 +38,7 @@ export default () => {
}) })
mainHandle<LX.UserApi.UserApiRequestParams>(WIN_MAIN_RENDERER_EVENT_NAME.request_user_api, async({ params }) => { mainHandle<LX.UserApi.UserApiRequestParams>(WIN_MAIN_RENDERER_EVENT_NAME.request_user_api, async({ params }) => {
return await request(params) return request(params)
}) })
mainHandle<LX.UserApi.UserApiRequestCancelParams>(WIN_MAIN_RENDERER_EVENT_NAME.request_user_api_cancel, async({ params: requestKey }) => { mainHandle<LX.UserApi.UserApiRequestCancelParams>(WIN_MAIN_RENDERER_EVENT_NAME.request_user_api_cancel, async({ params: requestKey }) => {
cancelRequest(requestKey) cancelRequest(requestKey)

View File

@ -4,7 +4,7 @@ import { CMMON_EVENT_NAME, WIN_LYRIC_RENDERER_EVENT_NAME } from '@common/ipcName
type RemoveListener = () => void type RemoveListener = () => void
export const getSetting = async() => { export const getSetting = async() => {
return await rendererInvoke<LX.DesktopLyric.Config>(WIN_LYRIC_RENDERER_EVENT_NAME.get_config) return rendererInvoke<LX.DesktopLyric.Config>(WIN_LYRIC_RENDERER_EVENT_NAME.get_config)
} }
export const updateSetting = async(setting: Partial<LX.DesktopLyric.Config>) => { export const updateSetting = async(setting: Partial<LX.DesktopLyric.Config>) => {
await rendererInvoke(WIN_LYRIC_RENDERER_EVENT_NAME.set_config, setting) await rendererInvoke(WIN_LYRIC_RENDERER_EVENT_NAME.set_config, setting)

View File

@ -215,7 +215,7 @@ export default {
}, () => { }, () => {
cancelScroll = null cancelScroll = null
isScrolling = false isScrolling = false
reject('canceled') reject(new Error('canceled'))
}) })
} else { } else {
dom_scrollContainer.value.scrollTop = scrollTop dom_scrollContainer.value.scrollTop = scrollTop

View File

@ -141,14 +141,14 @@
// } // }
// const scrollTo = async(scrollTop, animate = false) => { // const scrollTo = async(scrollTop, animate = false) => {
// return await new Promise(resolve => { // return new Promise(resolve => {
// if (cancelScroll) { // if (cancelScroll) {
// cancelScroll(resolve) // cancelScroll(resolve)
// } else { // } else {
// resolve() // resolve()
// } // }
// }).then(async() => { // }).then(async() => {
// return await new Promise((resolve, reject) => { // return new Promise((resolve, reject) => {
// if (animate) { // if (animate) {
// isScrolling = true // isScrolling = true
// scrollToValue = scrollTop // scrollToValue = scrollTop
@ -169,7 +169,7 @@
// } // }
// const scrollToIndex = async(index, offset = 0, animate = false) => { // const scrollToIndex = async(index, offset = 0, animate = false) => {
// return await scrollTo(Math.max(index * props.itemHeight + offset, 0), animate) // return scrollTo(Math.max(index * props.itemHeight + offset, 0), animate)
// } // }
// const getScrollTop = () => { // const getScrollTop = () => {

View File

@ -52,7 +52,7 @@ export default {
return return
} }
const { temp_source } = await getSearchSetting() const { temp_source } = await getSearchSetting()
prevTempSearchSource = temp_source prevTempSearchSource ||= temp_source
music[prevTempSearchSource].tipSearch.search(searchText.value).then(list => { music[prevTempSearchSource].tipSearch.search(searchText.value).then(list => {
tipList.value = list tipList.value = list
}).catch(() => {}) }).catch(() => {})

View File

@ -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({

View File

@ -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 })
} }
} }

View File

@ -25,7 +25,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)
@ -50,7 +50,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 }])
@ -69,7 +69,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)
} }
// 尝试读取文件内歌词 // 尝试读取文件内歌词
@ -81,7 +81,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)

View File

@ -55,7 +55,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
@ -70,7 +70,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
@ -88,16 +88,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)
}) })
} }

View File

@ -81,7 +81,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,
@ -225,7 +225,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) console.log('find otherSource', otherSource)
if (otherSource.length) { if (otherSource.length) {
return getOnlineOtherSourceMusicUrl({ return getOnlineOtherSourceMusicUrl({
@ -309,7 +309,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) console.log('find otherSource', otherSource)
if (otherSource.length) { if (otherSource.length) {
return getOnlineOtherSourcePicUrl({ return getOnlineOtherSourcePicUrl({
@ -408,7 +408,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) console.log('find otherSource', otherSource)
if (otherSource.length) { if (otherSource.length) {
return getOnlineOtherSourceLyricInfo({ return getOnlineOtherSourceLyricInfo({

View File

@ -49,7 +49,7 @@ export default () => {
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)
return await Promise.reject(err) return Promise.reject(err)
}), }),
} }
} }

View File

@ -82,7 +82,7 @@ export const getListDetailAll = async(id: string, isRefresh = false): Promise<LX
}) ?? Promise.reject(new Error('source not found' + source)) }) ?? Promise.reject(new Error('source not found' + source))
} }
// eslint-disable-next-line @typescript-eslint/promise-function-async // eslint-disable-next-line @typescript-eslint/promise-function-async
return await loadData(bangId, 1).then((result: ListDetailInfo) => { return loadData(bangId, 1).then((result: ListDetailInfo) => {
if (result.total <= result.limit) return result.list if (result.total <= result.limit) return result.list
let maxPage = Math.ceil(result.total / result.limit) let maxPage = Math.ceil(result.total / result.limit)

View File

@ -155,7 +155,7 @@ export const overwriteListFull = async(data: LX.List.ListActionDataOverwrite) =>
* @param musicInfoId * @param musicInfoId
*/ */
export const checkListExistMusic = async(listId: string, musicInfoId: string): Promise<boolean> => { export const checkListExistMusic = async(listId: string, musicInfoId: string): Promise<boolean> => {
return await rendererInvoke<LX.List.ListActionCheckMusicExistList, boolean>(PLAYER_EVENT_NAME.list_music_check_exist, { listId, musicInfoId }) return rendererInvoke<LX.List.ListActionCheckMusicExistList, boolean>(PLAYER_EVENT_NAME.list_music_check_exist, { listId, musicInfoId })
} }
/** /**
@ -163,7 +163,7 @@ export const checkListExistMusic = async(listId: string, musicInfoId: string): P
* @param musicInfoId * @param musicInfoId
*/ */
export const getMusicExistListIds = async(musicInfoId: string): Promise<string[]> => { export const getMusicExistListIds = async(musicInfoId: string): Promise<string[]> => {
return await rendererInvoke<string, string[]>(PLAYER_EVENT_NAME.list_music_get_list_ids, musicInfoId) return rendererInvoke<string, string[]>(PLAYER_EVENT_NAME.list_music_get_list_ids, musicInfoId)
} }

View File

@ -22,7 +22,7 @@ const saveSearchHistoryListThrottle = throttle((list: LX.List.SearchHistoryList)
export const getHistoryList = async() => { export const getHistoryList = async() => {
if (isInitedSearchHistory || historyList.length) return if (isInitedSearchHistory || historyList.length) return
historyList.push(...(await getSearchHistoryList() ?? [])) historyList.push(...(await getSearchHistoryList() ?? []))
isInitedSearchHistory = true isInitedSearchHistory ||= true
} }
export const addHistoryWord = async(word: string) => { export const addHistoryWord = async(word: string) => {
if (!appSetting['search.isShowHistorySearch']) return if (!appSetting['search.isShowHistorySearch']) return

View File

@ -104,7 +104,7 @@ export const search = async(text: string, page: number, sourceId: LX.OnlineSourc
} }
})) }))
} }
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 []
return setLists(results, page, text) return setLists(results, page, text)
}) })

View File

@ -105,7 +105,7 @@ export const search = async(text: string, page: number, sourceId: LX.OnlineSourc
} }
})) }))
} }
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 []
return setLists(results, page, text) return setLists(results, page, text)
}) })

View File

@ -161,7 +161,7 @@ export const getListDetailAll = async(id: string, source: LX.OnlineSource, isRef
}) ?? Promise.reject(new Error('source not found' + source)) }) ?? Promise.reject(new Error('source not found' + source))
} }
// eslint-disable-next-line @typescript-eslint/promise-function-async // eslint-disable-next-line @typescript-eslint/promise-function-async
return await loadData(id, 1).then((result: ListDetailInfo) => { return loadData(id, 1).then((result: ListDetailInfo) => {
if (result.total <= result.limit) return result.list if (result.total <= result.limit) return result.list
let maxPage = Math.ceil(result.total / result.limit) let maxPage = Math.ceil(result.total / result.limit)

View File

@ -12,12 +12,14 @@ let userEqPresetList: LX.SoundEffect.EQPreset[] | null = null
export const getUserEQPresetList = async() => { export const getUserEQPresetList = async() => {
if (userEqPresetList == null) { if (userEqPresetList == null) {
// eslint-disable-next-line require-atomic-updates
userEqPresetList = reactive(await getUserSoundEffectEQPresetList()) userEqPresetList = reactive(await getUserSoundEffectEQPresetList())
} }
return userEqPresetList return userEqPresetList
} }
export const saveUserEQPreset = async(preset: LX.SoundEffect.EQPreset) => { export const saveUserEQPreset = async(preset: LX.SoundEffect.EQPreset) => {
if (userEqPresetList == null) { if (userEqPresetList == null) {
// eslint-disable-next-line require-atomic-updates
userEqPresetList = reactive(await getUserSoundEffectEQPresetList()) userEqPresetList = reactive(await getUserSoundEffectEQPresetList())
} }
const target = userEqPresetList.find(p => p.id == preset.id) const target = userEqPresetList.find(p => p.id == preset.id)
@ -27,6 +29,7 @@ export const saveUserEQPreset = async(preset: LX.SoundEffect.EQPreset) => {
} }
export const removeUserEQPreset = async(id: string) => { export const removeUserEQPreset = async(id: string) => {
if (userEqPresetList == null) { if (userEqPresetList == null) {
// eslint-disable-next-line require-atomic-updates
userEqPresetList = reactive(await getUserSoundEffectEQPresetList()) userEqPresetList = reactive(await getUserSoundEffectEQPresetList())
} }
const index = userEqPresetList.findIndex(p => p.id == id) const index = userEqPresetList.findIndex(p => p.id == id)
@ -45,6 +48,7 @@ export const getUserConvolutionPresetList = async() => {
} }
export const saveUserConvolutionPreset = async(preset: LX.SoundEffect.ConvolutionPreset) => { export const saveUserConvolutionPreset = async(preset: LX.SoundEffect.ConvolutionPreset) => {
if (userConvolutionPresetList == null) { if (userConvolutionPresetList == null) {
// eslint-disable-next-line require-atomic-updates
userConvolutionPresetList = reactive(await getUserSoundEffectConvolutionPresetList()) userConvolutionPresetList = reactive(await getUserSoundEffectConvolutionPresetList())
} }
const target = userConvolutionPresetList.find(p => p.id == preset.id) const target = userConvolutionPresetList.find(p => p.id == preset.id)
@ -54,6 +58,7 @@ export const saveUserConvolutionPreset = async(preset: LX.SoundEffect.Convolutio
} }
export const removeUserConvolutionPreset = async(id: string) => { export const removeUserConvolutionPreset = async(id: string) => {
if (userConvolutionPresetList == null) { if (userConvolutionPresetList == null) {
// eslint-disable-next-line require-atomic-updates
userConvolutionPresetList = reactive(await getUserSoundEffectConvolutionPresetList()) userConvolutionPresetList = reactive(await getUserSoundEffectConvolutionPresetList())
} }
const index = userConvolutionPresetList.findIndex(p => p.id == id) const index = userConvolutionPresetList.findIndex(p => p.id == id)

View File

@ -44,6 +44,7 @@ const saveViewPrevStateThrottle = throttle((state) => {
}, 1000) }, 1000)
const initPosition = async() => { const initPosition = async() => {
// eslint-disable-next-line require-atomic-updates
listPosition ??= await getListPositionInfoFromData() ?? {} listPosition ??= await getListPositionInfoFromData() ?? {}
} }
export const getListPosition = async(id: string): Promise<number> => { export const getListPosition = async(id: string): Promise<number> => {
@ -74,6 +75,7 @@ const saveListPrevSelectIdThrottle = throttle(() => {
saveListPrevSelectIdFromData(listPrevSelectId) saveListPrevSelectIdFromData(listPrevSelectId)
}, 200) }, 200)
export const getListPrevSelectId = async() => { export const getListPrevSelectId = async() => {
// eslint-disable-next-line require-atomic-updates
listPrevSelectId ??= await getListPrevSelectIdFromData() ?? LIST_IDS.DEFAULT listPrevSelectId ??= await getListPrevSelectIdFromData() ?? LIST_IDS.DEFAULT
return listPrevSelectId ?? LIST_IDS.DEFAULT return listPrevSelectId ?? LIST_IDS.DEFAULT
} }
@ -88,6 +90,7 @@ const saveListUpdateInfo = throttle(() => {
const initListUpdateInfo = async() => { const initListUpdateInfo = async() => {
if (listUpdateInfo == null) { if (listUpdateInfo == null) {
// eslint-disable-next-line require-atomic-updates
listUpdateInfo = await getListUpdateInfoFromData() ?? {} listUpdateInfo = await getListUpdateInfoFromData() ?? {}
for (const [id, info] of Object.entries(listUpdateInfo)) { for (const [id, info] of Object.entries(listUpdateInfo)) {
setUpdateTime(id, info.updateTime ? dateFormat(info.updateTime) : '') setUpdateTime(id, info.updateTime ? dateFormat(info.updateTime) : '')
@ -138,6 +141,7 @@ export const overwriteListUpdateInfo = async(ids: string[]) => {
export const getSearchSetting = async() => { export const getSearchSetting = async() => {
// eslint-disable-next-line require-atomic-updates
searchSetting ??= await getSearchSettingFromData() searchSetting ??= await getSearchSettingFromData()
return { ...searchSetting } return { ...searchSetting }
} }
@ -154,6 +158,7 @@ export const setSearchSetting = async(setting: Partial<typeof DEFAULT_SETTING['s
} }
export const getSongListSetting = async() => { export const getSongListSetting = async() => {
// eslint-disable-next-line require-atomic-updates
songListSetting ??= await getSongListSettingFromData() songListSetting ??= await getSongListSettingFromData()
return { ...songListSetting } return { ...songListSetting }
} }
@ -164,6 +169,7 @@ export const setSongListSetting = async(setting: Partial<typeof DEFAULT_SETTING[
} }
export const getLeaderboardSetting = async() => { export const getLeaderboardSetting = async() => {
// eslint-disable-next-line require-atomic-updates
leaderboardSetting ??= await getLeaderboardSettingFromData() leaderboardSetting ??= await getLeaderboardSettingFromData()
return { ...leaderboardSetting } return { ...leaderboardSetting }
} }

View File

@ -73,5 +73,5 @@ export const deduplicationList = <T extends LX.Music.MusicInfo>(list: T[]): T[]
} }
export const langS2T = async(str: string) => { export const langS2T = async(str: string) => {
return await window.lx.worker.main.langS2t(Buffer.from(str).toString('base64')).then(b64 => Buffer.from(b64, 'base64').toString()) return window.lx.worker.main.langS2t(Buffer.from(str).toString('base64')).then(b64 => Buffer.from(b64, 'base64').toString())
} }

View File

@ -37,7 +37,7 @@ export const clearOtherSource = async() => {
await rendererInvoke(WIN_MAIN_RENDERER_EVENT_NAME.clear_other_source) await rendererInvoke(WIN_MAIN_RENDERER_EVENT_NAME.clear_other_source)
} }
export const getOtherSourceCount = async() => { export const getOtherSourceCount = async() => {
return await rendererInvoke<number>(WIN_MAIN_RENDERER_EVENT_NAME.get_other_source_count) return rendererInvoke<number>(WIN_MAIN_RENDERER_EVENT_NAME.get_other_source_count)
} }
@ -254,7 +254,7 @@ export const saveLeaderboardSetting = (source: typeof DEFAULT_SETTING['leaderboa
}) })
} }
export const getLeaderboardSetting = async() => { export const getLeaderboardSetting = async() => {
return await rendererInvoke<string, typeof DEFAULT_SETTING['leaderboard']>(WIN_MAIN_RENDERER_EVENT_NAME.get_data, DATA_KEYS.leaderboardSetting) ?? { ...DEFAULT_SETTING.leaderboard } return (await rendererInvoke<string, typeof DEFAULT_SETTING['leaderboard']>(WIN_MAIN_RENDERER_EVENT_NAME.get_data, DATA_KEYS.leaderboardSetting)) ?? { ...DEFAULT_SETTING.leaderboard }
} }
export const saveSongListSetting = (setting: typeof DEFAULT_SETTING['songList']) => { export const saveSongListSetting = (setting: typeof DEFAULT_SETTING['songList']) => {
rendererSend(WIN_MAIN_RENDERER_EVENT_NAME.save_data, { rendererSend(WIN_MAIN_RENDERER_EVENT_NAME.save_data, {
@ -263,7 +263,7 @@ export const saveSongListSetting = (setting: typeof DEFAULT_SETTING['songList'])
}) })
} }
export const getSongListSetting = async() => { export const getSongListSetting = async() => {
return await rendererInvoke<string, typeof DEFAULT_SETTING['songList']>(WIN_MAIN_RENDERER_EVENT_NAME.get_data, DATA_KEYS.songListSetting) ?? { ...DEFAULT_SETTING.songList } return (await rendererInvoke<string, typeof DEFAULT_SETTING['songList']>(WIN_MAIN_RENDERER_EVENT_NAME.get_data, DATA_KEYS.songListSetting)) ?? { ...DEFAULT_SETTING.songList }
} }
export const saveSearchSetting = (setting: typeof DEFAULT_SETTING['search']) => { export const saveSearchSetting = (setting: typeof DEFAULT_SETTING['search']) => {
rendererSend(WIN_MAIN_RENDERER_EVENT_NAME.save_data, { rendererSend(WIN_MAIN_RENDERER_EVENT_NAME.save_data, {
@ -272,7 +272,7 @@ export const saveSearchSetting = (setting: typeof DEFAULT_SETTING['search']) =>
}) })
} }
export const getSearchSetting = async() => { export const getSearchSetting = async() => {
return await rendererInvoke<string, typeof DEFAULT_SETTING['search']>(WIN_MAIN_RENDERER_EVENT_NAME.get_data, DATA_KEYS.searchSetting) ?? { ...DEFAULT_SETTING.search } return (await rendererInvoke<string, typeof DEFAULT_SETTING['search']>(WIN_MAIN_RENDERER_EVENT_NAME.get_data, DATA_KEYS.searchSetting)) ?? { ...DEFAULT_SETTING.search }
} }
export const saveViewPrevState = (state: typeof DEFAULT_SETTING['viewPrevState']) => { export const saveViewPrevState = (state: typeof DEFAULT_SETTING['viewPrevState']) => {
rendererSend(WIN_MAIN_RENDERER_EVENT_NAME.save_data, { rendererSend(WIN_MAIN_RENDERER_EVENT_NAME.save_data, {
@ -281,7 +281,7 @@ export const saveViewPrevState = (state: typeof DEFAULT_SETTING['viewPrevState']
}) })
} }
export const getViewPrevState = async() => { export const getViewPrevState = async() => {
return await rendererInvoke<string, typeof DEFAULT_SETTING['viewPrevState']>(WIN_MAIN_RENDERER_EVENT_NAME.get_data, DATA_KEYS.viewPrevState) ?? { ...DEFAULT_SETTING.viewPrevState } return (await rendererInvoke<string, typeof DEFAULT_SETTING['viewPrevState']>(WIN_MAIN_RENDERER_EVENT_NAME.get_data, DATA_KEYS.viewPrevState)) ?? { ...DEFAULT_SETTING.viewPrevState }
} }
@ -292,7 +292,7 @@ export const getSystemFonts = async() => {
} }
export const getUserSoundEffectEQPresetList = async() => { export const getUserSoundEffectEQPresetList = async() => {
return await rendererInvoke<LX.SoundEffect.EQPreset[]>(WIN_MAIN_RENDERER_EVENT_NAME.get_sound_effect_eq_preset) return rendererInvoke<LX.SoundEffect.EQPreset[]>(WIN_MAIN_RENDERER_EVENT_NAME.get_sound_effect_eq_preset)
} }
export const saveUserSoundEffectEQPresetList = (list: LX.SoundEffect.EQPreset[]) => { export const saveUserSoundEffectEQPresetList = (list: LX.SoundEffect.EQPreset[]) => {
@ -300,7 +300,7 @@ export const saveUserSoundEffectEQPresetList = (list: LX.SoundEffect.EQPreset[])
} }
export const getUserSoundEffectConvolutionPresetList = async() => { export const getUserSoundEffectConvolutionPresetList = async() => {
return await rendererInvoke<LX.SoundEffect.ConvolutionPreset[]>(WIN_MAIN_RENDERER_EVENT_NAME.get_sound_effect_convolution_preset) return rendererInvoke<LX.SoundEffect.ConvolutionPreset[]>(WIN_MAIN_RENDERER_EVENT_NAME.get_sound_effect_convolution_preset)
} }
export const saveUserSoundEffectConvolutionPresetList = (list: LX.SoundEffect.ConvolutionPreset[]) => { export const saveUserSoundEffectConvolutionPresetList = (list: LX.SoundEffect.ConvolutionPreset[]) => {
@ -308,7 +308,7 @@ export const saveUserSoundEffectConvolutionPresetList = (list: LX.SoundEffect.Co
} }
// export const getUserSoundEffectPitchShifterPresetList = async() => { // export const getUserSoundEffectPitchShifterPresetList = async() => {
// return await rendererInvoke<LX.SoundEffect.PitchShifterPreset[]>(WIN_MAIN_RENDERER_EVENT_NAME.get_sound_effect_pitch_shifter_preset) // return rendererInvoke<LX.SoundEffect.PitchShifterPreset[]>(WIN_MAIN_RENDERER_EVENT_NAME.get_sound_effect_pitch_shifter_preset)
// } // }
// export const saveUserSoundEffectPitchShifterPresetList = (list: LX.SoundEffect.PitchShifterPreset[]) => { // export const saveUserSoundEffectPitchShifterPresetList = (list: LX.SoundEffect.PitchShifterPreset[]) => {
@ -507,7 +507,7 @@ export const clearLyricRaw = async() => {
} }
export const getLyricRawCount = async() => { export const getLyricRawCount = async() => {
return await rendererInvoke<number>(WIN_MAIN_RENDERER_EVENT_NAME.get_lyric_raw_count) return rendererInvoke<number>(WIN_MAIN_RENDERER_EVENT_NAME.get_lyric_raw_count)
} }
@ -559,7 +559,7 @@ export const clearLyricEdited = async() => {
} }
export const getLyricEditedCount = async() => { export const getLyricEditedCount = async() => {
return await rendererInvoke<number>(WIN_MAIN_RENDERER_EVENT_NAME.get_lyric_edited_count) return rendererInvoke<number>(WIN_MAIN_RENDERER_EVENT_NAME.get_lyric_edited_count)
} }
@ -603,7 +603,7 @@ export const clearMusicUrl = async() => {
} }
export const getMusicUrlCount = async() => { export const getMusicUrlCount = async() => {
return await rendererInvoke<number>(WIN_MAIN_RENDERER_EVENT_NAME.get_music_url_count) return rendererInvoke<number>(WIN_MAIN_RENDERER_EVENT_NAME.get_music_url_count)
} }
/** /**

View File

@ -7,7 +7,7 @@ export const checkDownloadFileAvailable = async(musicInfo: LX.Download.ListItem,
} }
export const checkLocalFileAvailable = async(musicInfo: LX.Music.MusicInfoLocal): Promise<boolean> => { export const checkLocalFileAvailable = async(musicInfo: LX.Music.MusicInfoLocal): Promise<boolean> => {
return await checkPath(musicInfo.meta.filePath) return checkPath(musicInfo.meta.filePath)
} }
/** /**
@ -17,9 +17,9 @@ export const checkLocalFileAvailable = async(musicInfo: LX.Music.MusicInfoLocal)
*/ */
export const checkMusicFileAvailable = async(musicInfo: LX.Music.MusicInfo | LX.Download.ListItem, savePath: string): Promise<boolean> => { export const checkMusicFileAvailable = async(musicInfo: LX.Music.MusicInfo | LX.Download.ListItem, savePath: string): Promise<boolean> => {
if ('progress' in musicInfo) { if ('progress' in musicInfo) {
return await checkDownloadFileAvailable(musicInfo, savePath) return checkDownloadFileAvailable(musicInfo, savePath)
} else if (musicInfo.source == 'local') { } else if (musicInfo.source == 'local') {
return await checkLocalFileAvailable(musicInfo) return checkLocalFileAvailable(musicInfo)
} else return true } else return true
} }
@ -33,7 +33,7 @@ export const getDownloadFilePath = async(musicInfo: LX.Download.ListItem, savePa
} }
export const getLocalFilePath = async(musicInfo: LX.Music.MusicInfoLocal): Promise<string> => { export const getLocalFilePath = async(musicInfo: LX.Music.MusicInfoLocal): Promise<string> => {
return await checkPath(musicInfo.meta.filePath) ? musicInfo.meta.filePath : '' return (await checkPath(musicInfo.meta.filePath)) ? musicInfo.meta.filePath : ''
} }
@ -45,9 +45,9 @@ export const getLocalFilePath = async(musicInfo: LX.Music.MusicInfoLocal): Promi
*/ */
export const getMusicFilePath = async(musicInfo: LX.Music.MusicInfo | LX.Download.ListItem, savePath: string): Promise<string> => { export const getMusicFilePath = async(musicInfo: LX.Music.MusicInfo | LX.Download.ListItem, savePath: string): Promise<string> => {
if ('progress' in musicInfo) { if ('progress' in musicInfo) {
return await getDownloadFilePath(musicInfo, savePath) return getDownloadFilePath(musicInfo, savePath)
} else if (musicInfo.source == 'local') { } else if (musicInfo.source == 'local') {
return await getLocalFilePath(musicInfo) return getLocalFilePath(musicInfo)
} }
return '' return ''
} }

View File

@ -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

View File

@ -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
}) })
}, },

View File

@ -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

View File

@ -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

View File

@ -168,7 +168,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 {

View File

@ -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

View File

@ -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

View File

@ -18,7 +18,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) => {