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},