feat: add WebDAV sync support and startup/shutdown scripts

Backend:
- Add uuid, sync_version, is_deleted fields to all syncable models
- Add SyncSettings model for WebDAV configuration (AES-256-GCM encrypted passwords)
- Add crypto.py: AES-256-GCM encryption derived from JWT_SECRET via PBKDF2
- Add sync_lock.py: thread-level sync lock with 503 middleware for write blocking
- Add webdav.py: WebDAV client using requests (PUT/GET/MKCOL/DELETE)
- Add sync_service.py: push/pull/bidirectional merge with LWW conflict resolution
- Add sync router with 8 endpoints: config, test, push, pull, sync, status, remote delete
- Add UUID backfill for existing records in init_db()
- Add SQLAlchemy before_update event to auto-increment sync_version
- Register sync middleware to block writes during sync (503)

Frontend:
- Add sync API client (WebUI/src/api/sync.ts)
- Add useSyncStore with config, test, push/pull/sync operations
- Add WebDAV config + sync UI in SettingsView
- Add 503 status code handling in axios interceptor
- Add uuid field to all TypeScript type definitions

Scripts:
- Add scripts/start.bat and scripts/stop.bat for project management

Design doc: docs/plan/webdav-sync-design.md
This commit is contained in:
祀梦
2026-05-17 21:18:54 +08:00
parent 944d20dcc7
commit 0ab719500b
31 changed files with 2194 additions and 41 deletions

53
scripts/start.bat Normal file
View File

@@ -0,0 +1,53 @@
@echo off
chcp 65001 >nul 2>&1
title 爱莉希雅待办事项
echo ====================================================
echo 爱莉希雅待办事项 - 启动脚本
echo ====================================================
echo.
:: 项目根目录(脚本所在目录的上级)
set "PROJECT_ROOT=%~dp0.."
cd /d "%PROJECT_ROOT%"
:: 检查 Python
where python >nul 2>&1
if errorlevel 1 (
echo [错误] 未找到 Python请确保已安装并添加到 PATH
pause
exit /b 1
)
:: 检查依赖
if not exist "api\app\__init__.py" (
echo [错误] 未找到项目文件,请确认在项目根目录运行
pause
exit /b 1
)
:: 安装 Python 依赖(如需)
if not exist "api\__pycache__" (
echo [信息] 首次运行,安装 Python 依赖...
pip install -r requirements.txt -q
if errorlevel 1 (
echo [错误] Python 依赖安装失败
pause
exit /b 1
)
)
:: 检查端口占用
echo [信息] 检查端口 23994 占用情况...
for /f "tokens=5" %%a in ('netstat -ano -p TCP ^| findstr ":23994.*LISTENING"') do (
echo [警告] 端口 23994 已被进程 %%a 占用,正在尝试终止...
taskkill /PID %%a /F >nul 2>&1
timeout /t 2 /nobreak >nul
)
:: 启动项目
echo [信息] 正在启动项目...
echo [信息] 访问地址: http://localhost:23994
echo.
python main.py
pause