lint code
parent
358142c1cc
commit
2fff8652ca
|
@ -5,8 +5,8 @@ const baseRule = {
|
|||
'space-before-function-paren': ['error', 'never'],
|
||||
'no-var': 'error',
|
||||
'no-fallthrough': 'off',
|
||||
'prefer-promise-reject-errors': 'off',
|
||||
eqeqeq: 'off',
|
||||
'require-atomic-updates': ['error', { allowProperties: true }],
|
||||
'no-multiple-empty-lines': [1, { max: 2 }],
|
||||
'comma-dangle': [2, 'always-multiline'],
|
||||
'standard/no-callback-literal': 'off',
|
||||
|
|
|
@ -16,7 +16,7 @@ module.exports = async(context) => {
|
|||
const resPath = `${appOutDir}/${productFilename}.app/Contents/Resources`
|
||||
|
||||
// 创建APP语言包文件
|
||||
return await Promise.all(
|
||||
return Promise.all(
|
||||
Object.entries(macLanguagesInfoPlistStrings).map(([lang, config]) => {
|
||||
let infos = Object.entries(config).map(([k, v]) => `"${k}" = "${v}";`).join('\n')
|
||||
return fs.writeFile(`${resPath}/${lang}.lproj/InfoPlist.strings`, infos)
|
||||
|
|
|
@ -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 {
|
||||
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 {
|
||||
ipcMain.handleOnce(name, async(event, params) => {
|
||||
return await listener({ event, params })
|
||||
return listener({ event, params })
|
||||
})
|
||||
}
|
||||
export const mainHandleRemove = (name: string) => {
|
||||
|
|
|
@ -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, 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
|
||||
|
|
|
@ -15,7 +15,7 @@ export const dirname = (p: string): string => path.dirname(p)
|
|||
* @param {*} path 路径
|
||||
*/
|
||||
export const checkPath = async(path: string): Promise<boolean> => {
|
||||
return await new Promise(resolve => {
|
||||
return new Promise(resolve => {
|
||||
if (!path) {
|
||||
resolve(false)
|
||||
return
|
||||
|
@ -31,7 +31,7 @@ export const checkPath = async(path: string): Promise<boolean> => {
|
|||
}
|
||||
|
||||
export const getFileStats = async(path: string): Promise<fs.Stats | null> => {
|
||||
return await new Promise(resolve => {
|
||||
return new Promise(resolve => {
|
||||
if (!path) {
|
||||
resolve(null)
|
||||
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 gzipData = async(str: string): Promise<Buffer> => {
|
||||
return await new Promise((resolve, reject) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
gzip(str, (err, result) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
|
@ -109,7 +109,7 @@ export const gzipData = async(str: string): Promise<Buffer> => {
|
|||
}
|
||||
|
||||
export const gunzipData = async(buf: Buffer): Promise<string> => {
|
||||
return await new Promise((resolve, reject) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
gunzip(buf, (err, result) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
|
|
|
@ -253,7 +253,7 @@ export const initAppSetting = async() => {
|
|||
}
|
||||
// global.lx.theme = getTheme()
|
||||
|
||||
isInitialized = true
|
||||
isInitialized ||= true
|
||||
}
|
||||
|
||||
export const quitApp = () => {
|
||||
|
|
|
@ -20,7 +20,7 @@ export default () => {
|
|||
})
|
||||
|
||||
mainHandle<string[]>(CMMON_EVENT_NAME.get_system_fonts, async() => {
|
||||
return await getFonts()
|
||||
return getFonts()
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import { PLAYER_EVENT_NAME } from '@common/ipcNames'
|
|||
// 列表操作事件(公共,只注册一次)
|
||||
export default () => {
|
||||
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 }) => {
|
||||
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)
|
||||
})
|
||||
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 } }) => {
|
||||
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)
|
||||
})
|
||||
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 }) => {
|
||||
return await global.lx.worker.dbService.getMusicExistListIds(musicInfoId)
|
||||
return global.lx.worker.dbService.getMusicExistListIds(musicInfoId)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -16,8 +16,10 @@ export const initClientInfo = async() => {
|
|||
if (syncAuthKeys != null) return
|
||||
const syncAuthKeysFilePath = path.join(global.lxDataPath, File.clientDataPath, File.syncAuthKeysJSON)
|
||||
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())
|
||||
} else {
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
syncAuthKeys = {}
|
||||
const syncDataPath = path.join(global.lxDataPath, File.clientDataPath)
|
||||
if (!await exists(syncDataPath)) {
|
||||
|
|
|
@ -12,6 +12,7 @@ const sendListAction = async(wss: LX.Sync.Server.SocketServer, action: LX.Sync.L
|
|||
let key = ''
|
||||
for (const client of wss.clients) {
|
||||
if (!client.moduleReadys?.list) continue
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
if (!key) key = await userSpace.listManage.createSnapshot()
|
||||
void client.remoteQueueList.onListSyncAction(action).then(async() => {
|
||||
return userSpace.listManage.updateDeviceSnapshotKey(client.keyInfo.clientId, key)
|
||||
|
|
|
@ -25,8 +25,10 @@ export const initServerInfo = async() => {
|
|||
if (serverInfo != null) return
|
||||
const serverInfoFilePath = path.join(global.lxDataPath, File.serverDataPath, File.serverInfoJSON)
|
||||
if (await exists(serverInfoFilePath)) {
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
serverInfo = JSON.parse((await fs.promises.readFile(serverInfoFilePath)).toString())
|
||||
} else {
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
serverInfo = {
|
||||
serverId: randomBytes(4 * 4).toString('base64'),
|
||||
version: 2,
|
||||
|
|
|
@ -28,7 +28,7 @@ export const setApi = async(id: string) => {
|
|||
}
|
||||
const apiList = getUserApis()
|
||||
if (!apiList.some(a => a.id === id)) return
|
||||
userApiId = id
|
||||
userApiId ||= id
|
||||
await loadApi(id)
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ export const createWindow = async(userApi: LX.UserApi.UserApiInfo) => {
|
|||
dir ??= process.env.NODE_ENV !== 'production' ? webpackUserApiPath : path.join(encodePath(__dirname), 'userApi')
|
||||
|
||||
if (!html) {
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
html = await fs.promises.readFile(path.join(dir, 'renderer/user-api.html'), 'utf8')
|
||||
}
|
||||
const preloadUrl = process.env.NODE_ENV !== 'production'
|
||||
|
|
|
@ -128,7 +128,7 @@ export const sendEvent = <T = any>(name: string, params?: T) => {
|
|||
|
||||
export const showSelectDialog = async(options: Electron.OpenDialogOptions) => {
|
||||
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) => {
|
||||
if (!browserWindow) return
|
||||
|
@ -140,7 +140,7 @@ export const showDialog = ({ type, message, detail }: Electron.MessageBoxSyncOpt
|
|||
}
|
||||
export const showSaveDialog = async(options: Electron.SaveDialogOptions) => {
|
||||
if (!browserWindow) throw new Error('main window is undefined')
|
||||
return await dialog.showSaveDialog(browserWindow, options)
|
||||
return dialog.showSaveDialog(browserWindow, options)
|
||||
}
|
||||
export const minimize = () => {
|
||||
if (!browserWindow) return
|
||||
|
@ -256,7 +256,7 @@ export const clearCache = async() => {
|
|||
|
||||
export const getCacheSize = async() => {
|
||||
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 => {
|
||||
|
|
|
@ -70,7 +70,7 @@ export default () => {
|
|||
|
||||
// 选择目录
|
||||
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 }) => {
|
||||
|
@ -78,7 +78,7 @@ export default () => {
|
|||
})
|
||||
// 显示保存弹窗
|
||||
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() => {
|
||||
return await getCacheSize()
|
||||
return getCacheSize()
|
||||
})
|
||||
|
||||
mainOn(WIN_MAIN_RENDERER_EVENT_NAME.open_dev_tools, () => {
|
||||
|
|
|
@ -4,7 +4,7 @@ import { mainHandle } from '@common/mainIpc'
|
|||
|
||||
export default () => {
|
||||
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 } }) => {
|
||||
await global.lx.worker.dbService.downloadInfoSave(list, addMusicLocationType)
|
||||
|
|
|
@ -4,7 +4,7 @@ import { mainHandle } from '@common/mainIpc'
|
|||
import { WIN_MAIN_RENDERER_EVENT_NAME } from '@common/ipcNames'
|
||||
|
||||
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) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
|
|
|
@ -7,12 +7,12 @@ export default () => {
|
|||
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) ??
|
||||
// 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 }) => {
|
||||
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 } }) => {
|
||||
await global.lx.worker.dbService.rawLyricAdd(id, lyrics)
|
||||
|
@ -21,12 +21,12 @@ export default () => {
|
|||
await global.lx.worker.dbService.rawLyricClear()
|
||||
})
|
||||
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 }) => {
|
||||
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 } }) => {
|
||||
await global.lx.worker.dbService.editedLyricUpdateAddAndUpdate(id, lyrics)
|
||||
|
@ -38,13 +38,13 @@ export default () => {
|
|||
await global.lx.worker.dbService.editedLyricClear()
|
||||
})
|
||||
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=========================
|
||||
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 } }) => {
|
||||
await global.lx.worker.dbService.musicUrlSave([{ id, url }])
|
||||
|
@ -53,12 +53,12 @@ export default () => {
|
|||
await global.lx.worker.dbService.musicUrlClear()
|
||||
})
|
||||
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 }) => {
|
||||
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 } }) => {
|
||||
await global.lx.worker.dbService.musicInfoOtherSourceAdd(id, list)
|
||||
|
@ -67,7 +67,7 @@ export default () => {
|
|||
await global.lx.worker.dbService.musicInfoOtherSourceClear()
|
||||
})
|
||||
mainHandle(WIN_MAIN_RENDERER_EVENT_NAME.get_other_source_count, async() => {
|
||||
return await global.lx.worker.dbService.musicInfoOtherSourceCount()
|
||||
return global.lx.worker.dbService.musicInfoOtherSourceCount()
|
||||
})
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ export default () => {
|
|||
})
|
||||
|
||||
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 }) => {
|
||||
|
@ -38,7 +38,7 @@ export default () => {
|
|||
})
|
||||
|
||||
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 }) => {
|
||||
cancelRequest(requestKey)
|
||||
|
|
|
@ -4,7 +4,7 @@ import { CMMON_EVENT_NAME, WIN_LYRIC_RENDERER_EVENT_NAME } from '@common/ipcName
|
|||
type RemoveListener = () => void
|
||||
|
||||
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>) => {
|
||||
await rendererInvoke(WIN_LYRIC_RENDERER_EVENT_NAME.set_config, setting)
|
||||
|
|
|
@ -215,7 +215,7 @@ export default {
|
|||
}, () => {
|
||||
cancelScroll = null
|
||||
isScrolling = false
|
||||
reject('canceled')
|
||||
reject(new Error('canceled'))
|
||||
})
|
||||
} else {
|
||||
dom_scrollContainer.value.scrollTop = scrollTop
|
||||
|
|
|
@ -141,14 +141,14 @@
|
|||
// }
|
||||
|
||||
// const scrollTo = async(scrollTop, animate = false) => {
|
||||
// return await new Promise(resolve => {
|
||||
// return new Promise(resolve => {
|
||||
// if (cancelScroll) {
|
||||
// cancelScroll(resolve)
|
||||
// } else {
|
||||
// resolve()
|
||||
// }
|
||||
// }).then(async() => {
|
||||
// return await new Promise((resolve, reject) => {
|
||||
// return new Promise((resolve, reject) => {
|
||||
// if (animate) {
|
||||
// isScrolling = true
|
||||
// scrollToValue = scrollTop
|
||||
|
@ -169,7 +169,7 @@
|
|||
// }
|
||||
|
||||
// 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 = () => {
|
||||
|
|
|
@ -52,7 +52,7 @@ export default {
|
|||
return
|
||||
}
|
||||
const { temp_source } = await getSearchSetting()
|
||||
prevTempSearchSource = temp_source
|
||||
prevTempSearchSource ||= temp_source
|
||||
music[prevTempSearchSource].tipSearch.search(searchText.value).then(list => {
|
||||
tipList.value = list
|
||||
}).catch(() => {})
|
||||
|
|
|
@ -18,7 +18,7 @@ export const getMusicUrl = async({ musicInfo, isRefresh, onToggleSource = () =>
|
|||
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 = () => {} }: {
|
||||
|
@ -38,7 +38,7 @@ export const getPicUrl = async({ musicInfo, isRefresh, listId, onToggleSource =
|
|||
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)
|
||||
|
||||
return url
|
||||
|
@ -52,7 +52,7 @@ export const getLyricInfo = async({ musicInfo, isRefresh, onToggleSource = () =>
|
|||
}): Promise<LX.Player.LyricInfo> => {
|
||||
if (!isRefresh) {
|
||||
const lyricInfo = await getCachedLyricInfo(musicInfo.metadata.musicInfo)
|
||||
if (lyricInfo) return await buildLyricInfo(lyricInfo)
|
||||
if (lyricInfo) return buildLyricInfo(lyricInfo)
|
||||
}
|
||||
|
||||
return getOnlineLyricInfo({
|
||||
|
|
|
@ -31,11 +31,11 @@ export const getMusicUrl = async({
|
|||
onToggleSource?: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
||||
}): Promise<string> => {
|
||||
if ('progress' in musicInfo) {
|
||||
return await getDownloadMusicUrl({ musicInfo, isRefresh, onToggleSource })
|
||||
return getDownloadMusicUrl({ musicInfo, isRefresh, onToggleSource })
|
||||
} else if (musicInfo.source == 'local') {
|
||||
return await getLocalMusicUrl({ musicInfo, isRefresh, onToggleSource })
|
||||
return getLocalMusicUrl({ musicInfo, isRefresh, onToggleSource })
|
||||
} 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
|
||||
}): Promise<string> => {
|
||||
if ('progress' in musicInfo) {
|
||||
return await getDownloadPicUrl({ musicInfo, isRefresh, listId, onToggleSource })
|
||||
return getDownloadPicUrl({ musicInfo, isRefresh, listId, onToggleSource })
|
||||
} else if (musicInfo.source == 'local') {
|
||||
return await getLocalPicUrl({ musicInfo, isRefresh, listId, onToggleSource })
|
||||
return getLocalPicUrl({ musicInfo, isRefresh, listId, onToggleSource })
|
||||
} 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
|
||||
}): Promise<LX.Player.LyricInfo> => {
|
||||
if ('progress' in musicInfo) {
|
||||
return await getDownloadLyricInfo({ musicInfo, isRefresh, onToggleSource })
|
||||
return getDownloadLyricInfo({ musicInfo, isRefresh, onToggleSource })
|
||||
} else if (musicInfo.source == 'local') {
|
||||
return await getLocalLyricInfo({ musicInfo, isRefresh, onToggleSource })
|
||||
return getLocalLyricInfo({ musicInfo, isRefresh, onToggleSource })
|
||||
} else {
|
||||
return await getOnlineLyricInfo({ musicInfo, isRefresh, onToggleSource })
|
||||
return getOnlineLyricInfo({ musicInfo, isRefresh, onToggleSource })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ export const getMusicUrl = async({ musicInfo, isRefresh, onToggleSource = () =>
|
|||
onToggleSource()
|
||||
const otherSource = await getOtherSource(musicInfo)
|
||||
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)
|
||||
if (!isFromCache) void saveMusicUrl(targetMusicInfo, targetQuality, url)
|
||||
|
||||
|
@ -50,7 +50,7 @@ export const getPicUrl = async({ musicInfo, listId, isRefresh, onToggleSource =
|
|||
onToggleSource()
|
||||
const otherSource = await getOtherSource(musicInfo)
|
||||
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) {
|
||||
musicInfo.meta.picUrl = url
|
||||
void updateListMusics([{ id: listId, musicInfo }])
|
||||
|
@ -69,7 +69,7 @@ export const getLyricInfo = async({ musicInfo, isRefresh, onToggleSource = () =>
|
|||
const lyricInfo = await getCachedLyricInfo(musicInfo)
|
||||
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)
|
||||
if (!otherSource.length) throw new Error('source not found')
|
||||
// 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)
|
||||
|
||||
if (isFromCache) return buildLyricInfo(lyricInfo)
|
||||
|
|
|
@ -55,7 +55,7 @@ export const getMusicUrl = async({ musicInfo, quality, isRefresh, allowToggleSou
|
|||
const cachedUrl = await getStoreMusicUrl(musicInfo, targetQuality)
|
||||
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)
|
||||
void saveMusicUrl(musicInfo, targetQuality, url)
|
||||
return url
|
||||
|
@ -70,7 +70,7 @@ export const getPicUrl = async({ musicInfo, listId, isRefresh, allowToggleSource
|
|||
onToggleSource?: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
||||
}): Promise<string> => {
|
||||
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
|
||||
if (listId) {
|
||||
musicInfo.meta.picUrl = url
|
||||
|
@ -88,16 +88,16 @@ export const getLyricInfo = async({ musicInfo, isRefresh, allowToggleSource = tr
|
|||
}): Promise<LX.Player.LyricInfo> => {
|
||||
if (!isRefresh) {
|
||||
const lyricInfo = await getCachedLyricInfo(musicInfo)
|
||||
if (lyricInfo) return await buildLyricInfo(lyricInfo)
|
||||
if (lyricInfo) return buildLyricInfo(lyricInfo)
|
||||
}
|
||||
|
||||
// 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
|
||||
if (isFromCache) return await buildLyricInfo(lyricInfo)
|
||||
if (isFromCache) return buildLyricInfo(lyricInfo)
|
||||
if (targetMusicInfo.id == musicInfo.id) void saveLyric(musicInfo, lyricInfo)
|
||||
else void saveLyric(targetMusicInfo, lyricInfo)
|
||||
|
||||
return await buildLyricInfo(lyricInfo)
|
||||
return buildLyricInfo(lyricInfo)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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.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 ? {
|
||||
lyric: lyric_raw,
|
||||
tlyric: tlyric_raw,
|
||||
|
@ -225,7 +225,7 @@ export const handleGetOnlineMusicUrl = async({ musicInfo, quality, onToggleSourc
|
|||
if (!allowToggleSource || err.message == requestMsg.tooManyRequests) throw err
|
||||
onToggleSource()
|
||||
// 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)
|
||||
if (otherSource.length) {
|
||||
return getOnlineOtherSourceMusicUrl({
|
||||
|
@ -309,7 +309,7 @@ export const handleGetOnlinePicUrl = async({ musicInfo, isRefresh, onToggleSourc
|
|||
if (!allowToggleSource) throw err
|
||||
onToggleSource()
|
||||
// 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)
|
||||
if (otherSource.length) {
|
||||
return getOnlineOtherSourcePicUrl({
|
||||
|
@ -408,7 +408,7 @@ export const handleGetOnlineLyricInfo = async({ musicInfo, onToggleSource, isRef
|
|||
|
||||
onToggleSource()
|
||||
// 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)
|
||||
if (otherSource.length) {
|
||||
return getOnlineOtherSourceLyricInfo({
|
||||
|
|
|
@ -49,7 +49,7 @@ export default () => {
|
|||
return { type, url: res.data.url }
|
||||
}).catch(async err => {
|
||||
console.log(err.message)
|
||||
return await Promise.reject(err)
|
||||
return Promise.reject(err)
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ export const getListDetailAll = async(id: string, isRefresh = false): Promise<LX
|
|||
}) ?? Promise.reject(new Error('source not found' + source))
|
||||
}
|
||||
// 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
|
||||
|
||||
let maxPage = Math.ceil(result.total / result.limit)
|
||||
|
|
|
@ -155,7 +155,7 @@ export const overwriteListFull = async(data: LX.List.ListActionDataOverwrite) =>
|
|||
* @param musicInfoId
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ const saveSearchHistoryListThrottle = throttle((list: LX.List.SearchHistoryList)
|
|||
export const getHistoryList = async() => {
|
||||
if (isInitedSearchHistory || historyList.length) return
|
||||
historyList.push(...(await getSearchHistoryList() ?? []))
|
||||
isInitedSearchHistory = true
|
||||
isInitedSearchHistory ||= true
|
||||
}
|
||||
export const addHistoryWord = async(word: string) => {
|
||||
if (!appSetting['search.isShowHistorySearch']) return
|
||||
|
|
|
@ -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 []
|
||||
return setLists(results, page, text)
|
||||
})
|
||||
|
|
|
@ -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 []
|
||||
return setLists(results, page, text)
|
||||
})
|
||||
|
|
|
@ -161,7 +161,7 @@ export const getListDetailAll = async(id: string, source: LX.OnlineSource, isRef
|
|||
}) ?? Promise.reject(new Error('source not found' + source))
|
||||
}
|
||||
// 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
|
||||
|
||||
let maxPage = Math.ceil(result.total / result.limit)
|
||||
|
|
|
@ -12,12 +12,14 @@ let userEqPresetList: LX.SoundEffect.EQPreset[] | null = null
|
|||
|
||||
export const getUserEQPresetList = async() => {
|
||||
if (userEqPresetList == null) {
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
userEqPresetList = reactive(await getUserSoundEffectEQPresetList())
|
||||
}
|
||||
return userEqPresetList
|
||||
}
|
||||
export const saveUserEQPreset = async(preset: LX.SoundEffect.EQPreset) => {
|
||||
if (userEqPresetList == null) {
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
userEqPresetList = reactive(await getUserSoundEffectEQPresetList())
|
||||
}
|
||||
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) => {
|
||||
if (userEqPresetList == null) {
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
userEqPresetList = reactive(await getUserSoundEffectEQPresetList())
|
||||
}
|
||||
const index = userEqPresetList.findIndex(p => p.id == id)
|
||||
|
@ -45,6 +48,7 @@ export const getUserConvolutionPresetList = async() => {
|
|||
}
|
||||
export const saveUserConvolutionPreset = async(preset: LX.SoundEffect.ConvolutionPreset) => {
|
||||
if (userConvolutionPresetList == null) {
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
userConvolutionPresetList = reactive(await getUserSoundEffectConvolutionPresetList())
|
||||
}
|
||||
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) => {
|
||||
if (userConvolutionPresetList == null) {
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
userConvolutionPresetList = reactive(await getUserSoundEffectConvolutionPresetList())
|
||||
}
|
||||
const index = userConvolutionPresetList.findIndex(p => p.id == id)
|
||||
|
|
|
@ -44,6 +44,7 @@ const saveViewPrevStateThrottle = throttle((state) => {
|
|||
}, 1000)
|
||||
|
||||
const initPosition = async() => {
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
listPosition ??= await getListPositionInfoFromData() ?? {}
|
||||
}
|
||||
export const getListPosition = async(id: string): Promise<number> => {
|
||||
|
@ -74,6 +75,7 @@ const saveListPrevSelectIdThrottle = throttle(() => {
|
|||
saveListPrevSelectIdFromData(listPrevSelectId)
|
||||
}, 200)
|
||||
export const getListPrevSelectId = async() => {
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
listPrevSelectId ??= await getListPrevSelectIdFromData() ?? LIST_IDS.DEFAULT
|
||||
return listPrevSelectId ?? LIST_IDS.DEFAULT
|
||||
}
|
||||
|
@ -88,6 +90,7 @@ const saveListUpdateInfo = throttle(() => {
|
|||
|
||||
const initListUpdateInfo = async() => {
|
||||
if (listUpdateInfo == null) {
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
listUpdateInfo = await getListUpdateInfoFromData() ?? {}
|
||||
for (const [id, info] of Object.entries(listUpdateInfo)) {
|
||||
setUpdateTime(id, info.updateTime ? dateFormat(info.updateTime) : '')
|
||||
|
@ -138,6 +141,7 @@ export const overwriteListUpdateInfo = async(ids: string[]) => {
|
|||
|
||||
|
||||
export const getSearchSetting = async() => {
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
searchSetting ??= await getSearchSettingFromData()
|
||||
return { ...searchSetting }
|
||||
}
|
||||
|
@ -154,6 +158,7 @@ export const setSearchSetting = async(setting: Partial<typeof DEFAULT_SETTING['s
|
|||
}
|
||||
|
||||
export const getSongListSetting = async() => {
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
songListSetting ??= await getSongListSettingFromData()
|
||||
return { ...songListSetting }
|
||||
}
|
||||
|
@ -164,6 +169,7 @@ export const setSongListSetting = async(setting: Partial<typeof DEFAULT_SETTING[
|
|||
}
|
||||
|
||||
export const getLeaderboardSetting = async() => {
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
leaderboardSetting ??= await getLeaderboardSettingFromData()
|
||||
return { ...leaderboardSetting }
|
||||
}
|
||||
|
|
|
@ -73,5 +73,5 @@ export const deduplicationList = <T extends LX.Music.MusicInfo>(list: T[]): T[]
|
|||
}
|
||||
|
||||
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())
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ export const clearOtherSource = async() => {
|
|||
await rendererInvoke(WIN_MAIN_RENDERER_EVENT_NAME.clear_other_source)
|
||||
}
|
||||
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() => {
|
||||
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']) => {
|
||||
rendererSend(WIN_MAIN_RENDERER_EVENT_NAME.save_data, {
|
||||
|
@ -263,7 +263,7 @@ export const saveSongListSetting = (setting: typeof DEFAULT_SETTING['songList'])
|
|||
})
|
||||
}
|
||||
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']) => {
|
||||
rendererSend(WIN_MAIN_RENDERER_EVENT_NAME.save_data, {
|
||||
|
@ -272,7 +272,7 @@ export const saveSearchSetting = (setting: typeof DEFAULT_SETTING['search']) =>
|
|||
})
|
||||
}
|
||||
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']) => {
|
||||
rendererSend(WIN_MAIN_RENDERER_EVENT_NAME.save_data, {
|
||||
|
@ -281,7 +281,7 @@ export const saveViewPrevState = (state: typeof DEFAULT_SETTING['viewPrevState']
|
|||
})
|
||||
}
|
||||
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() => {
|
||||
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[]) => {
|
||||
|
@ -300,7 +300,7 @@ export const saveUserSoundEffectEQPresetList = (list: LX.SoundEffect.EQPreset[])
|
|||
}
|
||||
|
||||
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[]) => {
|
||||
|
@ -308,7 +308,7 @@ export const saveUserSoundEffectConvolutionPresetList = (list: LX.SoundEffect.Co
|
|||
}
|
||||
|
||||
// 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[]) => {
|
||||
|
@ -507,7 +507,7 @@ export const clearLyricRaw = 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() => {
|
||||
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() => {
|
||||
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)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,7 +7,7 @@ export const checkDownloadFileAvailable = async(musicInfo: LX.Download.ListItem,
|
|||
}
|
||||
|
||||
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> => {
|
||||
if ('progress' in musicInfo) {
|
||||
return await checkDownloadFileAvailable(musicInfo, savePath)
|
||||
return checkDownloadFileAvailable(musicInfo, savePath)
|
||||
} else if (musicInfo.source == 'local') {
|
||||
return await checkLocalFileAvailable(musicInfo)
|
||||
return checkLocalFileAvailable(musicInfo)
|
||||
} 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> => {
|
||||
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> => {
|
||||
if ('progress' in musicInfo) {
|
||||
return await getDownloadFilePath(musicInfo, savePath)
|
||||
return getDownloadFilePath(musicInfo, savePath)
|
||||
} else if (musicInfo.source == 'local') {
|
||||
return await getLocalFilePath(musicInfo)
|
||||
return getLocalFilePath(musicInfo)
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ export default {
|
|||
// })
|
||||
// requestObj.promise = requestObj.promise.then(({ body, statusCode }) => {
|
||||
// if (statusCode !== 200) {
|
||||
// if (tryNum > 5) return Promise.reject('歌词获取失败')
|
||||
// if (tryNum > 5) return Promise.reject(new Error('歌词获取失败'))
|
||||
// let tryRequestObj = this.getLyric(songInfo, ++tryNum)
|
||||
// requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
||||
// return tryRequestObj.promise
|
||||
|
@ -98,7 +98,7 @@ export default {
|
|||
})
|
||||
requestObj.promise = requestObj.promise.then(({ body, statusCode }) => {
|
||||
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)
|
||||
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
||||
return tryRequestObj.promise
|
||||
|
@ -121,7 +121,7 @@ export default {
|
|||
})
|
||||
requestObj.promise = requestObj.promise.then(({ body, statusCode }) => {
|
||||
if (statusCode !== 200) {
|
||||
if (tryNum > 5) return Promise.reject('歌词获取失败')
|
||||
if (tryNum > 5) return Promise.reject(new Error('歌词获取失败'))
|
||||
let tryRequestObj = this.getLyric(id, accessKey, ++tryNum)
|
||||
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
||||
return tryRequestObj.promise
|
||||
|
|
|
@ -38,10 +38,10 @@ export default {
|
|||
},
|
||||
)
|
||||
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
|
||||
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
|
||||
})
|
||||
},
|
||||
|
|
|
@ -57,7 +57,7 @@ const mrcTools = {
|
|||
})
|
||||
return requestObj.promise.then(({ statusCode, 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)
|
||||
})
|
||||
},
|
||||
|
@ -84,7 +84,7 @@ const mrcTools = {
|
|||
let p
|
||||
if (info.mrcUrl) p = this.getMrc(info.mrcUrl)
|
||||
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]) => {
|
||||
lrcInfo.tlyric = tlyric
|
||||
return lrcInfo
|
||||
|
@ -102,7 +102,7 @@ export default {
|
|||
let requestObj = httpFetch(songInfo.lrcUrl)
|
||||
requestObj.promise = requestObj.promise.then(({ body, statusCode }) => {
|
||||
if (statusCode !== 200) {
|
||||
if (tryNum > 5) return Promise.reject('歌词获取失败')
|
||||
if (tryNum > 5) return Promise.reject(new Error('歌词获取失败'))
|
||||
let tryRequestObj = this.getLyricWeb(songInfo, ++tryNum)
|
||||
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
||||
return tryRequestObj.promise
|
||||
|
|
|
@ -10,7 +10,7 @@ export default {
|
|||
})
|
||||
requestObj.promise.then(({ body }) => {
|
||||
if (body.returnCode !== '000000') {
|
||||
if (tryNum > 5) return Promise.reject('图片获取失败')
|
||||
if (tryNum > 5) return Promise.reject(new Error('图片获取失败'))
|
||||
let tryRequestObj = this.getPic(songId, ++tryNum)
|
||||
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
||||
return tryRequestObj.promise
|
||||
|
|
|
@ -168,7 +168,7 @@ export default {
|
|||
// return this._requestObj_list.promise.then(({ statusCode, body }) => {
|
||||
// if (statusCode !== 200) return this.getList(sortId, tagId, page)
|
||||
// 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 => {
|
||||
// let info = item.match(this.regExps.listInfo)
|
||||
// return {
|
||||
|
|
|
@ -33,7 +33,7 @@ export default (songmid) => {
|
|||
})
|
||||
return requestObj.promise.then(({ 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
|
||||
if (!item.file?.media_mid) return null
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ export default songmid => {
|
|||
})
|
||||
requestObj.promise = requestObj.promise.then(({ 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 requestObj
|
||||
|
|
|
@ -18,7 +18,7 @@ const address = [
|
|||
]
|
||||
|
||||
const request = async(url, retryNum = 0) => {
|
||||
return await new Promise((resolve, reject) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
httpGet(url, {
|
||||
timeout: 10000,
|
||||
}, (err, resp, body) => {
|
||||
|
|
Loading…
Reference in New Issue