From 0438a9c4b5c996c7c71e6e051434c7476e3fa975 Mon Sep 17 00:00:00 2001 From: ymq Date: Fri, 18 Sep 2026 08:59:34 +0800 Subject: [PATCH] =?UTF-8?q?feat(workspace):=20office=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B/=E7=BC=96=E8=BE=91=E5=9D=87univer=E5=9C=A8?= =?UTF-8?q?=E7=BA=BF+=E5=BC=B9=E7=AA=97=E9=A1=B6=E9=83=A8=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E6=8C=89=E9=92=AE(2026-09-18=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=A6=81=E6=B1=82)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - workspace_view.dspy(查看): docx从'需下载后查看'提示弹窗改为univer在线查看 (mode=view只读,无保存按钮)+顶部'⬇下载'按钮+只读提示文案 - workspace_open.dspy(编辑): 保留univer在线编辑,顶部加'⬇下载'按钮+保存引导文案 - 布局: VBox filler→工具行HBox+Iframe filler(高度链完整) - univer_url/file_url均沿用_fq_s双透传(session_id+pipeline_id) - 配套: univer-office前端main.ts mode=view不渲染浮动保存按钮(独立部署) --- wwwroot/api/workspace_open.dspy | 24 ++++++++++++++++++++---- wwwroot/api/workspace_view.dspy | 28 ++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/wwwroot/api/workspace_open.dspy b/wwwroot/api/workspace_open.dspy index 28491db..1196606 100644 --- a/wwwroot/api/workspace_open.dspy +++ b/wwwroot/api/workspace_open.dspy @@ -116,15 +116,31 @@ if ext in image_exts: ] } -# 4. office 文档 → iframe 嵌入 univer-office 在线编辑 +# 4. office 文档 → iframe 嵌入 univer-office 在线编辑 + 顶部下载按钮 +# (2026-09-18 用户要求:查看和编辑都在线,另提供下载按钮) if ext in office_exts: univer_url = entire_url("/univer-office/") + "?file=" + quote(file_id) + _fq_s + download_url_e = file_url + "&download=1" + download_script_e = ( + "window.open(" + _json.dumps(download_url_e) + ",'_blank');" + ) 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%"}} - ] + "subwidgets": [{ + "widgettype": "VBox", + "options": {"css": "filler", "height": "100%", "width": "100%", "gap": "6px", "padding": "6px"}, + "subwidgets": [ + {"widgettype": "HBox", + "options": {"width": "100%", "gap": "8px", "alignItems": "center"}, + "subwidgets": [ + {"widgettype": "Button", "options": {"label": "⬇ 下载", "css": "small"}, + "binds": [{"wid": "self", "event": "click", "actiontype": "script", "target": "self", "script": download_script_e}]}, + {"widgettype": "Text", "options": {"text": "编辑后点右上角「💾 保存」写回工作空间", "cfontsize": 0.8, "color": "#94a3b8"}}, + ]}, + {"widgettype": "Iframe", "options": {"url": univer_url, "css": "filler", "width": "100%", "height": "100%"}}, + ] + }] } # 5. pdf 等 → 下载后用本地应用打开 diff --git a/wwwroot/api/workspace_view.dspy b/wwwroot/api/workspace_view.dspy index 78adf88..126af09 100644 --- a/wwwroot/api/workspace_view.dspy +++ b/wwwroot/api/workspace_view.dspy @@ -139,6 +139,34 @@ if ext in image_exts: }] } +# office 文档(docx)→ univer-office 在线查看(mode=view 只读,不显示保存按钮)+ 下载按钮 +# (2026-09-18 用户要求:查看和编辑都在线,另提供下载按钮) +office_exts = ['.docx'] +if ext in office_exts: + univer_url = entire_url("/univer-office/") + "?file=" + quote(file_id) + "&mode=view" + _fq_s + download_url_v = file_url + "&download=1" + download_script_v = ( + "window.open(" + _json.dumps(download_url_v) + ",'_blank');" + ) + return { + "widgettype": "PopupWindow", + "options": {"title": name + " (在线查看)", "width": "85%", "height": "85%", "auto_open": True, "resizable": True}, + "subwidgets": [{ + "widgettype": "VBox", + "options": {"css": "filler", "height": "100%", "width": "100%", "gap": "6px", "padding": "6px"}, + "subwidgets": [ + {"widgettype": "HBox", + "options": {"width": "100%", "gap": "8px", "alignItems": "center"}, + "subwidgets": [ + {"widgettype": "Button", "options": {"label": "⬇ 下载", "css": "small"}, + "binds": [{"wid": "self", "event": "click", "actiontype": "script", "target": "self", "script": download_script_v}]}, + {"widgettype": "Text", "options": {"text": "在线查看模式(只读);如需修改请用「编辑」", "cfontsize": 0.8, "color": "#94a3b8"}}, + ]}, + {"widgettype": "Iframe", "options": {"url": univer_url, "css": "filler", "width": "100%", "height": "100%"}}, + ] + }] + } + # 其他 → 下载查看 download_url = file_url + "&download=1" download_script = (