Files
momentry_portal/README.md
2026-05-20 08:29:37 +08:00

136 lines
3.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Momentry Portal
基於 Tauri + Vue 3 的影片搜尋與身份管理桌面應用程式。
## 功能
1. **影片搜尋**: 智能搜尋影片內容
2. **身份管理**: 管理全域身份、區域人物
3. **臉部管理**: 查看和下載人物臉部截圖
## 環境需求
- Node.js 18+
- Rust 1.70+
- npm 或 yarn
## 安裝與執行
```bash
# 進入專案目錄
cd portal
# 安裝前端依賴
npm install
# 開發模式 (同時啟動 Vue 和 Tauri)
npm run tauri dev
# 或分別啟動
npm run dev # 啟動 Vue dev server (port 1420)
npm run tauri dev # 啟動 Tauri desktop app
```
## 專案結構
```
portal/
├── src-tauri/ # Rust 後端
│ ├── src/
│ │ ├── main.rs # Tauri 入口
│ │ ├── config.rs # 組態管理
│ │ └── api/ # API 處理常式
│ │ ├── search.rs # 搜尋 API
│ │ ├── identity.rs # 身份管理 API
│ │ ├── video.rs # 影片 API
│ │ └── person.rs # 人物/臉部 API
│ ├── Cargo.toml
│ └── tauri.conf.json
├── src/ # Vue 前端
│ ├── main.ts
│ ├── App.vue
│ ├── router.ts
│ ├── views/
│ │ ├── HomeView.vue
│ │ ├── SearchView.vue
│ │ ├── IdentitiesView.vue
│ │ └── VideoDetailView.vue
│ └── assets/
├── package.json
├── vite.config.ts
└── tailwind.config.js
```
## API 環境
Portal 連接到 Momentry Core API Server支援兩種環境
### 環境配置
| 環境 | API URL | Port | Redis Prefix | Schema | 用途 |
|------|---------|------|--------------|--------|------|
| **生產環境** | `http://127.0.0.1:3002` | 3002 | `momentry:` | `public` | 正式數據 |
| **開發環境** | `http://127.0.0.1:3003` | 3003 | `momentry_dev:` | `dev` | 測試數據 |
### 啟動 API Server
```bash
# 生產環境 (port 3002, schema=public)
cargo run --bin momentry -- server
# 開發環境 (port 3003, schema=dev)
DATABASE_SCHEMA=dev cargo run --bin momentry_playground -- server
```
### Portal 配置
Portal 預設連接開發環境 (3003),可透過環境變數切換:
```bash
# 切換到生產環境
export MOMENTRY_API_URL="http://127.0.0.1:3002"
# 啟動 Portal
cd portal && npm run tauri dev
```
### API Key
API Key 用於認證 Portal 與 API Server 的通訊:
```bash
export MOMENTRY_API_KEY="muser_68600856036340bcafc01930eb4bd839_1774418104_97221b69"
```
**注意**: 開發環境 (dev schema) 的 API Key hash 必須與 `dev.api_keys` 表中的資料一致。
### 檢查 API 連接
```bash
# 檢查 API Server 狀態
curl http://localhost:3003/api/v1/videos -H "X-API-Key: $MOMENTRY_API_KEY"
# 檢查 Schema
psql -U accusys -d momentry -c "SELECT table_name FROM information_schema.tables WHERE table_schema = 'dev';"
```
## 環境變數
可在 `src-tauri/src/config.rs` 中修改,或設定環境變數:
```bash
export MOMENTRY_API_URL="http://127.0.0.1:3002"
export MOMENTRY_API_KEY="your-api-key"
```
## API 對應
| 前端功能 | Tauri Command | 對應 Momentry API |
|---------|---------------|-------------------|
| 搜尋 | `search_videos` | `POST /api/v1/n8n/search` |
| 身份列表 | `list_identities` | `POST /api/v1/identities/search` |
| 註冊身份 | `register_identity` | `POST /api/v1/person/:id/register` |
| 影片列表 | `list_videos` | `GET /api/v1/videos` |
| 影片臉部 | `get_video_faces` | `GET /api/v1/videos/:uuid/faces` |
| 下載截圖 | `get_person_thumbnail` | `GET /api/v1/person/:id/thumbnail` |