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:
109
DEPLOYMENT.md
109
DEPLOYMENT.md
@@ -4,7 +4,7 @@
|
||||
|
||||
- Python 3.10+
|
||||
- Node.js 18+
|
||||
- MySQL 8.0+
|
||||
- MySQL 8.0+ 或 SQLite(本地模式)
|
||||
- Access to Dify LLM service
|
||||
|
||||
## Quick Start
|
||||
@@ -233,18 +233,32 @@ npm start
|
||||
- 企業內部部署,簡化用戶操作
|
||||
- 無法獨立架設後端的環境
|
||||
- 快速測試和演示
|
||||
- **離線環境**:使用 SQLite 本地資料庫,無需網路連接資料庫
|
||||
|
||||
### 打包方式
|
||||
|
||||
```batch
|
||||
# Windows 全包打包
|
||||
# Windows 全包打包(MySQL 雲端資料庫,預設)
|
||||
.\scripts\build-client.bat build --embedded-backend --clean
|
||||
|
||||
# Windows 全包打包(SQLite 本地資料庫,適合離線/防火牆環境)
|
||||
.\scripts\build-client.bat build --embedded-backend --database-type sqlite --clean
|
||||
```
|
||||
|
||||
**打包參數說明:**
|
||||
|
||||
| 參數 | 說明 |
|
||||
|------|------|
|
||||
| `--embedded-backend` | 啟用內嵌後端模式 |
|
||||
| `--database-type TYPE` | 資料庫類型:`mysql`(雲端)或 `sqlite`(本地) |
|
||||
| `--clean` | 建置前清理所有暫存檔案 |
|
||||
|
||||
### config.json 配置
|
||||
|
||||
全包模式需要在 `config.json` 中配置資料庫和 API 金鑰:
|
||||
|
||||
#### MySQL 模式(雲端資料庫)
|
||||
|
||||
```json
|
||||
{
|
||||
"apiBaseUrl": "http://localhost:8000/api",
|
||||
@@ -260,6 +274,8 @@ npm start
|
||||
"host": "127.0.0.1",
|
||||
"port": 8000,
|
||||
"database": {
|
||||
"type": "mysql",
|
||||
"sqlitePath": "data/meeting.db",
|
||||
"host": "mysql.theaken.com",
|
||||
"port": 33306,
|
||||
"user": "your_username",
|
||||
@@ -281,6 +297,45 @@ npm start
|
||||
}
|
||||
```
|
||||
|
||||
#### SQLite 模式(本地資料庫)
|
||||
|
||||
適合離線環境或網路防火牆阻擋資料庫連線的情況:
|
||||
|
||||
```json
|
||||
{
|
||||
"apiBaseUrl": "http://localhost:8000/api",
|
||||
"uploadTimeout": 600000,
|
||||
"appTitle": "Meeting Assistant",
|
||||
"whisper": {
|
||||
"model": "medium",
|
||||
"device": "cpu",
|
||||
"compute": "int8"
|
||||
},
|
||||
"backend": {
|
||||
"embedded": true,
|
||||
"host": "127.0.0.1",
|
||||
"port": 8000,
|
||||
"database": {
|
||||
"type": "sqlite",
|
||||
"sqlitePath": "data/meeting.db"
|
||||
},
|
||||
"externalApis": {
|
||||
"authApiUrl": "https://pj-auth-api.vercel.app/api/auth/login",
|
||||
"difyApiUrl": "https://dify.theaken.com/v1",
|
||||
"difyApiKey": "app-xxxxxxxxxx",
|
||||
"difySttApiKey": "app-xxxxxxxxxx"
|
||||
},
|
||||
"auth": {
|
||||
"adminEmail": "admin@example.com",
|
||||
"jwtSecret": "your_secure_jwt_secret",
|
||||
"jwtExpireHours": 24
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
> **注意**:SQLite 模式下,資料庫檔案位於 `%TEMP%\Meeting-Assistant\resources\backend\backend\data\meeting.db`
|
||||
|
||||
### 配置說明
|
||||
|
||||
| 區段 | 欄位 | 說明 |
|
||||
@@ -288,20 +343,40 @@ npm start
|
||||
| `backend.embedded` | `true`/`false` | 啟用/停用內嵌後端模式 |
|
||||
| `backend.host` | IP | 後端監聽地址(通常為 127.0.0.1) |
|
||||
| `backend.port` | 數字 | 後端監聽端口(預設 8000) |
|
||||
| `backend.database.*` | 各欄位 | MySQL 資料庫連線資訊 |
|
||||
| `backend.database.type` | `mysql`/`sqlite` | 資料庫類型(預設 mysql) |
|
||||
| `backend.database.sqlitePath` | 路徑 | SQLite 資料庫檔案路徑(相對或絕對) |
|
||||
| `backend.database.*` | 各欄位 | MySQL 資料庫連線資訊(僅 MySQL 模式需要) |
|
||||
| `backend.externalApis.*` | 各欄位 | 外部 API 設定(認證、Dify) |
|
||||
| `backend.auth.*` | 各欄位 | 認證設定(管理員信箱、JWT 金鑰) |
|
||||
|
||||
### 資料庫模式比較
|
||||
|
||||
| 特性 | MySQL 模式 | SQLite 模式 |
|
||||
|------|------------|-------------|
|
||||
| 網路需求 | 需連接遠端資料庫 | 完全離線運作 |
|
||||
| 資料位置 | 雲端資料庫伺服器 | 本機檔案 |
|
||||
| 多用戶共享 | ✅ 支援 | ❌ 僅單機使用 |
|
||||
| 適用場景 | 企業部署、多人共用 | 離線環境、防火牆限制 |
|
||||
| 資料備份 | 使用資料庫工具 | 複製 `.db` 檔案即可 |
|
||||
|
||||
### Portable 執行檔解壓縮位置
|
||||
|
||||
Portable exe 執行時會解壓縮到 `%TEMP%\Meeting-Assistant` 資料夾(固定路徑,非隨機資料夾)。
|
||||
|
||||
- **優點**:Windows Defender 不會每次都提示警告
|
||||
- **SQLite 資料庫位置**:`%TEMP%\Meeting-Assistant\resources\backend\backend\data\meeting.db`
|
||||
|
||||
### 啟動流程
|
||||
|
||||
1. 用戶雙擊 exe
|
||||
2. Electron 主程序啟動
|
||||
3. 讀取 `config.json`
|
||||
4. 啟動內嵌後端 (FastAPI)
|
||||
5. 健康檢查等待後端就緒(最多 30 秒)
|
||||
6. 後端就緒後,載入前端頁面
|
||||
7. 啟動 Whisper Sidecar
|
||||
8. 應用就緒
|
||||
2. 解壓縮到 `%TEMP%\Meeting-Assistant`
|
||||
3. Electron 主程序啟動
|
||||
4. 讀取 `config.json`
|
||||
5. 啟動內嵌後端 (FastAPI)
|
||||
6. 健康檢查等待後端就緒(最多 30 秒)
|
||||
7. 後端就緒後,載入前端頁面
|
||||
8. 啟動 Whisper Sidecar
|
||||
9. 應用就緒
|
||||
|
||||
### 向後相容性
|
||||
|
||||
@@ -367,6 +442,8 @@ Copy `sidecar/dist/` to `client/sidecar/` before building Electron app.
|
||||
|
||||
## Database Setup
|
||||
|
||||
### MySQL 模式
|
||||
|
||||
The backend will automatically create tables on first startup. To manually verify:
|
||||
|
||||
```sql
|
||||
@@ -374,7 +451,17 @@ USE your_database;
|
||||
SHOW TABLES LIKE 'meeting_%';
|
||||
```
|
||||
|
||||
Expected tables:
|
||||
### SQLite 模式
|
||||
|
||||
SQLite 資料庫檔案會在首次啟動時自動建立:
|
||||
|
||||
- **開發環境**:`backend/data/meeting.db`
|
||||
- **打包後**:`%TEMP%\Meeting-Assistant\resources\backend\backend\data\meeting.db`
|
||||
|
||||
**備份方式**:直接複製 `.db` 檔案即可。
|
||||
|
||||
### Expected tables
|
||||
|
||||
- `meeting_users`
|
||||
- `meeting_records`
|
||||
- `meeting_conclusions`
|
||||
|
||||
Reference in New Issue
Block a user