From c2c89ef680844a9e8e356165cab69f0ba00d26cd Mon Sep 17 00:00:00 2001 From: ymq Date: Thu, 3 Sep 2026 18:57:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B7=A5=E4=BD=9C=E7=A9=BA=E9=97=B4?= =?UTF-8?q?=E7=AB=AF=E7=82=B9id=E5=A4=9A=E5=B1=82URL=E8=A7=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=88=E4=B8=AD=E6=96=87=E6=96=87=E4=BB=B6=E5=90=8D'?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8D=E5=AD=98=E5=9C=A8'=E6=A0=B9?= =?UTF-8?q?=E5=9B=A0=EF=BC=89+json=E6=9F=A5=E7=9C=8B=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=E6=AD=A3=E6=96=87=E4=B8=8D=E4=B8=8B=E8=BD=BD=EF=BC=88=E5=85=A8?= =?UTF-8?q?=E4=BA=A7=E7=BA=BF=E5=85=B1=E4=BA=AB=E7=AB=AF=E7=82=B9=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wwwroot/api/task_io.dspy | 1 + wwwroot/api/workspace_delete.dspy | 13 +++++++++- wwwroot/api/workspace_file.dspy | 15 +++++++++-- wwwroot/api/workspace_files.dspy | 13 +++++++++- wwwroot/api/workspace_open.dspy | 14 +++++++++-- wwwroot/api/workspace_tree.dspy | 9 +++++++ wwwroot/api/workspace_upload.dspy | 13 +++++++++- wwwroot/api/workspace_view.dspy | 41 +++++++++++++++++++++++++++---- 8 files changed, 107 insertions(+), 12 deletions(-) diff --git a/wwwroot/api/task_io.dspy b/wwwroot/api/task_io.dspy index 8eabcab..86064a2 100644 --- a/wwwroot/api/task_io.dspy +++ b/wwwroot/api/task_io.dspy @@ -22,6 +22,7 @@ _state_colors = { 'paused': '#f0a040', 'cancelled': '#64748b', 'qc_review': '#8b5cf6', 'qc_rejected': '#dc2626', + 'verify_failed': '#f0a040', } if not task_id: diff --git a/wwwroot/api/workspace_delete.dspy b/wwwroot/api/workspace_delete.dspy index b512b35..a3a9d09 100644 --- a/wwwroot/api/workspace_delete.dspy +++ b/wwwroot/api/workspace_delete.dspy @@ -1,8 +1,19 @@ # workspace_delete.dspy - 删除工作空间文件 import os +from urllib.parse import unquote -file_id = (params_kw or {}).get('id', '').strip() +def _decode_id(s): + for _ in range(4): + if '%' not in s: + break + s2 = unquote(s) + if s2 == s: + break + s = s2 + return s + +file_id = _decode_id((params_kw or {}).get('id', '').strip()) uid = await get_user() if not uid: diff --git a/wwwroot/api/workspace_file.dspy b/wwwroot/api/workspace_file.dspy index f99df6d..e5d1876 100644 --- a/wwwroot/api/workspace_file.dspy +++ b/wwwroot/api/workspace_file.dspy @@ -1,10 +1,21 @@ # workspace_file.dspy - 提供工作空间文件(媒体流 / 下载) import os -from urllib.parse import quote +from urllib.parse import quote, unquote from aiohttp.web_fileresponse import FileResponse -file_id = (params_kw or {}).get('id', '').strip() +def _decode_id(s): + # 前端 id 可能被多层编码,循环解码到无 % 为止(2026-09-03 中文文件名根因) + for _ in range(4): + if '%' not in s: + break + s2 = unquote(s) + if s2 == s: + break + s = s2 + return s + +file_id = _decode_id((params_kw or {}).get('id', '').strip()) download = (params_kw or {}).get('download', '').strip() uid = await get_user() diff --git a/wwwroot/api/workspace_files.dspy b/wwwroot/api/workspace_files.dspy index 4e26261..d3cc5da 100644 --- a/wwwroot/api/workspace_files.dspy +++ b/wwwroot/api/workspace_files.dspy @@ -2,8 +2,19 @@ import os import json as _json +from urllib.parse import unquote -folder_id = (params_kw or {}).get('id', '').strip() +def _decode_id(s): + for _ in range(4): + if '%' not in s: + break + s2 = unquote(s) + if s2 == s: + break + s = s2 + return s + +folder_id = _decode_id((params_kw or {}).get('id', '').strip()) uid = await get_user() if not uid: diff --git a/wwwroot/api/workspace_open.dspy b/wwwroot/api/workspace_open.dspy index ae1e945..210321d 100644 --- a/wwwroot/api/workspace_open.dspy +++ b/wwwroot/api/workspace_open.dspy @@ -2,9 +2,19 @@ import os import json as _json -from urllib.parse import quote +from urllib.parse import quote, unquote -file_id = (params_kw or {}).get('id', '').strip() +def _decode_id(s): + for _ in range(4): + if '%' not in s: + break + s2 = unquote(s) + if s2 == s: + break + s = s2 + return s + +file_id = _decode_id((params_kw or {}).get('id', '').strip()) uid = await get_user() if not uid: diff --git a/wwwroot/api/workspace_tree.dspy b/wwwroot/api/workspace_tree.dspy index d824f35..bbf9d8a 100644 --- a/wwwroot/api/workspace_tree.dspy +++ b/wwwroot/api/workspace_tree.dspy @@ -3,6 +3,15 @@ import os node_id = (params_kw or {}).get('id', '').strip() +# 前端 id 可能被多层编码,循环解码(2026-09-03 中文目录名根因) +from urllib.parse import unquote as _unq +for _ in range(4): + if '%' not in node_id: + break + _s2 = _unq(node_id) + if _s2 == node_id: + break + node_id = _s2 uid = await get_user() if not uid: diff --git a/wwwroot/api/workspace_upload.dspy b/wwwroot/api/workspace_upload.dspy index 1c0367a..bfdd05b 100644 --- a/wwwroot/api/workspace_upload.dspy +++ b/wwwroot/api/workspace_upload.dspy @@ -2,8 +2,19 @@ import os import base64 +from urllib.parse import unquote -folder_id = (params_kw or {}).get('id', '').strip() +def _decode_id(s): + for _ in range(4): + if '%' not in s: + break + s2 = unquote(s) + if s2 == s: + break + s = s2 + return s + +folder_id = _decode_id((params_kw or {}).get('id', '').strip()) filename = (params_kw or {}).get('filename', '').strip() filedata = (params_kw or {}).get('filedata', '').strip() diff --git a/wwwroot/api/workspace_view.dspy b/wwwroot/api/workspace_view.dspy index cdbb3a3..ba83519 100644 --- a/wwwroot/api/workspace_view.dspy +++ b/wwwroot/api/workspace_view.dspy @@ -1,10 +1,22 @@ -# workspace_view.dspy - 查看文件:txt/md 用 MdWidget 渲染,其他文档下载查看 +# workspace_view.dspy - 查看文件:txt/md/json 用 MdWidget 渲染,其他文档下载查看 import os import json as _json -from urllib.parse import quote +from urllib.parse import quote, unquote -file_id = (params_kw or {}).get('id', '').strip() +def _decode_id(s): + # 前端 id 可能被多层编码(Tree 懒加载一次 + encodeURIComponent 一次), + # 循环解码到无 % 为止,兼容任意编码层数(2026-09-03 中文文件名"文件不存在"根因) + for _ in range(4): + if '%' not in s: + break + s2 = unquote(s) + if s2 == s: + break + s = s2 + return s + +file_id = _decode_id((params_kw or {}).get('id', '').strip()) uid = await get_user() if not uid: @@ -39,9 +51,28 @@ ext = os.path.splitext(name)[1].lower() file_url = entire_url("/pipeline-sdlc/api/workspace_file.dspy") + "?id=" + quote(file_id) + (("&session_id=" + session_id) if session_id else "") -# txt/md → VScrollPanel 包裹 MdWidget 渲染(可滚动,长文档不截断) -md_exts = ['.md', '.txt'] +# txt/md/json → VScrollPanel 包裹 MdWidget 渲染(可滚动,长文档不截断;json 直接显示正文不下载) +md_exts = ['.md', '.txt', '.json'] if ext in md_exts: + if ext == '.json': + # json 包代码块渲染(marked 按 pre 显示正文) + try: + with open(full_path, 'r', encoding='utf-8', errors='replace') as fh: + body = fh.read(200000) + except Exception as e: + return {"widgettype": "Message", "options": {"title": "查看失败", "message": str(e)[:200]}} + return { + "widgettype": "PopupWindow", + "options": {"title": name + " (查看)", "width": "85%", "height": "85%", "auto_open": True, "resizable": True}, + "subwidgets": [{ + "widgettype": "VScrollPanel", + "options": {"css": "filler", "width": "100%", "height": "100%"}, + "subwidgets": [{ + "widgettype": "MdWidget", + "options": {"mdtext": "```json\n" + body + "\n```", "width": "100%"} + }] + }] + } return { "widgettype": "PopupWindow", "options": {"title": name + " (查看)", "width": "85%", "height": "85%", "auto_open": True, "resizable": True},