diff --git a/change.log b/change.log index c815983..0e8c369 100644 --- a/change.log +++ b/change.log @@ -1,5 +1,5 @@ ## 更新日志 -- 20260805 适配 Memos 0.29.x Attachment API,修复附件上传、绑定和预览地址 +- 20260805 适配 Memos 0.29.x Attachment API,修复附件上传、绑定和预览地址;修复 0.20.x 图片预览 URL 错误使用 numeric id 的问题 - 20260425 新增德语/法语/西班牙语支持 - 20260423 优化 firefox 抖动问题和支持手机版,支持 edge 浏览器扩展 - 20260422 调整发送设置,支持仅发送附件 diff --git a/chrome/js/oper.js b/chrome/js/oper.js index cdda987..27813bd 100644 --- a/chrome/js/oper.js +++ b/chrome/js/oper.js @@ -516,6 +516,11 @@ function buildV1ResourceStreamUrl(info, resource) { const uid = typeof uidRaw === 'string' ? uidRaw : uidRaw != null ? String(uidRaw) : '' if (uid.trim() !== '') return buildStreamUrl(uid.trim()) + // Fallback for older resource shapes. + // In some memo payloads, the uid may appear as `name` directly. + // Example: name="ETU6hjuR..." should map to /o/r/:uid, not /file/:name/:filename. + if (isProbablyUid(name)) return buildStreamUrl(name.trim()) + // Legacy versions (e.g. v0.18) may only expose numeric `id` without `uid/name`. const idRaw = resource.id != null ? resource.id : resource.ID != null ? resource.ID : resource.Id const id = typeof idRaw === 'number' && Number.isFinite(idRaw) @@ -525,11 +530,6 @@ function buildV1ResourceStreamUrl(info, resource) { : '' if (id) return buildStreamUrl(id) - // Fallback for older resource shapes. - // In some memo payloads, the uid may appear as `name` directly. - // Example: name="ETU6hjuR..." should map to /o/r/:uid, not /file/:name/:filename. - if (isProbablyUid(name)) return buildStreamUrl(name.trim()) - const fileId = resource.publicId || filename if (name && fileId) return root + 'file/' + name + '/' + fileId return '' diff --git a/edge/js/oper.js b/edge/js/oper.js index cdda987..27813bd 100644 --- a/edge/js/oper.js +++ b/edge/js/oper.js @@ -516,6 +516,11 @@ function buildV1ResourceStreamUrl(info, resource) { const uid = typeof uidRaw === 'string' ? uidRaw : uidRaw != null ? String(uidRaw) : '' if (uid.trim() !== '') return buildStreamUrl(uid.trim()) + // Fallback for older resource shapes. + // In some memo payloads, the uid may appear as `name` directly. + // Example: name="ETU6hjuR..." should map to /o/r/:uid, not /file/:name/:filename. + if (isProbablyUid(name)) return buildStreamUrl(name.trim()) + // Legacy versions (e.g. v0.18) may only expose numeric `id` without `uid/name`. const idRaw = resource.id != null ? resource.id : resource.ID != null ? resource.ID : resource.Id const id = typeof idRaw === 'number' && Number.isFinite(idRaw) @@ -525,11 +530,6 @@ function buildV1ResourceStreamUrl(info, resource) { : '' if (id) return buildStreamUrl(id) - // Fallback for older resource shapes. - // In some memo payloads, the uid may appear as `name` directly. - // Example: name="ETU6hjuR..." should map to /o/r/:uid, not /file/:name/:filename. - if (isProbablyUid(name)) return buildStreamUrl(name.trim()) - const fileId = resource.publicId || filename if (name && fileId) return root + 'file/' + name + '/' + fileId return '' diff --git a/firefox/js/oper.js b/firefox/js/oper.js index be72188..1f5dee5 100644 --- a/firefox/js/oper.js +++ b/firefox/js/oper.js @@ -541,6 +541,11 @@ function buildV1ResourceStreamUrl(info, resource) { const uid = typeof uidRaw === 'string' ? uidRaw : uidRaw != null ? String(uidRaw) : '' if (uid.trim() !== '') return buildStreamUrl(uid.trim()) + // Fallback for older resource shapes. + // In some memo payloads, the uid may appear as `name` directly. + // Example: name="ETU6hjuR..." should map to /o/r/:uid, not /file/:name/:filename. + if (isProbablyUid(name)) return buildStreamUrl(name.trim()) + // Legacy versions (e.g. v0.18) may only expose numeric `id` without `uid/name`. const idRaw = resource.id != null ? resource.id : resource.ID != null ? resource.ID : resource.Id const id = typeof idRaw === 'number' && Number.isFinite(idRaw) @@ -550,11 +555,6 @@ function buildV1ResourceStreamUrl(info, resource) { : '' if (id) return buildStreamUrl(id) - // Fallback for older resource shapes. - // In some memo payloads, the uid may appear as `name` directly. - // Example: name="ETU6hjuR..." should map to /o/r/:uid, not /file/:name/:filename. - if (isProbablyUid(name)) return buildStreamUrl(name.trim()) - const fileId = resource.publicId || filename if (name && fileId) return root + 'file/' + name + '/' + fileId return ''