From 6ee26e46e634916619323378b5b7dfe9a5b36fc5 Mon Sep 17 00:00:00 2001 From: chenjw28 <792430652@qq.com> Date: Mon, 14 Sep 2026 16:00:30 +0800 Subject: [PATCH] feat(share): inline media preview on single-file share landing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The public share page only rendered media previews for FOLDER shares — a single-file share got a bare icon + download button, even for images and videos the browser can play natively. Backend: resolve the shared file's mime_type + size at read time and expose them on ShareDto (meta + password-verify endpoints, one shared enrichment helper). Display-only enrichment: a failed file lookup leaves the fields None instead of failing the response — the download endpoint still surfaces the real error. Frontend: the 'file' view now reuses the folder grid's lazyVideo (poster-seek + retry) for video and imageRetry for images, with Range-aware streaming already provided by /api/s/{token}/file/{id}. Co-Authored-By: Claude Code --- frontend/src/lib/api/endpoints/share.ts | 10 ++ frontend/src/routes/s/[token]/+page.svelte | 31 ++++- src/application/dtos/share_dto.rs | 11 ++ src/application/services/share_service.rs | 123 ++++++++++++++++++- src/interfaces/api/handlers/share_handler.rs | 2 +- 5 files changed, 174 insertions(+), 3 deletions(-) diff --git a/frontend/src/lib/api/endpoints/share.ts b/frontend/src/lib/api/endpoints/share.ts index 1b69f68a..154d3f4f 100644 --- a/frontend/src/lib/api/endpoints/share.ts +++ b/frontend/src/lib/api/endpoints/share.ts @@ -9,6 +9,16 @@ import type { ItemType } from '$lib/api/types'; export interface ShareMeta { item_type: ItemType; item_name: string; + /** The shared item's id — file shares use it to build the preview src. */ + item_id: string; + /** + * File shares only: resolved by the server at read time so the landing + * page can inline a media preview (video player / image) instead of a + * bare download button. Absent for folder shares. + */ + mime_type?: string; + /** File shares only: the shared file's size in bytes. */ + size?: number; } export interface ShareFolderEntry { diff --git a/frontend/src/routes/s/[token]/+page.svelte b/frontend/src/routes/s/[token]/+page.svelte index 570a536c..9e61d933 100644 --- a/frontend/src/routes/s/[token]/+page.svelte +++ b/frontend/src/routes/s/[token]/+page.svelte @@ -287,7 +287,29 @@ {:else if view === 'file'}
-