feat(sync): add cloud synchronization for favorites

Add a new sync service and frontend integration to allow syncing
favorites across devices using a token.

- Configure `sync-service` in docker-compose.yml on port 7482
- Add sync token input and manual sync button to SideDrawer
- Implement auto-sync logic to persist favorites to the KV store
- Add logic to merge cloud favorites with local data on initialization
This commit is contained in:
史悦
2026-01-06 11:20:06 +08:00
parent 33e3ec714e
commit ca1026d166
5 changed files with 215 additions and 2 deletions

27
nginx.conf.example Normal file
View File

@@ -0,0 +1,27 @@
server {
listen 80;
server_name your-domain.com;
# 前端静态资源 (Music Canvas)
location / {
proxy_pass http://127.0.0.1:7481;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# 同步服务 API 代理
# 将 /api/kv/... 转发到 sync-service 的 7482 端口
# 注意:这里去掉了 /api 前缀,因为 sync-service 直接监听 /kv
location /api/ {
proxy_pass http://127.0.0.1:7482/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# 允许跨域 (如果前端和后端不在同一个域)
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
}
}