feat: Add SQLite database support and fixed portable extraction path
- Add SQLite as alternative database for offline/firewall environments - Add --database-type parameter to build-client.bat (mysql/sqlite) - Refactor database.py to support both MySQL and SQLite - Add DB_TYPE and SQLITE_PATH configuration options - Set fixed unpackDirName for portable exe (Meeting-Assistant) - Update DEPLOYMENT.md with SQLite mode documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -27,6 +27,7 @@ set "SKIP_BACKEND=true"
|
||||
set "EMBEDDED_BACKEND=false"
|
||||
set "CLEAN_BUILD=false"
|
||||
set "API_URL="
|
||||
set "DATABASE_TYPE="
|
||||
|
||||
REM 解析參數
|
||||
set "COMMAND=help"
|
||||
@@ -42,6 +43,7 @@ if /i "%~1"=="--skip-backend" (set "SKIP_BACKEND=true" & shift & goto :parse_arg
|
||||
if /i "%~1"=="--embedded-backend" (set "EMBEDDED_BACKEND=true" & set "SKIP_BACKEND=false" & shift & goto :parse_args)
|
||||
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)
|
||||
echo %RED%[ERROR]%NC% 未知參數: %~1
|
||||
goto :show_help
|
||||
|
||||
@@ -324,6 +326,42 @@ if errorlevel 1 (
|
||||
echo %GREEN%[OK]%NC% 已啟用內嵌後端模式
|
||||
goto :eof
|
||||
|
||||
:update_config_database
|
||||
REM 更新 config.json 的資料庫類型
|
||||
if "%DATABASE_TYPE%"=="" goto :eof
|
||||
|
||||
echo %BLUE%[STEP]%NC% 設定資料庫類型...
|
||||
|
||||
set "CONFIG_FILE=%CLIENT_DIR%\config.json"
|
||||
if not exist "%CONFIG_FILE%" (
|
||||
echo %YELLOW%[WARN]%NC% 找不到 config.json,跳過資料庫類型設定
|
||||
goto :eof
|
||||
)
|
||||
|
||||
REM 驗證資料庫類型
|
||||
if /i not "%DATABASE_TYPE%"=="mysql" if /i not "%DATABASE_TYPE%"=="sqlite" (
|
||||
echo %RED%[ERROR]%NC% 無效的資料庫類型: %DATABASE_TYPE%
|
||||
echo %BLUE%[INFO]%NC% 有效選項: mysql, sqlite
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM 使用 PowerShell 更新 database.type (使用 UTF8 without BOM)
|
||||
if /i "%DATABASE_TYPE%"=="sqlite" (
|
||||
REM SQLite 模式: 設定 type=sqlite,清空 MySQL 連線資訊
|
||||
powershell -Command "$config = Get-Content '%CONFIG_FILE%' -Raw | ConvertFrom-Json; $config.backend.database.type = 'sqlite'; $config.backend.database.host = ''; $config.backend.database.user = ''; $config.backend.database.password = ''; $config.backend.database.database = ''; $json = $config | ConvertTo-Json -Depth 10; [System.IO.File]::WriteAllText('%CONFIG_FILE%', $json, [System.Text.UTF8Encoding]::new($false))"
|
||||
echo %GREEN%[OK]%NC% 資料庫類型已設定為: SQLite (本地模式)
|
||||
) else (
|
||||
REM MySQL 模式: 僅設定 type=mysql,保留連線資訊
|
||||
powershell -Command "$config = Get-Content '%CONFIG_FILE%' -Raw | ConvertFrom-Json; $config.backend.database.type = 'mysql'; $json = $config | ConvertTo-Json -Depth 10; [System.IO.File]::WriteAllText('%CONFIG_FILE%', $json, [System.Text.UTF8Encoding]::new($false))"
|
||||
echo %GREEN%[OK]%NC% 資料庫類型已設定為: MySQL (雲端模式)
|
||||
)
|
||||
|
||||
if errorlevel 1 (
|
||||
echo %RED%[ERROR]%NC% 更新 config.json database.type 失敗
|
||||
exit /b 1
|
||||
)
|
||||
goto :eof
|
||||
|
||||
:setup_client
|
||||
echo %BLUE%[STEP]%NC% 設置前端建置環境...
|
||||
|
||||
@@ -436,6 +474,9 @@ call :update_config
|
||||
REM 更新 embedded backend 設定(如果有指定)
|
||||
call :update_config_embedded
|
||||
|
||||
REM 更新資料庫類型設定(如果有指定)
|
||||
call :update_config_database
|
||||
|
||||
if "%SKIP_SIDECAR%"=="false" (
|
||||
call :setup_sidecar_venv
|
||||
call :build_sidecar
|
||||
@@ -506,11 +547,13 @@ echo --api-url URL 後端 API URL (預設: http://localhost:8000/api)
|
||||
echo --skip-sidecar 跳過 Sidecar 打包
|
||||
echo --skip-backend 跳過 Backend 打包 (預設)
|
||||
echo --embedded-backend 打包內嵌後端 (全包部署模式)
|
||||
echo --database-type TYPE 資料庫類型: mysql (雲端) 或 sqlite (本地)
|
||||
echo --clean 建置前先清理
|
||||
echo.
|
||||
echo 範例:
|
||||
echo %~nx0 build 完整建置 (前端+Sidecar)
|
||||
echo %~nx0 build --embedded-backend 全包部署 (含內嵌後端)
|
||||
echo %~nx0 build --embedded-backend --database-type sqlite 全包部署 + SQLite
|
||||
echo %~nx0 build --api-url "http://192.168.1.100:8000/api" 指定遠端後端
|
||||
echo %~nx0 sidecar 僅打包 Sidecar
|
||||
echo %~nx0 electron --skip-sidecar 僅打包 Electron
|
||||
@@ -519,6 +562,10 @@ echo 部署模式:
|
||||
echo 分離部署(預設): 前端連接遠端後端,使用 --api-url 指定後端地址
|
||||
echo 全包部署: 使用 --embedded-backend 將後端打包進 exe,雙擊即可運行
|
||||
echo.
|
||||
echo 資料庫模式:
|
||||
echo MySQL(預設): 連接雲端資料庫,需要網路存取
|
||||
echo SQLite: 本地資料庫,適合離線或防火牆環境,使用 --database-type sqlite
|
||||
echo.
|
||||
echo 注意:
|
||||
echo - 首次打包 Sidecar 需下載 Whisper 模型,可能需要較長時間
|
||||
echo - 全包部署需要額外約 50MB 空間用於後端
|
||||
|
||||
Reference in New Issue
Block a user