From 77c2e962ecba6819f5288630c9eeeb9a2284b05e Mon Sep 17 00:00:00 2001 From: lyswhut Date: Fri, 23 Aug 2024 20:06:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9C=AC=E5=9C=B0=E6=AD=8C?= =?UTF-8?q?=E6=9B=B2=E5=86=85=E5=B5=8C=E5=B0=81=E9=9D=A2=E8=BF=87=E5=A4=A7?= =?UTF-8?q?=E6=97=B6=E7=9A=84=E5=8A=A0=E8=BD=BD=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish/changeLog.md | 3 ++- src/renderer/worker/main/music.ts | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/publish/changeLog.md b/publish/changeLog.md index 50be56b3..565e02ec 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -1,6 +1,6 @@ ### 新增 -- 新增 是否将歌词显示在状态栏 设置,默认关闭,该功能只在 MacOS 下可用(#1940) +- 新增 设置-播放设置-是否将歌词显示在状态栏 设置,默认关闭,该功能只在 MacOS 下可用(#1940) - 新增设置-播放详情页设置-延迟歌词滚动设置(#1985) - 新增鼠标在音量按钮使用滚轮时可以调整音量大小的功能(#2000) - 新增设置-下载设置-同时下载任务数设置(#1498) @@ -10,6 +10,7 @@ - 优化侧栏图标显示,修复图标可能被裁切的问题(#1960) - 托盘图标添加当前播放歌曲名字显示 +- 优化本地歌曲内嵌封面过大时的加载方式 ### 修复 diff --git a/src/renderer/worker/main/music.ts b/src/renderer/worker/main/music.ts index 29e5b3fd..4f2951cf 100644 --- a/src/renderer/worker/main/music.ts +++ b/src/renderer/worker/main/music.ts @@ -1,9 +1,30 @@ import { getLocalMusicFileLyric, getLocalMusicFilePic } from '@renderer/utils/music' +import path from 'node:path' +import os from 'node:os' +import fs from 'node:fs/promises' +import { checkPath } from '@common/utils/nodejs' +const getTempDir = async() => { + const tempDir = path.join(os.tmpdir(), 'lxmusic_temp') + if (!await checkPath(tempDir)) { + await fs.mkdir(tempDir, { recursive: true }) + } + return tempDir +} export const getMusicFilePic = async(filePath: string) => { const picture = await getLocalMusicFilePic(filePath) if (!picture) return '' + if (picture.data.length > 400_000) { + try { + const tempDir = await getTempDir() + const tempFile = path.join(tempDir, path.basename(filePath) + '.' + picture.format.split('/')[1]) + await fs.writeFile(tempFile, picture.data) + return tempFile + } catch (err) { + console.log(err) + } + } return `data:${picture.format};base64,${Buffer.from(picture.data).toString('base64')}` }