From e4fa7d79520bdd33de99fbbda91f9107501ffbdd Mon Sep 17 00:00:00 2001 From: YXL Date: Sat, 13 Apr 2024 23:01:24 +0800 Subject: [PATCH] style: fix lint Signed-off-by: YXL --- packages/client/src/utils/ipc.ts | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/packages/client/src/utils/ipc.ts b/packages/client/src/utils/ipc.ts index 516ed0b47..fdad8bf0d 100644 --- a/packages/client/src/utils/ipc.ts +++ b/packages/client/src/utils/ipc.ts @@ -48,7 +48,7 @@ class IPCClient { resolve(true); }) - .catch(() => resolve(false)) + .catch(() => resolve(false)), ); } @@ -92,11 +92,11 @@ const ipc = new IPCClient(ipcServerPath); const ipcB = new IPCClient(ipcBroadcastServerPath); let _nextChann = 0; -const removePicUrl = (items?: PlayTreeItemData[]) => { - if (items) - for (const item of items) { - if ("al" in item && item.al.picUrl.length > 1000) item.al.picUrl = ""; - } +const removePicUrl = (items: PlayTreeItemData[]) => { + for (const item of items) { + if ("al" in item && item.al.picUrl.length > 1000) item.al.picUrl = ""; + } + return items; }; export const IPC = { @@ -105,7 +105,7 @@ export const IPC = { connect: ( ipcHandler: Parameters[0], ipcBHandler: Parameters[0], - retry = 4 + retry = 4, ): Promise<[boolean, boolean]> => Promise.all([ipc.connect(ipcHandler, retry), ipcB.connect(ipcBHandler, retry)]), disconnect: () => { ipc.disconnect(); @@ -129,7 +129,7 @@ export const IPC = { next: next && "mainSong" in next ? next.mainSong : next, play, seek, - }) + }), ) .catch(console.error); }, @@ -160,21 +160,16 @@ export const IPC = { volume: (level: number) => ipc.send({ t: IPCPlayer.volume, level }), speed: (speed: number) => ipc.send({ t: IPCPlayer.speed, speed }), seek: (seekOffset: number) => ipc.send({ t: IPCPlayer.seek, seekOffset }), - add: (items: PlayTreeItemData[], index?: number) => { - removePicUrl(items); - ipcB.send({ t: IPCQueue.add, items, index }); - }, + add: (items: PlayTreeItemData[], index?: number) => ipcB.send({ t: IPCQueue.add, items: removePicUrl(items), index }), clear: () => ipcB.send({ t: IPCQueue.clear }), delete: (id: number | string) => ipcB.send({ t: IPCQueue.delete, id }), fm: (uid: number) => ipc.send({ t: IPCQueue.fm, uid }), - new: (items?: PlayTreeItemData[]) => { - removePicUrl(items); + new: (items?: PlayTreeItemData[]) => ipcB.send( items - ? { t: IPCQueue.new, id: QueueProvider.id + 1, items } - : { t: IPCQueue.new, id: QueueProvider.id, items: QueueProvider.songs } - ); - }, + ? { t: IPCQueue.new, id: QueueProvider.id + 1, items: removePicUrl(items) } + : { t: IPCQueue.new, id: QueueProvider.id, items: QueueProvider.songs }, + ), playSong: (id: number | string) => ipcB.send({ t: IPCQueue.play, id }), random: () => ipcB.send({ t: IPCQueue.new, id: QueueProvider.id + 1, items: QueueProvider.random() }), shift: (index: number) => ipcB.send({ t: IPCQueue.shift, index }),