fix: 修复 macos 和linux 本地歌曲路径问题

- 在 macos 和 linux 读取本地文件需要添加 file:// 前缀
- windows 也支持 file:// 前缀
- 在创建播放器时,为本地歌曲路径添加 file:// 前缀
- 在修改歌曲封面时,为本地路径添加 file:// 前缀
- 在保存元数据时,移除 file:// 前缀以保持兼容性
This commit is contained in:
wangjian
2025-08-21 09:37:25 +08:00
parent b2ddb9f4e2
commit c702e6e01a
2 changed files with 5 additions and 3 deletions

View File

@@ -262,7 +262,7 @@ const onlineMatch = debounce(
const changeCover = async () => {
const newPath = await window.electron.ipcRenderer.invoke("choose-image");
if (!newPath) return;
coverData.value = newPath;
coverData.value = `file://${newPath}`;
};
// 实时修改列表
@@ -300,7 +300,9 @@ const saveSongInfo = debounce(async (song: SongType) => {
cover:
coverData.value.startsWith("blob:") || coverData.value === "/images/song.jpg?assest"
? null
: coverData.value,
: coverData.value.startsWith("file://")
? coverData.value.replace(/^file:\/\//, "")
: coverData.value,
};
console.log(song.path, metadata);
await window.electron.ipcRenderer.invoke("set-music-metadata", song.path, metadata);

View File

@@ -549,7 +549,7 @@ class Player {
statusStore.playLoading = true;
// 本地歌曲
if (path) {
await this.createPlayer(path, autoPlay, seek);
await this.createPlayer(`file://${path}`, autoPlay, seek);
// 获取歌曲元信息
await this.parseLocalMusicInfo(path);
}