lint code
This commit is contained in:
+1
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user