sync: 各端互通引擎就位 —— wire 应用/拉取(LWW+FK uuid 映射)接入 /sync/push|pull,桌面与网页同库

This commit is contained in:
root
2026-10-16 15:46:51 +08:00
parent ae278379af
commit 9d97384aaf
4 changed files with 189 additions and 4 deletions
+3 -2
View File
@@ -126,10 +126,11 @@ const server = http.createServer(async (req, res) => {
if (req.method === 'POST' && route === '/sync/push') {
const body = await readJson(req);
return send(200, true, push(auth.user_id, body.changes));
// wire 变更直接应用到该用户档案库(网页版立即可见);generate_changes 由档案库 oplog 驱动
return send(200, true, commandsFor(auth.user_id).applyWireBatch(body.changes));
}
if (req.method === 'GET' && route === '/sync/pull') {
return send(200, true, pull(auth.user_id, url.searchParams.get('cursor'), url.searchParams.get('limit')));
return send(200, true, commandsFor(auth.user_id).pullWire(url.searchParams.get('cursor'), url.searchParams.get('limit')));
}
if (req.method === 'POST' && route === '/sync/attachment') {
const body = await readJson(req);