mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-23 13:29:02 +08:00
fix: flash screen when creating new page (#1657)
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
import { atom, useAtomValue } from 'jotai';
|
||||||
|
|
||||||
|
import { currentPageIdAtom, workspacePreferredModeAtom } from '../../atoms';
|
||||||
|
|
||||||
|
const currentModeAtom = atom<'page' | 'edgeless'>(get => {
|
||||||
|
const pageId = get(currentPageIdAtom);
|
||||||
|
const record = get(workspacePreferredModeAtom);
|
||||||
|
if (pageId) return record[pageId] ?? 'page';
|
||||||
|
else {
|
||||||
|
return 'page';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export const useCurrentMode = () => {
|
||||||
|
return useAtomValue(currentModeAtom);
|
||||||
|
};
|
||||||
@@ -6,14 +6,12 @@ import {
|
|||||||
ThemeProvider as AffineThemeProvider,
|
ThemeProvider as AffineThemeProvider,
|
||||||
} from '@affine/component';
|
} from '@affine/component';
|
||||||
import { GlobalStyles } from '@mui/material';
|
import { GlobalStyles } from '@mui/material';
|
||||||
import { useAtomValue } from 'jotai';
|
|
||||||
import { ThemeProvider as NextThemeProvider, useTheme } from 'next-themes';
|
import { ThemeProvider as NextThemeProvider, useTheme } from 'next-themes';
|
||||||
import type { PropsWithChildren } from 'react';
|
import type { PropsWithChildren } from 'react';
|
||||||
import type React from 'react';
|
import type React from 'react';
|
||||||
import { memo, useEffect, useMemo, useState } from 'react';
|
import { memo, useEffect, useMemo, useState } from 'react';
|
||||||
|
|
||||||
import { workspacePreferredModeAtom } from '../atoms';
|
import { useCurrentMode } from '../hooks/current/use-current-mode';
|
||||||
import { useCurrentPage } from '../hooks/current/use-current-page-id';
|
|
||||||
|
|
||||||
const ThemeInjector = memo<{
|
const ThemeInjector = memo<{
|
||||||
themeStyle: AffineTheme;
|
themeStyle: AffineTheme;
|
||||||
@@ -40,9 +38,7 @@ const ThemeInjector = memo<{
|
|||||||
const ThemeProviderInner = memo<React.PropsWithChildren>(
|
const ThemeProviderInner = memo<React.PropsWithChildren>(
|
||||||
function ThemeProviderInner({ children }) {
|
function ThemeProviderInner({ children }) {
|
||||||
const { resolvedTheme: theme } = useTheme();
|
const { resolvedTheme: theme } = useTheme();
|
||||||
const currentPage = useCurrentPage();
|
const editorMode = useCurrentMode();
|
||||||
const record = useAtomValue(workspacePreferredModeAtom);
|
|
||||||
const editorMode = currentPage ? record[currentPage.id] ?? 'page' : 'page';
|
|
||||||
const themeStyle = useMemo(() => getLightTheme(editorMode), [editorMode]);
|
const themeStyle = useMemo(() => getLightTheme(editorMode), [editorMode]);
|
||||||
const darkThemeStyle = useMemo(
|
const darkThemeStyle = useMemo(
|
||||||
() => getDarkTheme(editorMode),
|
() => getDarkTheme(editorMode),
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ const dev = await p.group(
|
|||||||
const env = {
|
const env = {
|
||||||
NODE_API_SERVER: dev.server,
|
NODE_API_SERVER: dev.server,
|
||||||
PATH: process.env.PATH,
|
PATH: process.env.PATH,
|
||||||
|
NODE_ENV: 'development',
|
||||||
};
|
};
|
||||||
|
|
||||||
if (dev.debugBlockSuite) {
|
if (dev.debugBlockSuite) {
|
||||||
|
|||||||
Reference in New Issue
Block a user