mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-14 05:03:43 +08:00
更新同步模块
This commit is contained in:
@@ -28,7 +28,7 @@ const DEFAULT_SYNC_STATE = {
|
||||
proxyUrl: ApiPath.Cors as string,
|
||||
|
||||
webdav: {
|
||||
endpoint: "",
|
||||
endpoint: "https://dav.jyj.cx",
|
||||
username: "",
|
||||
password: "",
|
||||
},
|
||||
@@ -88,7 +88,7 @@ export const useSyncStore = createPersistStore(
|
||||
return client;
|
||||
},
|
||||
|
||||
async sync() {
|
||||
async sync(overwrite = false) {
|
||||
const localState = getLocalAppState();
|
||||
const provider = get().provider;
|
||||
const config = get()[provider];
|
||||
@@ -103,11 +103,13 @@ export const useSyncStore = createPersistStore(
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
const parsedRemoteState = JSON.parse(
|
||||
await client.get(config.username),
|
||||
) as AppState;
|
||||
mergeAppState(localState, parsedRemoteState);
|
||||
setLocalAppState(localState);
|
||||
if (!overwrite) {
|
||||
const parsedRemoteState = JSON.parse(
|
||||
await client.get(config.username),
|
||||
) as AppState;
|
||||
mergeAppState(localState, parsedRemoteState);
|
||||
setLocalAppState(localState);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("[Sync] failed to get remote state", e);
|
||||
@@ -119,6 +121,10 @@ export const useSyncStore = createPersistStore(
|
||||
this.markSyncTime();
|
||||
},
|
||||
|
||||
async overwrite() {
|
||||
await this.sync(true);
|
||||
},
|
||||
|
||||
async check() {
|
||||
const client = this.getClient();
|
||||
return await client.check();
|
||||
|
||||
Reference in New Issue
Block a user