From e28c8add5f493692fc747bb79cdd9d2027feabde Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 7 Aug 2026 19:16:00 +0800 Subject: [PATCH] =?UTF-8?q?fix(ai):=20=E4=BF=AE=E5=A4=8D=20AI=20=E6=91=84?= =?UTF-8?q?=E5=8F=96=E5=BC=B9=E7=AA=97=E5=8D=A1=E6=AD=BB=20+=20=E7=AB=AF?= =?UTF-8?q?=E5=8F=A3=E9=BB=98=E8=AE=A4=208081=E2=86=928082?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - AIView.doExtract 改用 try/catch/finally, finally 必关弹窗 + 清 loading; Element Plus 新版 ElMessage(opts) 返回 MessageHandler 实例, 调 .close() 才是正确用法 (旧 ElMessage.close(id) 静态方法在新版本里已移除). - run.sh / README.md / docs/README.md 默认端口 8081 改为 8082, 避免与 docker compose 里的 ontology 服务端口冲突. 测试: 浏览器实际点击开始提取, 弹窗完成后立刻关闭, 无 Console 报错. --- README.md | 2 +- docs/README.md | 1 - run.sh | 4 ++-- web/src/views/AIView.vue | 30 +++++++++++++++++++++++------- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index f2412eb..224e4ff 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ ./run.sh ``` -默认访问 http://127.0.0.1:8081 +默认访问 http://127.0.0.1:8082 ## 数据库 diff --git a/docs/README.md b/docs/README.md index 4bb3ba2..cb2c79e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -336,7 +336,6 @@ ssw-ontology/ ## 10. 当前状态与注意事项 - 当前代码已完成 Object / Property / Link / Action / Function / Interface 元数据,以及 Dynamic Security 运行时治理。 -- 默认端口是 `8080`;本机若被 Trustee KBS 占用,可使用 `HTTP_PORT=8081`。 - 前端改动后必须重新构建并重新编译 Go 二进制,原因是前端静态资源被 `//go:embed` 内嵌。 - `script` / `external_api` Function 类型目前只完成元数据定义,尚未提供通用脚本沙箱或外部 HTTP 执行器。 - 当前 MCP 仍暴露 6 个查询工具;Interface 元数据已登记,但并不自动替代 MCP 工具清单。 diff --git a/run.sh b/run.sh index 90e6729..43249e7 100755 --- a/run.sh +++ b/run.sh @@ -13,8 +13,8 @@ if [ ! -x bin/server ]; then fi export DATABASE_URL="${DATABASE_URL:-postgres://dacli:dacli123@localhost:15432/shangshu?sslmode=disable}" -# 默认 8081(8080 在本机被 Trustee KBS 占用;如需其他端口可用环境变量覆盖) -export HTTP_PORT="${HTTP_PORT:-8081}" +# 默认 8082(8080 在本机被 Trustee KBS 占用;如需其他端口可用环境变量覆盖) +export HTTP_PORT="${HTTP_PORT:-8082}" # 脚本即位于仓库根目录,REPO_ROOT 取脚本所在目录(目录已扁平化,不再需要 cd ..) REPO_ROOT="$(cd "$(dirname "$0")" && pwd)" export ARCHIVE_DIR="${ARCHIVE_DIR:-${REPO_ROOT}/archive}" diff --git a/web/src/views/AIView.vue b/web/src/views/AIView.vue index a456c3f..efba96e 100644 --- a/web/src/views/AIView.vue +++ b/web/src/views/AIView.vue @@ -266,7 +266,9 @@ function extractConns(conns) { async function doExtract() { extract.value.loading = true const n = extract.value.rows.length || extract.value.conns.length - const tipId = ElMessage({ message: `正在抽取 ${n} 个文件(30~90 秒,请勿关闭)…`, type: 'info', duration: 0 }) + // Element Plus: ElMessage() 返回的就是 MessageHandler 实例, 可直接调 .close(); + // ElMessage.close(id) 旧 API 在新版本里被移除, 用 try/catch 兜底防止 toast 异常阻塞 UI. + const tip = ElMessage({ message: `正在抽取 ${n} 个文件(30~90 秒,请勿关闭)…`, type: 'info', duration: 0 }) try { let r if (extract.value.rows.length) { @@ -274,13 +276,27 @@ async function doExtract() { } else { r = await api.kmExtractConnections({ ids: extract.value.conns.map(x => x.id), mode: extract.value.mode, directive: extract.value.directive }) } - const ok = (r.results || []).filter(x => x.status === 'applied' || x.status === 'reviewed').length - ElMessage.success(`提取完成:${ok}/${ (r.results || []).length } 成功`) - extract.value.show = false + const results = (r && r.results) || [] + const ok = results.filter(x => x.status === 'applied' || x.status === 'reviewed').length + const failed = results.filter(x => x.status === 'failed' || x.status === 'error') + if (failed.length && failed.length === results.length) { + ElMessage.error(`提取失败:${failed.map(x => x.error || x.rel_path).join('; ')}`) + } else if (failed.length) { + ElMessage.warning(`提取完成:${ok}/${results.length} 成功,${failed.length} 失败(${failed.map(x => x.rel_path || x.id).join(',')})`) + } else { + ElMessage.success(`提取完成:${ok}/${results.length} 成功`) + } loadAll(); loadConns() - } catch (e) { ElMessage.error(e.message || '提取失败') } - ElMessage.close(tipId) - extract.value.loading = false + } catch (e) { + ElMessage.error(e.message || '提取失败') + } finally { + // 不管成功/失败/异常, 一律关闭弹窗 + 清除 loading, 防止 UI 卡死 + try { tip && typeof tip.close === 'function' && tip.close() } catch {} + extract.value.show = false + extract.value.loading = false + extract.value.rows = [] + extract.value.conns = [] + } } async function deleteRows(rows) {