mirror of https://github.com/msgbyte/tailchat
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
632 B
TypeScript
22 lines
632 B
TypeScript
import { QueryClient } from '@tanstack/react-query';
|
|
import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persister';
|
|
import { getStorage } from '../manager/storage';
|
|
|
|
export const queryClient = new QueryClient({
|
|
defaultOptions: {
|
|
queries: {
|
|
staleTime: 10 * 1000, // 默认缓存10s
|
|
},
|
|
},
|
|
});
|
|
|
|
export const asyncStoragePersister = createAsyncStoragePersister({
|
|
storage: {
|
|
getItem: (key: string) => {
|
|
return getStorage().get(key);
|
|
},
|
|
setItem: (key: string, value: string) => getStorage().set(key, value),
|
|
removeItem: (key: string) => getStorage().remove(key),
|
|
},
|
|
});
|