mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
Co-authored-by: Hongtao Lye <codert.sn@gmail.com> Co-authored-by: liuyi <forehalo@gmail.com> Co-authored-by: LongYinan <lynweklm@gmail.com> Co-authored-by: X1a0t <405028157@qq.com> Co-authored-by: JimmFly <yangjinfei001@gmail.com> Co-authored-by: Peng Xiao <pengxiao@outlook.com> Co-authored-by: xiaodong zuo <53252747+zuoxiaodong0815@users.noreply.github.com> Co-authored-by: DarkSky <25152247+darkskygit@users.noreply.github.com> Co-authored-by: Qi <474021214@qq.com> Co-authored-by: danielchim <kahungchim@gmail.com>
66 lines
1.9 KiB
TypeScript
66 lines
1.9 KiB
TypeScript
import '@affine/component/theme/global.css';
|
|
import '@affine/component/theme/theme.css';
|
|
import '@toeverything/components/style.css';
|
|
|
|
import { AffineContext } from '@affine/component/context';
|
|
import { WorkspaceFallback } from '@affine/component/workspace';
|
|
import { CacheProvider } from '@emotion/react';
|
|
import { getCurrentStore } from '@toeverything/infra/atom';
|
|
import { use } from 'foxact/use';
|
|
import { SessionProvider } from 'next-auth/react';
|
|
import type { PropsWithChildren, ReactElement } from 'react';
|
|
import { lazy, memo, Suspense } from 'react';
|
|
import { RouterProvider } from 'react-router-dom';
|
|
|
|
import { router } from './router';
|
|
import createEmotionCache from './utils/create-emotion-cache';
|
|
|
|
const cache = createEmotionCache();
|
|
|
|
const DevTools = lazy(() =>
|
|
import('jotai-devtools').then(m => ({ default: m.DevTools }))
|
|
);
|
|
|
|
const DebugProvider = ({ children }: PropsWithChildren): ReactElement => {
|
|
return (
|
|
<>
|
|
<Suspense>{process.env.DEBUG_JOTAI === 'true' && <DevTools />}</Suspense>
|
|
{children}
|
|
</>
|
|
);
|
|
};
|
|
|
|
const future = {
|
|
v7_startTransition: true,
|
|
} as const;
|
|
|
|
async function loadLanguage() {
|
|
if (environment.isBrowser) {
|
|
const { createI18n, setUpLanguage } = await import('@affine/i18n');
|
|
const i18n = createI18n();
|
|
document.documentElement.lang = i18n.language;
|
|
await setUpLanguage(i18n);
|
|
}
|
|
}
|
|
|
|
const languageLoadingPromise = loadLanguage().catch(console.error);
|
|
|
|
export const App = memo(function App() {
|
|
use(languageLoadingPromise);
|
|
return (
|
|
<SessionProvider refetchOnWindowFocus>
|
|
<CacheProvider value={cache}>
|
|
<AffineContext store={getCurrentStore()}>
|
|
<DebugProvider>
|
|
<RouterProvider
|
|
fallbackElement={<WorkspaceFallback key="RouterFallback" />}
|
|
router={router}
|
|
future={future}
|
|
/>
|
|
</DebugProvider>
|
|
</AffineContext>
|
|
</CacheProvider>
|
|
</SessionProvider>
|
|
);
|
|
});
|