fix(local-music): 封面落盘 + URL 编码统一,修复持久化配额与编码边界

- 新增 src/shared/localUrl.ts 共用 local:// 编码:按路径段 encodeURIComponent,
  避免整体编码把 / 转成 %2F 引发 Chromium 解析边界差异,同时正确处理
  空格/中文/# 等特殊字符(封面落到含空格目录时 Image loader 会加载失败)
- 封面从内嵌 base64 Data URL 改为 userData/AudioCovers/<sha256>.<ext> 落盘,
  MAX_COVER_BYTES 1MB→8MB;老条目(无 coverPath 字段)扫描时一次性自愈
- playlist minify 剥离 base64 picUrl 并仅持久化 local:// 永不过期的 playMusicUrl,
  防止单张 base64 封面撑爆 localStorage 5MB 配额导致整个 playList 写入失败;
  localStorage 写入加 try/catch 兜底,避免配额超限时直接抛异常
This commit is contained in:
chengww
2026-05-17 21:36:49 +08:00
parent ee98eb0266
commit 15258f28fd
8 changed files with 129 additions and 40 deletions
+2 -1
View File
@@ -557,6 +557,7 @@ import type { SongResult } from '@/types/music';
import { getImgUrl } from '@/utils';
import type { DownloadTask } from '../../../shared/download';
import { filePathToLocalUrl } from '../../../shared/localUrl';
const { t } = useI18n();
const playerStore = usePlayerStore();
@@ -656,7 +657,7 @@ const shortenPath = (path: string) => {
const getLocalFilePath = (path: string) => {
if (!path) return '';
return `local:///${encodeURIComponent(path)}`;
return filePathToLocalUrl(path);
};
const openDirectory = (path: string) => {