forked from XiaoMo/ChatGPT-Next-Web
feat: auto fill upstash backup name
This commit is contained in:
parent
83fed42997
commit
f1e7db6a88
@ -22,27 +22,29 @@ export interface WebDavConfig {
|
|||||||
|
|
||||||
export type SyncStore = GetStoreState<typeof useSyncStore>;
|
export type SyncStore = GetStoreState<typeof useSyncStore>;
|
||||||
|
|
||||||
export const useSyncStore = createPersistStore(
|
const DEFAULT_SYNC_STATE = {
|
||||||
{
|
provider: ProviderType.WebDAV,
|
||||||
provider: ProviderType.WebDAV,
|
useProxy: true,
|
||||||
useProxy: true,
|
proxyUrl: corsPath(ApiPath.Cors),
|
||||||
proxyUrl: corsPath(ApiPath.Cors),
|
|
||||||
|
|
||||||
webdav: {
|
webdav: {
|
||||||
endpoint: "",
|
endpoint: "",
|
||||||
username: "",
|
username: "",
|
||||||
password: "",
|
password: "",
|
||||||
},
|
|
||||||
|
|
||||||
upstash: {
|
|
||||||
endpoint: "",
|
|
||||||
username: STORAGE_KEY,
|
|
||||||
apiKey: "",
|
|
||||||
},
|
|
||||||
|
|
||||||
lastSyncTime: 0,
|
|
||||||
lastProvider: "",
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
upstash: {
|
||||||
|
endpoint: "",
|
||||||
|
username: STORAGE_KEY,
|
||||||
|
apiKey: "",
|
||||||
|
},
|
||||||
|
|
||||||
|
lastSyncTime: 0,
|
||||||
|
lastProvider: "",
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useSyncStore = createPersistStore(
|
||||||
|
DEFAULT_SYNC_STATE,
|
||||||
(set, get) => ({
|
(set, get) => ({
|
||||||
coundSync() {
|
coundSync() {
|
||||||
const config = get()[get().provider];
|
const config = get()[get().provider];
|
||||||
@ -108,6 +110,16 @@ export const useSyncStore = createPersistStore(
|
|||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
name: StoreKey.Sync,
|
name: StoreKey.Sync,
|
||||||
version: 1,
|
version: 1.1,
|
||||||
|
|
||||||
|
migrate(persistedState, version) {
|
||||||
|
const newState = persistedState as typeof DEFAULT_SYNC_STATE;
|
||||||
|
|
||||||
|
if (version < 1.1) {
|
||||||
|
newState.upstash.username = STORAGE_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
return newState as any;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user