mirror of
https://github.com/antebudimir/feishin.git
synced 2025-12-31 18:13:31 +00:00
restructure files onto electron-vite boilerplate
This commit is contained in:
parent
91ce2cd8a1
commit
1cf587bc8f
457 changed files with 9927 additions and 11705 deletions
67
src/renderer/main.tsx
Normal file
67
src/renderer/main.tsx
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
import { Notifications } from '@mantine/notifications';
|
||||
import {
|
||||
PersistedClient,
|
||||
Persister,
|
||||
PersistQueryClientProvider,
|
||||
} from '@tanstack/react-query-persist-client';
|
||||
import { del, get, set } from 'idb-keyval';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import 'overlayscrollbars/overlayscrollbars.css';
|
||||
|
||||
import './styles/overlayscrollbars.css';
|
||||
import { queryClient } from './lib/react-query';
|
||||
|
||||
import { App } from '/@/renderer/app';
|
||||
|
||||
function createIDBPersister(idbValidKey: IDBValidKey = 'reactQuery') {
|
||||
return {
|
||||
persistClient: async (client: PersistedClient) => {
|
||||
set(idbValidKey, client);
|
||||
},
|
||||
removeClient: async () => {
|
||||
await del(idbValidKey);
|
||||
},
|
||||
restoreClient: async () => {
|
||||
return await get<PersistedClient>(idbValidKey);
|
||||
},
|
||||
} as Persister;
|
||||
}
|
||||
|
||||
const indexedDbPersister = createIDBPersister('feishin');
|
||||
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
<PersistQueryClientProvider
|
||||
client={queryClient}
|
||||
persistOptions={{
|
||||
buster: 'feishin',
|
||||
dehydrateOptions: {
|
||||
dehydrateQueries: true,
|
||||
shouldDehydrateQuery: (query) => {
|
||||
const isSuccess = query.state.status === 'success';
|
||||
const isLyricsQueryKey =
|
||||
query.queryKey.includes('song') &&
|
||||
query.queryKey.includes('lyrics') &&
|
||||
query.queryKey.includes('select');
|
||||
|
||||
return isSuccess && isLyricsQueryKey;
|
||||
},
|
||||
},
|
||||
hydrateOptions: {
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
cacheTime: Infinity,
|
||||
},
|
||||
},
|
||||
},
|
||||
maxAge: Infinity,
|
||||
persister: indexedDbPersister,
|
||||
}}
|
||||
>
|
||||
<Notifications
|
||||
containerWidth="300px"
|
||||
position="bottom-center"
|
||||
zIndex={5}
|
||||
/>
|
||||
<App />
|
||||
</PersistQueryClientProvider>,
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue