From 33e5a2d045e2caf946df4d1aa691aed6bb8ec923 Mon Sep 17 00:00:00 2001 From: ymq Date: Mon, 24 Aug 2026 12:06:23 +0800 Subject: [PATCH] =?UTF-8?q?feat(sdlc):=20workspace=20docx=20=E5=9C=A8?= =?UTF-8?q?=E7=BA=BF=E7=BC=96=E8=BE=91=E6=8E=A5=E5=85=A5=20univer-office(i?= =?UTF-8?q?frame)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wwwroot/api/workspace_open.dspy | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) 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');"