Skip to content

Commit

Permalink
fix(local): ignore large picUrl
Browse files Browse the repository at this point in the history
Signed-off-by: YXL <[email protected]>
  • Loading branch information
YXL76 committed Apr 13, 2024
1 parent 6b092b8 commit b0b3795
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/client/src/treeview/local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class LocalProvider implements TreeDataProvider<Content> {
mv: undefined,
};

if (common.picture?.length) {
if (common.picture?.length && common.picture.length < 1024) {
const [{ data, format }] = common.picture;
item.al.picUrl = `data:${format};base64,${data.toString("base64")}`;
}
Expand Down
12 changes: 3 additions & 9 deletions packages/client/src/utils/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,6 @@ const ipc = new IPCClient<IPCClientMsg, IPCServerMsg>(ipcServerPath);
const ipcB = new IPCClient<IPCBroadcastMsg>(ipcBroadcastServerPath);

let _nextChann = 0;
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 = {
requestPool: <CSConnPool>new Map(),
Expand Down Expand Up @@ -160,14 +154,14 @@ 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) => ipcB.send({ t: IPCQueue.add, items: removePicUrl(items), index }),
add: (items: readonly PlayTreeItemData[], index?: number) => ipcB.send({ t: IPCQueue.add, 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[]) =>
new: (items?: readonly PlayTreeItemData[]) =>
ipcB.send(
items
? { t: IPCQueue.new, id: QueueProvider.id + 1, items: removePicUrl(items) }
? { t: IPCQueue.new, id: QueueProvider.id + 1, items }
: { t: IPCQueue.new, id: QueueProvider.id, items: QueueProvider.songs },
),
playSong: (id: number | string) => ipcB.send({ t: IPCQueue.play, id }),
Expand Down

0 comments on commit b0b3795

Please sign in to comment.