This commit is contained in:
seb
2026-08-01 02:08:39 +02:00
parent 6d720d34ed
commit 4ea593a0c8
7 changed files with 211 additions and 33 deletions

View File

@@ -180,7 +180,7 @@ export const article = {
/**
* POST /api/article/:sku/image
* Body: raw AVIF bytes (Content-Type: image/avif, max 1000×1000, prepared client-side via WASM)
* → 201 { image: { picId, sort, full, thumb, hash, thumbHash } }
* → 201 { image: { picId, sort, full, thumb, fullHash, thumbHash } }
*/
uploadImage(sku, file) {
return httpBinary(`/api/article/${encodeURIComponent(sku)}/image`, {
@@ -191,6 +191,20 @@ export const article = {
},
};
/**
* Content-addressed thumb AVIF by fullHash (SHA-256 hex of full image bytes).
* Auth: session cookie. Browser-cacheable (private, immutable, ETag).
*/
export const thumb = {
/**
* GET /api/thumb/:fullHash → image/avif (thumb bytes)
* Use as <img src={thumb.url(fullHash)} /> (same-origin; cookies sent).
*/
url(fullHash) {
return `/api/thumb/${encodeURIComponent(fullHash)}`;
},
};
export const category = {
/** GET /api/category/tree → { languageId, tree, articles } (company from session) */
getTree() {
@@ -310,4 +324,4 @@ export const auth = {
},
};
export default { auth, article, category, company };
export default { auth, article, category, company, thumb };