Skip to content

Commit 8e3e5c7

Browse files
committed
fix(review-feedback-965): address latest review comments
1 parent 652c3dd commit 8e3e5c7

4 files changed

Lines changed: 10 additions & 6 deletions

File tree

docs/DEPLOY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ deploy:
317317

318318
- **直接部署(pip + python)**:先构建前端,再启动服务:
319319
```bash
320-
# 安装 Node.js 20+(如尚未安装)
320+
# 安装 Node.js 18+(推荐 20+,如尚未安装)
321321
# 构建前端
322322
cd apps/dsa-web
323323
npm ci

docs/deploy-webui-cloud.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ docker-compose -f ./docker/docker-compose.yml up -d
227227

228228
重建完成后,用 `Ctrl+Shift+R` 强制刷新浏览器缓存,再访问页面。
229229

230-
**直接部署用户**:先确保已安装 Node.js 20+,然后手动构建前端:
230+
**直接部署用户**:先确保已安装 Node.js 18+(推荐 20+,然后手动构建前端:
231231

232232
```bash
233233
cd apps/dsa-web

src/webui_frontend.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ def _run_frontend_commands(commands: Sequence[Sequence[str]], frontend_dir: Path
122122

123123

124124
def _manual_build_command(frontend_dir: Path) -> str:
125-
return f'cd "{frontend_dir}" && npm install && npm run build'
125+
lock_file = frontend_dir / "package-lock.json"
126+
install_cmd = "npm ci" if lock_file.exists() else "npm install"
127+
return f'cd "{frontend_dir}" && {install_cmd} && npm run build'
126128

127129

128130
def _has_static_assets(static_dir: Path) -> bool:
@@ -146,11 +148,13 @@ def _has_static_assets(static_dir: Path) -> bool:
146148
def _warn_if_assets_missing(artifact_index: Path, frontend_dir: Path) -> None:
147149
"""当 index.html 存在但 assets/ 缺失时,发出页面显示异常警告。"""
148150
static_dir = artifact_index.parent
151+
assets_dir = static_dir / "assets"
149152
if not _has_static_assets(static_dir):
150153
logger.warning(
151-
"检测到 %s 但 static/assets/ 目录不存在或无 CSS/JS 文件,"
154+
"检测到 %s 但 %s 目录不存在或无 CSS/JS 文件,"
152155
"WebUI 将因缺少样式与脚本而显示异常(元素过大、布局错乱)",
153156
artifact_index,
157+
assets_dir,
154158
)
155159
logger.warning(
156160
"请重新构建前端以修复此问题: %s",

tests/test_webui_frontend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def test_prepare_webui_frontend_assets_warns_when_assets_missing(tmp_path, monke
6868
result = webui_frontend.prepare_webui_frontend_assets()
6969

7070
assert result is True # function still returns True (index.html present)
71-
assert "assets/ 目录不存在或无 CSS/JS 文件" in caplog.text
71+
assert "目录不存在或无 CSS/JS 文件" in caplog.text
7272
assert "WebUI 将因缺少样式与脚本而显示异常" in caplog.text
7373

7474

@@ -87,7 +87,7 @@ def test_prepare_webui_frontend_assets_auto_build_disabled_warns_when_assets_mis
8787
result = webui_frontend.prepare_webui_frontend_assets()
8888

8989
assert result is True # index.html present, still returns True
90-
assert "assets/ 目录不存在或无 CSS/JS 文件" in caplog.text
90+
assert "目录不存在或无 CSS/JS 文件" in caplog.text
9191

9292

9393
def test_has_static_assets_returns_false_for_missing_dir(tmp_path):

0 commit comments

Comments
 (0)