Merge pull request #1589 from A-Dawn/r-dev
fix:仅使用包内WebUI静态资源&修复前端本地构建错误
This commit is contained in:
@@ -1719,7 +1719,7 @@ export function KnowledgeBasePage() {
|
||||
}
|
||||
}, [selectedFeedbackCorrection?.task_id])
|
||||
|
||||
const selectedFeedbackResolved = useMemo(() => {
|
||||
const selectedFeedbackResolved = useMemo<MemoryFeedbackCorrectionDetailTaskPayload | null>(() => {
|
||||
if (!selectedFeedbackCorrection) {
|
||||
return null
|
||||
}
|
||||
@@ -1732,7 +1732,7 @@ export function KnowledgeBasePage() {
|
||||
return selectedFeedbackTaskDetail ?? selectedFeedbackCorrection
|
||||
}, [selectedFeedbackCorrection, selectedFeedbackTaskDetail])
|
||||
|
||||
const selectedFeedbackActionLogs = Array.isArray(selectedFeedbackResolved?.action_logs)
|
||||
const selectedFeedbackActionLogs: MemoryFeedbackActionLogPayload[] = Array.isArray(selectedFeedbackResolved?.action_logs)
|
||||
? selectedFeedbackResolved.action_logs
|
||||
: []
|
||||
const filteredFeedbackActionLogs = useMemo(() => {
|
||||
|
||||
@@ -79,7 +79,7 @@ def test_resolve_static_path_prefers_installed_dashboard_package(monkeypatch, tm
|
||||
assert resolved_path == package_dist
|
||||
|
||||
|
||||
def test_resolve_static_path_uses_dashboard_dist(monkeypatch, tmp_path) -> None:
|
||||
def test_resolve_static_path_ignores_dashboard_dist_when_package_is_unavailable(monkeypatch, tmp_path) -> None:
|
||||
dashboard_dist = tmp_path / "dashboard" / "dist"
|
||||
dashboard_dist.mkdir(parents=True)
|
||||
(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:
|
||||
with patch.object(webui_app, "import_module", side_effect=ImportError):
|
||||
resolved_path = webui_app._resolve_static_path()
|
||||
|
||||
assert resolved_path == dashboard_dist
|
||||
assert resolved_path is None
|
||||
|
||||
|
||||
def test_resolve_static_path_falls_back_to_package_when_dashboard_dist_has_no_index(monkeypatch, tmp_path) -> None:
|
||||
def test_resolve_static_path_uses_package_even_when_dashboard_dist_exists(monkeypatch, tmp_path) -> None:
|
||||
dashboard_dist = tmp_path / "dashboard" / "dist"
|
||||
dashboard_dist.mkdir(parents=True)
|
||||
|
||||
|
||||
@@ -205,11 +205,12 @@ def _setup_static_files(app: FastAPI):
|
||||
|
||||
|
||||
def _resolve_static_path() -> Path | None:
|
||||
# 开发环境优先允许复用仓库里的现成 dist
|
||||
base_dir = _get_project_root()
|
||||
static_path = base_dir / "dashboard" / "dist"
|
||||
if static_path.is_dir() and (static_path / "index.html").exists():
|
||||
return static_path
|
||||
# 临时仅允许使用已安装的 maibot-dashboard 包,不使用仓库本地 dashboard/dist。
|
||||
# 如需恢复本地回退逻辑,可取消下方注释。
|
||||
# base_dir = _get_project_root()
|
||||
# static_path = base_dir / "dashboard" / "dist"
|
||||
# if static_path.is_dir() and (static_path / "index.html").exists():
|
||||
# return static_path
|
||||
|
||||
try:
|
||||
module = import_module("maibot_dashboard")
|
||||
|
||||
Reference in New Issue
Block a user