Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix(scripts): build-exe use relative path, UTF-8, skip redundant npm install; exe run without admin

xiaotian077a047dcce2548
diff --git a/scripts/build-exe.bat b/scripts/build-exe.bat
index 46aa148037..0fe5acf540 100644
--- a/scripts/build-exe.bat
+++ b/scripts/build-exe.bat
@@ -1,32 +1,44 @@
@echo off
-REM JiuwenSwarm 打包 exe 脚本
-REM 用法: scripts\build-exe.bat 或双击运行
+REM JiuwenSwarm build-exe script
+REM Usage: scripts\build-exe.bat or double-click to run
+REM Project root = parent of this bat's own dir. Path-relative, survives relocation.
cd /d "%~dp0\.."
-echo === JiuwenSwarm 打包 exe ===
+echo === JiuwenSwarm build-exe ===
echo.
-echo [1/3] 安装 Python 依赖...
+echo [1/3] Installing Python deps (uv sync --extra dev)...
call uv sync --extra dev
if errorlevel 1 exit /b 1
echo.
-echo [2/3] 构建前端...
-cd jiuwenswarm\channels\web\frontend
-call npm install
-if errorlevel 1 (cd ..\.. & exit /b 1)
+echo [2/3] Building frontend...
+pushd jiuwenswarm\channels\web\frontend
+if errorlevel 1 goto :failed_frontend
+if not exist node_modules (
+ echo [build] node_modules missing, running npm install...
+ call npm install
+ if errorlevel 1 goto :failed_frontend
+) else (
+ echo [build] node_modules exists, skip npm install
+)
call npm run build
-if errorlevel 1 (cd ..\.. & exit /b 1)
-cd ..\..
+if errorlevel 1 goto :failed_frontend
+popd
echo.
-echo [3/3] 执行 PyInstaller 打包...
-call uv run pyinstaller scripts\jiuwenswarm.spec
+echo [3/3] Running PyInstaller...
+call uv run pyinstaller scripts\jiuwenswarm.spec --noconfirm
if errorlevel 1 exit /b 1
echo.
-echo === 打包完成 ===
-echo 桌面版目录: %cd%\dist\jiuwenswarm
-echo 主程序: %cd%\dist\jiuwenswarm\jiuwenswarm.exe
+echo === Build complete ===
+echo Desktop dir: %cd%\dist\jiuwenswarm
+echo Main exe: %cd%\dist\jiuwenswarm\jiuwenswarm.exe
pause
+exit /b 0
+
+:failed_frontend
+popd
+exit /b 1
diff --git a/scripts/build-exe.ps1 b/scripts/build-exe.ps1
index 14b15c4d56..9eab65bcee 100644
--- a/scripts/build-exe.ps1
+++ b/scripts/build-exe.ps1
@@ -7,6 +7,11 @@ param(
$ErrorActionPreference = "Stop"
+# 控制台 UTF-8,避免中文 echo 乱码(PowerShell 5.1 默认编码易乱码)
+[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
+$OutputEncoding = [System.Text.Encoding]::UTF8
+
+# 项目根 = 脚本所在目录的上一层,基于脚本自身位置推导,换路径不坏
$ProjectRoot = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
Set-Location $ProjectRoot
@@ -182,8 +187,13 @@ Write-Host "`n[2/4] Building frontend (jiuwenswarm/channels/web/frontend)..." -F
Push-Location (Join-Path $ProjectRoot "jiuwenswarm\channels\web\frontend")
$WebDist = Join-Path $ProjectRoot "jiuwenswarm\channels\web\dist"
if (Test-Path $WebDist) { Remove-Item $WebDist -Recurse -Force }
-npm install
-if ($LASTEXITCODE -ne 0) { Pop-Location; exit $LASTEXITCODE }
+if (Test-Path "node_modules") {
+ Write-Host "[build] node_modules exists, skip npm install" -ForegroundColor Gray
+} else {
+ Write-Host "[build] node_modules missing, running npm install..." -ForegroundColor Gray
+ npm install
+ if ($LASTEXITCODE -ne 0) { Pop-Location; exit $LASTEXITCODE }
+}
npm run build
if ($LASTEXITCODE -ne 0) { Pop-Location; exit $LASTEXITCODE }
Pop-Location
diff --git a/scripts/jiuwenswarm.spec b/scripts/jiuwenswarm.spec
index c0bf77e240..9a131542f9 100644
--- a/scripts/jiuwenswarm.spec
+++ b/scripts/jiuwenswarm.spec
@@ -299,7 +299,10 @@ exe = EXE(
codesign_identity=None,
entitlements_file=None,
icon=icon_path,
- uac_admin=True,
+ # 运行时数据全部落在用户目录 ~/.jiuwenswarm(cwd、单实例锁、日志、工作区),
+ # 不写 Program Files / HKLM,因此运行时不需要管理员权限。
+ # uac_admin=True 会让双击 exe 时弹 UAC,去掉它实现"安装需管理员、运行不需要"。
+ uac_admin=False,
)
coll = COLLECT(