feat: Add NSIS installer target and persistent SQLite storage

- Add NSIS installer as default target (--target nsis)
- Keep portable option available (--target portable)
- Store SQLite database in %APPDATA%\Meeting-Assistant for persistence
- Portable temp folder cleanup no longer affects SQLite data
- Update build-client.bat with --target parameter support
- Update DEPLOYMENT.md with new options and comparisons

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
egg
2025-12-18 08:13:32 +08:00
parent bc37a5392a
commit 08cffbb74a
4 changed files with 113 additions and 17 deletions

View File

@@ -28,6 +28,7 @@ set "EMBEDDED_BACKEND=false"
set "CLEAN_BUILD=false"
set "API_URL="
set "DATABASE_TYPE="
set "BUILD_TARGET=nsis"
REM 解析參數
set "COMMAND=help"
@@ -44,6 +45,7 @@ if /i "%~1"=="--embedded-backend" (set "EMBEDDED_BACKEND=true" & set "SKIP_BACKE
if /i "%~1"=="--clean" (set "CLEAN_BUILD=true" & shift & goto :parse_args)
if /i "%~1"=="--api-url" (set "API_URL=%~2" & shift & shift & goto :parse_args)
if /i "%~1"=="--database-type" (set "DATABASE_TYPE=%~2" & shift & shift & goto :parse_args)
if /i "%~1"=="--target" (set "BUILD_TARGET=%~2" & shift & shift & goto :parse_args)
echo %RED%[ERROR]%NC% 未知參數: %~1
goto :show_help
@@ -399,7 +401,20 @@ echo %BLUE%[STEP]%NC% 打包 Electron 應用...
cd /d "%CLIENT_DIR%"
echo %BLUE%[INFO]%NC% 目標平台: Windows (Portable)
REM 驗證 BUILD_TARGET
if /i not "%BUILD_TARGET%"=="nsis" if /i not "%BUILD_TARGET%"=="portable" (
echo %RED%[ERROR]%NC% 無效的打包目標: %BUILD_TARGET%
echo %BLUE%[INFO]%NC% 有效選項: nsis, portable
exit /b 1
)
if /i "%BUILD_TARGET%"=="nsis" (
echo %BLUE%[INFO]%NC% 目標平台: Windows (NSIS 安裝檔) - 推薦
) else (
echo %BLUE%[INFO]%NC% 目標平台: Windows (Portable)
echo %YELLOW%[WARN]%NC% 注意: Portable 模式的臨時資料夾會在關閉時清空
echo %YELLOW%[WARN]%NC% SQLite 資料庫已自動儲存到 %%APPDATA%%\Meeting-Assistant
)
REM 清理可能損壞的 electron-builder 快取(解決 symlink 問題)
set "EB_CACHE=%LOCALAPPDATA%\electron-builder\Cache\winCodeSign"
@@ -412,9 +427,9 @@ echo %BLUE%[INFO]%NC% 執行 electron-builder...
REM 使用 npm run build 或直接執行 node_modules 中的 electron-builder
if exist "node_modules\.bin\electron-builder.cmd" (
call "node_modules\.bin\electron-builder.cmd" --win
call "node_modules\.bin\electron-builder.cmd" --win %BUILD_TARGET%
) else (
call npx electron-builder --win
call npx electron-builder --win %BUILD_TARGET%
)
if errorlevel 1 (
@@ -457,9 +472,19 @@ dir /b "%BUILD_DIR%"
echo.
echo %GREEN%[OK]%NC% 打包完成!
echo.
echo Windows 使用說明:
echo 1. 找到 build\ 中的 .exe 檔案
echo 2. 直接執行即可,無需安裝
if /i "%BUILD_TARGET%"=="nsis" (
echo Windows 使用說明 (NSIS 安裝檔):
echo 1. 找到 build\ 中的 *-setup.exe 檔案
echo 2. 執行安裝檔,選擇安裝目錄
echo 3. 安裝後從開始選單或桌面捷徑啟動
echo 4. 資料會持久保存在安裝目錄中
) else (
echo Windows 使用說明 (Portable):
echo 1. 找到 build\ 中的 *-portable.exe 檔案
echo 2. 直接執行,無需安裝
echo 3. 注意: 關閉程式後臨時檔案會清空
echo 4. SQLite 資料庫保存在 %%APPDATA%%\Meeting-Assistant
)
echo.
goto :eof
@@ -550,12 +575,14 @@ echo --skip-sidecar 跳過 Sidecar 打包
echo --skip-backend 跳過 Backend 打包 (預設)
echo --embedded-backend 打包內嵌後端 (全包部署模式)
echo --database-type TYPE 資料庫類型: mysql (雲端) 或 sqlite (本地)
echo --target TARGET 打包目標: nsis (安裝檔, 預設) 或 portable (免安裝)
echo --clean 建置前先清理
echo.
echo 範例:
echo %~nx0 build 完整建置 (前端+Sidecar)
echo %~nx0 build 完整建置 (NSIS 安裝檔)
echo %~nx0 build --embedded-backend 全包部署 (含內嵌後端)
echo %~nx0 build --embedded-backend --database-type sqlite 全包部署 + SQLite
echo %~nx0 build --target portable 打包為免安裝 Portable
echo %~nx0 build --api-url "http://192.168.1.100:8000/api" 指定遠端後端
echo %~nx0 sidecar 僅打包 Sidecar
echo %~nx0 electron --skip-sidecar 僅打包 Electron
@@ -564,6 +591,11 @@ echo 部署模式:
echo 分離部署(預設): 前端連接遠端後端,使用 --api-url 指定後端地址
echo 全包部署: 使用 --embedded-backend 將後端打包進 exe雙擊即可運行
echo.
echo 打包目標:
echo nsis預設: 產生安裝檔,安裝後資料持久保存,推薦正式使用
echo portable: 產生免安裝 exe臨時資料夾會在關閉時清空
echo SQLite 資料庫會自動儲存到 %%APPDATA%%\Meeting-Assistant
echo.
echo 資料庫模式:
echo MySQL預設: 連接雲端資料庫,需要網路存取
echo SQLite: 本地資料庫,適合離線或防火牆環境,使用 --database-type sqlite