mirror of
https://github.com/imsyy/SPlayer.git
synced 2025-11-25 03:14:57 +08:00
fix: 修复 macos 和linux 本地歌曲路径问题
- 在 macos 和 linux 读取本地文件需要添加 file:// 前缀 - windows 也支持 file:// 前缀 - 在创建播放器时,为本地歌曲路径添加 file:// 前缀 - 在修改歌曲封面时,为本地路径添加 file:// 前缀 - 在保存元数据时,移除 file:// 前缀以保持兼容性
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user