publish: 1.0.0 snapshot (bad2ec1)

channel: master
version: 1.0.0
source-ref: master
published-at-utc: 2026-03-13T15:19:28Z
This commit is contained in:
Ant Browser Release Bot
2026-03-13 23:19:29 +08:00
commit 6f58a6c19a
230 changed files with 44624 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
# bat
## 用途
- `dev.bat`:本地开发启动
- `build.bat`:本地构建可执行文件
- `publish.bat`:打包发布安装包
## 用法
### `dev.bat`
适合日常开发。
```bat
bat\dev.bat
```
### `build.bat`
构建 `build\bin\ant-chrome.exe`
```bat
bat\build.bat
```
### `publish.bat`
生成安装包,需要先安装 NSIS。
```bat
bat\publish.bat
```
产物:
```text
publish\output\AntBrowser-Setup-<version>.exe
```
## 备注
- `generate-bindings.bat` 是辅助脚本,通常由 `build.bat` 调用。
+148
View File
@@ -0,0 +1,148 @@
@echo off
chcp 65001 >nul
setlocal enabledelayedexpansion
REM 切换到项目根目录(脚本所在目录的上一级)
cd /d "%~dp0.."
echo ========================================
echo Ant Browser - Wails 构建脚本
echo ========================================
echo.
echo 当前工作目录: %CD%
echo.
REM ======== 代理配置 ========
REM 本地代理地址(例如 Clash、V2Ray 等)
set PROXY_HOST=127.0.0.1
set PROXY_PORT=7890
set USE_PROXY=1
REM 如果不需要使用代理,将 USE_PROXY 设置为 0
REM set USE_PROXY=0
REM 设置代理环境变量
if "%USE_PROXY%"=="1" (
echo [0/7] 正在配置代理...
set HTTP_PROXY=http://%PROXY_HOST%:%PROXY_PORT%
set HTTPS_PROXY=http://%PROXY_HOST%:%PROXY_PORT%
set http_proxy=http://%PROXY_HOST%:%PROXY_PORT%
set https_proxy=http://%PROXY_HOST%:%PROXY_PORT%
REM 配置 npm 代理
call npm config set proxy http://%PROXY_HOST%:%PROXY_PORT% 2>nul
call npm config set https-proxy http://%PROXY_HOST%:%PROXY_PORT% 2>nul
REM 配置 Go 代理环境变量
set GOPROXY=https://goproxy.cn,direct
echo ✓ 代理已配置: %PROXY_HOST%:%PROXY_PORT%
echo.
)
REM 定义清理函数(用于恢复代理设置)
goto :skip_cleanup_function
:cleanup
if "%USE_PROXY%"=="1" (
echo.
echo [清理代理配置...]
call npm config delete proxy 2>nul
call npm config delete https-proxy 2>nul
echo ✓ 代理配置已清理
)
exit /b
:skip_cleanup_function
echo [1/7] 安装前端依赖...
cd frontend
call npm install
if %errorlevel% neq 0 (
echo ✗ 安装前端依赖失败
cd ..
call :cleanup
pause
exit /b 1
)
cd ..
echo.
echo [2/7] 安装 Go 依赖...
go mod download
go mod tidy
if %errorlevel% neq 0 (
echo ✗ 安装 Go 依赖失败
call :cleanup
pause
exit /b 1
)
echo.
echo [3/7] 创建临时 dist 目录...
if not exist "frontend\dist" (
mkdir "frontend\dist"
echo. > "frontend\dist\index.html"
echo ✓ 临时 dist 目录已创建
) else (
echo ✓ dist 目录已存在
)
echo.
echo [4/7] 生成 Wails 绑定文件...
call bat\generate-bindings.bat --no-pause
if %errorlevel% neq 0 (
echo ✗ 生成绑定文件失败
call :cleanup
pause
exit /b 1
)
echo.
echo [5/7] 构建前端项目...
REM 清理临时 dist 目录
if exist "frontend\dist" (
rmdir /S /Q "frontend\dist" 2>nul
echo ✓ 临时 dist 目录已清理
)
cd frontend
call npm run build
if %errorlevel% neq 0 (
echo ✗ 构建前端失败
cd ..
call :cleanup
pause
exit /b 1
)
cd ..
echo.
echo [6/7] 构建应用...
wails build
if %errorlevel% neq 0 (
echo ✗ 构建失败
call :cleanup
pause
exit /b 1
)
echo.
echo [7/7] 复制运行时依赖...
if exist "bin" (
xcopy /E /I /Y bin build\bin\bin >nul
echo ✓ bin 目录已复制到 build\bin\bin\
) else (
echo [Warn] bin 目录不存在,跳过复制
)
echo.
echo ========================================
echo ✓ 构建成功!
echo ========================================
echo.
echo 可执行文件位置: build\bin\ant-chrome.exe
echo.
REM 清理代理配置
call :cleanup
pause
+167
View File
@@ -0,0 +1,167 @@
@echo off
setlocal EnableExtensions EnableDelayedExpansion
cd /d "%~dp0.."
echo ========================================
echo Ant Chrome - Dev Launcher
echo ========================================
echo.
echo Current workdir: %CD%
echo.
call :cleanup_dev_logs
echo Cleaning stale processes...
taskkill /F /IM ant-chrome-dev.exe >nul 2>&1
taskkill /F /IM ant-chrome.exe >nul 2>&1
echo.
set FRONTEND_PORT=5218
set PORT_ERROR=0
set TEMP_DEV_DIST_CREATED=0
set TEMP_DEV_PLACEHOLDER_CREATED=0
call :cleanup_local_vite_port %FRONTEND_PORT%
echo Checking port status...
call :check_port %FRONTEND_PORT%
if "!PORT_ERROR!"=="1" (
echo.
echo Please close the process using the occupied port and retry.
pause
exit /b 1
)
echo.
set GOPROXY=https://goproxy.cn,direct
echo Checking dependencies...
if not exist "go.sum" (
echo Installing Go dependencies...
go mod download
go mod tidy
)
if not exist "frontend\node_modules" (
echo Installing frontend dependencies...
pushd frontend
call npm install
popd
)
echo.
echo Regenerating Wails bindings...
if not exist "frontend\dist" (
mkdir "frontend\dist"
set TEMP_DEV_DIST_CREATED=1
)
if not exist "frontend\dist\__wails_placeholder__.txt" (
echo placeholder> "frontend\dist\__wails_placeholder__.txt"
set TEMP_DEV_PLACEHOLDER_CREATED=1
)
wails generate module
if errorlevel 1 (
call :cleanup_temp_dist
echo [ERROR] Failed to generate Wails bindings.
pause
exit /b 1
)
if exist "frontend\wailsjs" (
xcopy /E /I /Y "frontend\wailsjs" "frontend\src\wailsjs" >nul
)
if not exist "frontend\src\wailsjs" (
call :cleanup_temp_dist
echo [ERROR] Wails bindings output folder not found.
pause
exit /b 1
)
call :cleanup_temp_dist
echo.
echo Starting dev server...
echo Frontend URL: http://127.0.0.1:%FRONTEND_PORT%
echo Wails dev endpoint: auto-select
echo.
wails dev -viteservertimeout 60
set EXIT_CODE=%errorlevel%
if not "%EXIT_CODE%"=="0" (
echo.
echo [ERROR] wails dev exited with code %EXIT_CODE%.
)
pause
exit /b %EXIT_CODE%
:cleanup_temp_dist
if "%TEMP_DEV_PLACEHOLDER_CREATED%"=="1" (
del /F /Q "frontend\dist\__wails_placeholder__.txt" >nul 2>&1
)
if "%TEMP_DEV_DIST_CREATED%"=="1" (
rmdir /S /Q "frontend\dist" >nul 2>&1
)
exit /b 0
:cleanup_dev_logs
for %%f in (
"tmp-npm-dev.err.log"
"tmp-npm-dev.log"
"tmp-wails-err.log"
"tmp-wails-out.log"
"tmp-wails2-err.log"
"tmp-wails2-out.log"
"tmp-wails3-err.log"
"tmp-wails3-out.log"
"tmp-wails.err"
"wails-dev-capture.log"
"wails-dev-run.log"
"wails-dev-stderr.log"
"wails-dev-stdout.log"
) do (
if exist %%~f del /F /Q %%~f >nul 2>&1
)
exit /b 0
:cleanup_local_vite_port
set "CHECK_PORT=%~1"
set "CHECK_PID="
set "CHECK_CMDLINE="
for /f "usebackq delims=" %%a in (`powershell -NoProfile -Command "$port=%CHECK_PORT%; $procId=(Get-NetTCPConnection -State Listen -LocalPort $port -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty OwningProcess); if($procId){Write-Output $procId}"`) do (
set "CHECK_PID=%%a"
)
if not defined CHECK_PID exit /b 0
for /f "usebackq delims=" %%a in (`powershell -NoProfile -Command "$line=Get-CimInstance Win32_Process | Where-Object { $_.ProcessId -eq %CHECK_PID% } | Select-Object -First 1 -ExpandProperty CommandLine; if($line){Write-Output $line}"`) do (
set "CHECK_CMDLINE=%%a"
)
echo !CHECK_CMDLINE! | findstr /I /C:"%CD%\frontend" >nul
set "MATCH_PROJECT=!errorlevel!"
echo !CHECK_CMDLINE! | findstr /I /C:"vite" >nul
set "MATCH_VITE=!errorlevel!"
if "!MATCH_PROJECT!"=="0" if "!MATCH_VITE!"=="0" (
echo Cleaning stale local Vite process on port %CHECK_PORT% ^(PID !CHECK_PID!^)...
taskkill /F /PID !CHECK_PID! /T >nul 2>&1
timeout /t 1 /nobreak >nul
)
exit /b 0
:check_port
set "CHECK_PORT=%~1"
set "CHECK_PID="
for /f "usebackq delims=" %%a in (`powershell -NoProfile -Command "$port=%CHECK_PORT%; $procId=(Get-NetTCPConnection -State Listen -LocalPort $port -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty OwningProcess); if($procId){Write-Output $procId}"`) do (
set "CHECK_PID=%%a"
)
if defined CHECK_PID (
set PORT_ERROR=1
echo [ERROR] Port %CHECK_PORT% is occupied. PID: !CHECK_PID!
) else (
echo [OK] Port %CHECK_PORT% is available.
)
exit /b 0
+80
View File
@@ -0,0 +1,80 @@
@echo off
chcp 65001 >nul
setlocal enabledelayedexpansion
REM Change to repository root (parent directory of this script).
cd /d "%~dp0.."
set "NO_PAUSE=0"
if /I "%~1"=="--no-pause" set "NO_PAUSE=1"
set "TEMP_DIST_CREATED=0"
set "TEMP_PLACEHOLDER_CREATED=0"
echo ========================================
echo Generate Wails Bindings
echo ========================================
echo.
echo Working directory: %CD%
echo.
echo [1/3] Ensure frontend\dist exists...
if not exist "frontend\dist" (
mkdir "frontend\dist"
set "TEMP_DIST_CREATED=1"
echo Created temporary dist directory.
) else (
echo Dist directory already exists.
)
if not exist "frontend\dist\__wails_placeholder__.txt" (
echo placeholder> "frontend\dist\__wails_placeholder__.txt"
set "TEMP_PLACEHOLDER_CREATED=1"
echo Created temporary placeholder file.
)
echo.
echo [2/3] Regenerating Wails bindings...
wails generate module
if errorlevel 1 (
echo Failed to regenerate Wails bindings.
goto :cleanup_fail
)
echo.
echo [3/3] Verify bindings output...
if exist "frontend\wailsjs" (
xcopy /E /I /Y "frontend\wailsjs" "frontend\src\wailsjs" >nul
echo Bindings copied from frontend\wailsjs to frontend\src\wailsjs.
) else if exist "frontend\src\wailsjs" (
echo Bindings already generated in frontend\src\wailsjs.
) else (
echo Cannot find generated bindings in frontend\wailsjs or frontend\src\wailsjs.
goto :cleanup_fail
)
call :cleanup
echo.
echo ========================================
echo Done
echo ========================================
echo.
if not "%NO_PAUSE%"=="1" pause
exit /b 0
:cleanup
if "!TEMP_PLACEHOLDER_CREATED!"=="1" (
del /Q "frontend\dist\__wails_placeholder__.txt" >nul 2>&1
)
if "!TEMP_DIST_CREATED!"=="1" (
rmdir /S /Q "frontend\dist" >nul 2>&1
)
exit /b 0
:cleanup_fail
call :cleanup
if not "%NO_PAUSE%"=="1" pause
exit /b 1
+248
View File
@@ -0,0 +1,248 @@
@echo off
chcp 65001 >nul
setlocal enabledelayedexpansion
REM 切换到项目根目录(脚本所在目录的上一级)
cd /d "%~dp0.."
echo ========================================
echo Ant Browser - 发布打包脚本
echo ========================================
echo.
echo 当前工作目录: %CD%
echo.
REM ======== [1/6] 检测 NSIS ========
echo [1/6] 检测 NSIS 安装...
echo 支持环境变量:MAKENSIS_PATH / NSIS_PATH / NSIS_HOME
echo.
set "MAKENSIS="
REM 优先级 1MAKENSIS_PATH 直接指向 makensis.exe
if defined MAKENSIS_PATH (
if exist "!MAKENSIS_PATH!" (
set "MAKENSIS=!MAKENSIS_PATH!"
goto :nsis_found
)
)
REM 优先级 2NSIS_PATH 可以是 makensis.exe 或 NSIS 目录
if defined NSIS_PATH (
if exist "!NSIS_PATH!\makensis.exe" (
set "MAKENSIS=!NSIS_PATH!\makensis.exe"
goto :nsis_found
)
if exist "!NSIS_PATH!" (
set "MAKENSIS=!NSIS_PATH!"
goto :nsis_found
)
)
REM 优先级 3NSIS_HOME 为 NSIS 安装根目录
if defined NSIS_HOME (
if exist "!NSIS_HOME!\makensis.exe" (
set "MAKENSIS=!NSIS_HOME!\makensis.exe"
goto :nsis_found
)
)
REM 优先级 4:系统 PATH
for /f "delims=" %%i in ('where makensis.exe 2^>nul') do (
set "MAKENSIS=%%i"
goto :nsis_found
)
REM 优先级 5:常见安装目录
if exist "C:\Program Files (x86)\NSIS\makensis.exe" (
set "MAKENSIS=C:\Program Files (x86)\NSIS\makensis.exe"
goto :nsis_found
)
if exist "C:\Program Files\NSIS\makensis.exe" (
set "MAKENSIS=C:\Program Files\NSIS\makensis.exe"
goto :nsis_found
)
echo ✗ 未找到 NSISmakensis.exe
echo.
echo 请安装 NSIS 后,通过以下任一方式配置(PowerShell):
echo setx MAKENSIS_PATH "D:\tools\NSIS\makensis.exe"
echo setx NSIS_PATH "D:\tools\NSIS"
echo setx NSIS_HOME "D:\tools\NSIS"
echo.
echo 或下载安装:https://nsis.sourceforge.io/Download
echo.
pause
exit /b 1
:nsis_found
echo ✓ NSIS 已就绪: !MAKENSIS!
echo.
REM ======== [2/6] 读取版本号 ========
echo [2/6] 读取版本号...
set "VERSION="
for /f "usebackq delims=" %%v in (`powershell -NoProfile -Command "(Get-Content wails.json | ConvertFrom-Json).info.productVersion"`) do (
set "VERSION=%%v"
)
if "!VERSION!"=="" (
echo ✗ 无法从 wails.json 读取版本号
pause
exit /b 1
)
echo ✓ 版本号: !VERSION!
echo.
REM ======== [3/6] Wails 构建 ========
echo [3/6] 执行 Wails 构建...
set GOPROXY=https://goproxy.cn,direct
wails build
if %errorlevel% neq 0 (
echo ✗ Wails 构建失败
pause
exit /b 1
)
if not exist "build\bin\ant-chrome.exe" (
echo ✗ 构建产物不存在: build\bin\ant-chrome.exe
pause
exit /b 1
)
echo ✓ 构建成功: build\bin\ant-chrome.exe
echo.
REM ======== [4/6] 组装 staging 目录 ========
echo [4/6] 组装 staging 目录...
set "STAGING=publish\staging"
set "RELEASE_CONFIG=publish\config.init.yaml"
if exist "!STAGING!" rmdir /S /Q "!STAGING!"
mkdir "!STAGING!"
copy /Y "build\bin\ant-chrome.exe" "!STAGING!\ant-chrome.exe" >nul
if errorlevel 1 (
echo ✗ 复制 ant-chrome.exe 失败
rmdir /S /Q "!STAGING!"
pause
exit /b 1
)
if not exist "!STAGING!\ant-chrome.exe" (
echo ✗ staging 中缺少 ant-chrome.exe
rmdir /S /Q "!STAGING!"
pause
exit /b 1
)
echo ✓ 复制 ant-chrome.exe
if not exist "!RELEASE_CONFIG!" (
echo ✗ 未找到发布配置模板: !RELEASE_CONFIG!
rmdir /S /Q "!STAGING!"
pause
exit /b 1
)
copy /Y "!RELEASE_CONFIG!" "!STAGING!\config.yaml" >nul
if errorlevel 1 (
echo ✗ 复制发布配置模板失败: !RELEASE_CONFIG!
rmdir /S /Q "!STAGING!"
pause
exit /b 1
)
if not exist "!STAGING!\config.yaml" (
echo ✗ staging 中缺少 config.yaml(来源: !RELEASE_CONFIG!
rmdir /S /Q "!STAGING!"
pause
exit /b 1
)
echo ✓ 复制发布配置模板 !RELEASE_CONFIG! -> config.yaml
if not exist "bin" (
echo ✗ bin\ 目录不存在,缺少代理运行时文件
rmdir /S /Q "!STAGING!"
pause
exit /b 1
)
if not exist "bin\xray.exe" (
echo ✗ 缺少运行时文件: bin\xray.exe
rmdir /S /Q "!STAGING!"
pause
exit /b 1
)
if not exist "bin\sing-box.exe" (
echo ✗ 缺少运行时文件: bin\sing-box.exe
rmdir /S /Q "!STAGING!"
pause
exit /b 1
)
xcopy /E /I /Y bin "!STAGING!\bin" >nul
if not exist "!STAGING!\bin\xray.exe" (
echo ✗ 复制后仍缺少 !STAGING!\bin\xray.exe
rmdir /S /Q "!STAGING!"
pause
exit /b 1
)
if not exist "!STAGING!\bin\sing-box.exe" (
echo ✗ 复制后仍缺少 !STAGING!\bin\sing-box.exe
rmdir /S /Q "!STAGING!"
pause
exit /b 1
)
echo ✓ 复制 bin\xray.exe, sing-box.exe
if not exist "chrome" (
echo ✗ chrome\ 目录不存在,Chrome 内核为必需文件
rmdir /S /Q "!STAGING!"
pause
exit /b 1
)
xcopy /E /I /Y chrome "!STAGING!\chrome" >nul
echo ✓ 复制 chrome\
mkdir "!STAGING!\data"
echo ✓ 创建空 data 目录(不打包 app.db,首次启动自动初始化)
echo.
echo ✓ staging 目录组装完成
echo.
REM ======== [5/6] NSIS 打包 ========
echo [5/6] 调用 NSIS 打包...
if not exist "publish\output" mkdir "publish\output"
REM 确保 installer.nsi 是 UTF-8 with BOMNSIS Unicode True 要求)
powershell -NoProfile -Command "$f=(Resolve-Path 'publish\installer.nsi').Path; $c=[System.IO.File]::ReadAllText($f,[System.Text.Encoding]::UTF8); [System.IO.File]::WriteAllText($f,$c,[System.Text.UTF8Encoding]::new($true))" >nul
for /f "usebackq delims=" %%p in (`powershell -NoProfile -Command "(Resolve-Path '!STAGING!').Path"`) do (
set "STAGING_ABS=%%p"
)
"!MAKENSIS!" /DVERSION=!VERSION! "/DSTAGINGDIR=!STAGING_ABS!" publish\installer.nsi
if %errorlevel% neq 0 (
echo ✗ NSIS 打包失败
rmdir /S /Q "!STAGING!"
pause
exit /b 1
)
echo ✓ 安装包生成成功
echo.
REM ======== [6/6] 清理 staging ========
echo [6/6] 清理临时文件...
rmdir /S /Q "!STAGING!"
echo ✓ staging 目录已清理
echo.
echo ========================================
echo ✓ 发布完成!
echo ========================================
echo.
echo 安装包位置: publish\output\AntBrowser-Setup-!VERSION!.exe
echo.
echo 提示:用户安装后可将旧的 data\ 目录粘贴到安装目录覆盖初始数据
echo.
pause