v1.4.15: fix getOriginalUrl/getThumbnailUrl URL encoding for paths with Chinese/spaces/#/?

This commit is contained in:
jinghui committed 2026-11-20 21:17:16 +08:00
1 parent d6b1989a4c
commit bf69419c68
6 files changed
+12 -7

No files matched your search

+5 -2
View File
@@ -50,7 +50,8 @@ export async function getCacheMeta(libraryId) {
* 使用分片结构,不再需要 size 参数
*/
export function getThumbnailUrl(libraryId, filename, version) {
const base = `/api/image/thumbnail/${libraryId}/${filename}`;
const encoded = encodeURIComponent(filename);
const base = `/api/image/thumbnail/${libraryId}/${encoded}`;
// version=文件 modified_at,编辑保存后变化以穿透浏览器缓存
return version ? `${base}?v=${version}` : base;
}
@@ -59,7 +60,9 @@ export function getThumbnailUrl(libraryId, filename, version) {
* 获取原图 URL
*/
export function getOriginalUrl(libraryId, path) {
return `/api/image/original/${libraryId}/${path}`;
// 按 '/' 分段编码,避免中文/空格/#/? 等字符导致原图 URL 404(灯箱/新窗口打开失败)
const encoded = String(path).split('/').map(encodeURIComponent).join('/');
return `/api/image/original/${libraryId}/${encoded}`;
}
/**