diff --git a/wwwroot/api/workspace_open.dspy b/wwwroot/api/workspace_open.dspy index 1ac1dfc..adb1779 100644 --- a/wwwroot/api/workspace_open.dspy +++ b/wwwroot/api/workspace_open.dspy @@ -32,6 +32,7 @@ text_exts = ['.md', '.py', '.js', '.html', '.css', '.json', '.txt', '.xml', '.ya 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'] +office_exts = ['.docx'] # 在线编辑(univer-office)。xlsx/ppt 后续接入 Univer sheet/slide 插件 file_url = entire_url("/pipeline-sdlc/api/workspace_file.dspy") + "?id=" + quote(file_id) @@ -78,13 +79,24 @@ 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%"} - }] + "subwidgets": [ + {"widgettype": "Image", + "options": {"url": file_url, "width": "100%", "height": "100%"}} + ] } -# 4. office/pdf 等 → 下载后用本地应用打开 +# 4. office 文档 → iframe 嵌入 univer-office 在线编辑 +if ext in office_exts: + univer_url = entire_url("/univer-office/") + "?file=" + quote(file_id) + return { + "widgettype": "PopupWindow", + "options": {"title": name + " (在线编辑)", "width": "85%", "height": "85%", "auto_open": True, "resizable": True}, + "subwidgets": [ + {"widgettype": "Iframe", "options": {"url": univer_url, "width": "100%", "height": "100%"}} + ] + } + +# 5. pdf 等 → 下载后用本地应用打开 download_url = file_url + "&download=1" download_script = ( "window.open(" + _json.dumps(download_url) + ",'_blank');"