fix(ai): 修复 AI 摄取弹窗卡死 + 端口默认 8081→8082

- 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 报错.
This commit is contained in:
admin committed 2026-08-07 19:16:00 +08:00
1 parent d57f0ac068
commit e28c8add5f
4 files changed
+26 -11

No files matched your search

+1 -1
View File
@@ -18,7 +18,7 @@
./run.sh
```
默认访问 http://127.0.0.1:8081
默认访问 http://127.0.0.1:8082
## 数据库
-1
View File
@@ -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 工具清单。
+2 -2
View File
@@ -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}"
+23 -7
View File
@@ -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) {