diff --git a/wwwroot/api/workspace_view.dspy b/wwwroot/api/workspace_view.dspy index 468b70b..78adf88 100644 --- a/wwwroot/api/workspace_view.dspy +++ b/wwwroot/api/workspace_view.dspy @@ -102,6 +102,43 @@ if ext in md_exts: }] } +# 媒体文件 → 直接用播放控件打开(2026-09-18 用户要求:查看即播放,不再让下载) +# 控件均已注册进 bricks.Factory(videoplayer.js/audio.js/image.js),声明式 widgetBuild 可解析; +# workspace_file.dspy 已用 FileResponse 提供媒体流(支持 Range 请求,可拖动进度)。 +video_exts = ['.mp4', '.m3u8', '.mpd', '.webm', '.mov', '.avi', '.mkv'] +audio_exts = ['.mp3', '.wav', '.aac', '.flac', '.m4a', '.ogg'] +image_exts = ['.png', '.jpg', '.jpeg', '.gif', '.svg', '.webp', '.bmp', '.ico'] + +if ext in video_exts: + return { + "widgettype": "PopupWindow", + "options": {"title": name + " (播放)", "width": "70%", "height": "70%", "auto_open": True, "resizable": True}, + "subwidgets": [{ + "widgettype": "VideoPlayer", + "options": {"url": file_url, "width": "100%", "height": "100%"} + }] + } + +if ext in audio_exts: + return { + "widgettype": "PopupWindow", + "options": {"title": name + " (播放)", "width": "50%", "height": "30%", "auto_open": True, "resizable": True}, + "subwidgets": [{ + "widgettype": "AudioPlayer", + "options": {"url": file_url, "width": "100%", "height": "100%"} + }] + } + +if ext in image_exts: + return { + "widgettype": "PopupWindow", + "options": {"title": name + " (查看)", "width": "70%", "height": "70%", "auto_open": True, "resizable": True}, + "subwidgets": [{ + "widgettype": "Image", + "options": {"url": file_url, "width": "100%", "height": "100%"} + }] + } + # 其他 → 下载查看 download_url = file_url + "&download=1" download_script = (