Skip to content

Commit 2d70169

Browse files
authored
Merge pull request #1589 from A-Dawn/r-dev
fix:仅使用包内WebUI静态资源&修复前端本地构建错误
2 parents f71034b + df281c7 commit 2d70169

3 files changed

Lines changed: 11 additions & 10 deletions

File tree

dashboard/src/routes/resource/knowledge-base.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,7 +1719,7 @@ export function KnowledgeBasePage() {
17191719
}
17201720
}, [selectedFeedbackCorrection?.task_id])
17211721

1722-
const selectedFeedbackResolved = useMemo(() => {
1722+
const selectedFeedbackResolved = useMemo<MemoryFeedbackCorrectionDetailTaskPayload | null>(() => {
17231723
if (!selectedFeedbackCorrection) {
17241724
return null
17251725
}
@@ -1732,7 +1732,7 @@ export function KnowledgeBasePage() {
17321732
return selectedFeedbackTaskDetail ?? selectedFeedbackCorrection
17331733
}, [selectedFeedbackCorrection, selectedFeedbackTaskDetail])
17341734

1735-
const selectedFeedbackActionLogs = Array.isArray(selectedFeedbackResolved?.action_logs)
1735+
const selectedFeedbackActionLogs: MemoryFeedbackActionLogPayload[] = Array.isArray(selectedFeedbackResolved?.action_logs)
17361736
? selectedFeedbackResolved.action_logs
17371737
: []
17381738
const filteredFeedbackActionLogs = useMemo(() => {

pytests/webui/test_app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def get_dist_path() -> Path:
7979
assert resolved_path == package_dist
8080

8181

82-
def test_resolve_static_path_uses_dashboard_dist(monkeypatch, tmp_path) -> None:
82+
def test_resolve_static_path_ignores_dashboard_dist_when_package_is_unavailable(monkeypatch, tmp_path) -> None:
8383
dashboard_dist = tmp_path / "dashboard" / "dist"
8484
dashboard_dist.mkdir(parents=True)
8585
(dashboard_dist / "index.html").write_text("<html></html>", encoding="utf-8")
@@ -89,10 +89,10 @@ def test_resolve_static_path_uses_dashboard_dist(monkeypatch, tmp_path) -> None:
8989
with patch.object(webui_app, "import_module", side_effect=ImportError):
9090
resolved_path = webui_app._resolve_static_path()
9191

92-
assert resolved_path == dashboard_dist
92+
assert resolved_path is None
9393

9494

95-
def test_resolve_static_path_falls_back_to_package_when_dashboard_dist_has_no_index(monkeypatch, tmp_path) -> None:
95+
def test_resolve_static_path_uses_package_even_when_dashboard_dist_exists(monkeypatch, tmp_path) -> None:
9696
dashboard_dist = tmp_path / "dashboard" / "dist"
9797
dashboard_dist.mkdir(parents=True)
9898

src/webui/app.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,12 @@ async def serve_spa(full_path: str):
205205

206206

207207
def _resolve_static_path() -> Path | None:
208-
# 开发环境优先允许复用仓库里的现成 dist
209-
base_dir = _get_project_root()
210-
static_path = base_dir / "dashboard" / "dist"
211-
if static_path.is_dir() and (static_path / "index.html").exists():
212-
return static_path
208+
# 临时仅允许使用已安装的 maibot-dashboard 包,不使用仓库本地 dashboard/dist。
209+
# 如需恢复本地回退逻辑,可取消下方注释。
210+
# base_dir = _get_project_root()
211+
# static_path = base_dir / "dashboard" / "dist"
212+
# if static_path.is_dir() and (static_path / "index.html").exists():
213+
# return static_path
213214

214215
try:
215216
module = import_module("maibot_dashboard")

0 commit comments

Comments
 (0)