fix(core): onboading performance improvement (#8790)
- compress images - remove noise assets (700kb) - remove lottie animations - remove `perspective` after paper animation to reduce layers
@@ -2,6 +2,7 @@ import { join } from 'node:path';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
app,
|
app,
|
||||||
|
BrowserWindow,
|
||||||
Menu,
|
Menu,
|
||||||
MenuItem,
|
MenuItem,
|
||||||
session,
|
session,
|
||||||
@@ -38,7 +39,6 @@ import {
|
|||||||
type WorkbenchViewMeta,
|
type WorkbenchViewMeta,
|
||||||
} from '../shared-state-schema';
|
} from '../shared-state-schema';
|
||||||
import { globalStateStorage } from '../shared-storage/storage';
|
import { globalStateStorage } from '../shared-storage/storage';
|
||||||
import { getCustomThemeWindow } from './custom-theme-window';
|
|
||||||
import { getMainWindow, MainWindowManager } from './main-window';
|
import { getMainWindow, MainWindowManager } from './main-window';
|
||||||
|
|
||||||
async function getAdditionalArguments() {
|
async function getAdditionalArguments() {
|
||||||
@@ -1083,14 +1083,11 @@ export const onActiveTabChanged = (fn: (tabId: string) => void) => {
|
|||||||
|
|
||||||
export const showDevTools = (id?: string) => {
|
export const showDevTools = (id?: string) => {
|
||||||
// use focusedWindow?
|
// use focusedWindow?
|
||||||
// const focusedWindow = BrowserWindow.getFocusedWindow()
|
const focusedWindow = BrowserWindow.getFocusedWindow();
|
||||||
|
// check if focused window is main window
|
||||||
// workaround for opening devtools for theme-editor window
|
const mainWindow = WebContentViewsManager.instance.mainWindow;
|
||||||
// there should be some strategy like windows manager, so we can know which window is active
|
if (focusedWindow && focusedWindow.id !== mainWindow?.id) {
|
||||||
getCustomThemeWindow()
|
focusedWindow.webContents.openDevTools();
|
||||||
.then(w => {
|
|
||||||
if (w && w.isFocused()) {
|
|
||||||
w.webContents.openDevTools();
|
|
||||||
} else {
|
} else {
|
||||||
const view = id
|
const view = id
|
||||||
? WebContentViewsManager.instance.getViewById(id)
|
? WebContentViewsManager.instance.getViewById(id)
|
||||||
@@ -1099,8 +1096,6 @@ export const showDevTools = (id?: string) => {
|
|||||||
view.webContents.openDevTools();
|
view.webContents.openDevTools();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.catch(console.error);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const pingAppLayoutReady = (wc: WebContents, ready: boolean) => {
|
export const pingAppLayoutReady = (wc: WebContents, ready: boolean) => {
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 344 KiB After Width: | Height: | Size: 119 KiB |
|
Before Width: | Height: | Size: 636 KiB After Width: | Height: | Size: 132 KiB |
|
Before Width: | Height: | Size: 324 KiB After Width: | Height: | Size: 110 KiB |
|
Before Width: | Height: | Size: 289 KiB After Width: | Height: | Size: 120 KiB |
|
Before Width: | Height: | Size: 464 KiB After Width: | Height: | Size: 140 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 225 KiB After Width: | Height: | Size: 190 KiB |
|
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 177 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 112 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 197 KiB After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 124 KiB After Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 11 KiB |
@@ -52,6 +52,7 @@ export const orbitItem = style({
|
|||||||
flexShrink: 0,
|
flexShrink: 0,
|
||||||
flexGrow: 0,
|
flexGrow: 0,
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
|
position: 'relative',
|
||||||
});
|
});
|
||||||
export const doc = style({
|
export const doc = style({
|
||||||
selectors: {
|
selectors: {
|
||||||
@@ -171,6 +172,7 @@ export const noDragWrapper = style({
|
|||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
inset: 0,
|
inset: 0,
|
||||||
pointerEvents: 'none',
|
pointerEvents: 'none',
|
||||||
|
width: '100%',
|
||||||
});
|
});
|
||||||
globalStyle(`${noDragWrapper} > *`, {
|
globalStyle(`${noDragWrapper} > *`, {
|
||||||
pointerEvents: 'auto',
|
pointerEvents: 'auto',
|
||||||
|
|||||||
@@ -113,7 +113,6 @@ export const EdgelessSwitch = ({
|
|||||||
turnOffScalingRef.current?.();
|
turnOffScalingRef.current?.();
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO(@catsjuice): mobile support
|
|
||||||
const onMouseDown = (e: MouseEvent) => {
|
const onMouseDown = (e: MouseEvent) => {
|
||||||
const target = e.target as HTMLElement;
|
const target = e.target as HTMLElement;
|
||||||
if (target.closest('[data-no-drag]')) return;
|
if (target.closest('[data-no-drag]')) return;
|
||||||
|
|||||||
@@ -61,10 +61,6 @@ export const onboardingVars = {
|
|||||||
nextButtonShowUpDelay: '20s',
|
nextButtonShowUpDelay: '20s',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
export const perspective = style({
|
|
||||||
perspective: '10000px',
|
|
||||||
transformStyle: 'preserve-3d',
|
|
||||||
});
|
|
||||||
export const fadeIn = keyframes({
|
export const fadeIn = keyframes({
|
||||||
from: {
|
from: {
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
@@ -73,9 +69,7 @@ export const fadeIn = keyframes({
|
|||||||
opacity: 1,
|
opacity: 1,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
export const onboarding = style([
|
export const onboarding = style({
|
||||||
perspective,
|
|
||||||
{
|
|
||||||
width: '100vw',
|
width: '100vw',
|
||||||
height: '100vh',
|
height: '100vh',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@@ -83,6 +77,10 @@ export const onboarding = style([
|
|||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
selectors: {
|
selectors: {
|
||||||
|
'&[data-is-window="false"]': {
|
||||||
|
perspective: '10000px',
|
||||||
|
transformStyle: 'preserve-3d',
|
||||||
|
},
|
||||||
// hack background color for web
|
// hack background color for web
|
||||||
'&::after': {
|
'&::after': {
|
||||||
content: '',
|
content: '',
|
||||||
@@ -102,9 +100,8 @@ export const onboarding = style([
|
|||||||
opacity: 0,
|
opacity: 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
]);
|
globalStyle(`${onboarding}[data-is-window="false"] *`, {
|
||||||
globalStyle(`${onboarding} *`, {
|
|
||||||
perspective: '10000px',
|
perspective: '10000px',
|
||||||
transformStyle: 'preserve-3d',
|
transformStyle: 'preserve-3d',
|
||||||
});
|
});
|
||||||
@@ -146,3 +143,7 @@ globalStyle(`${tipsWrapper} > *`, {
|
|||||||
globalStyle(`${tipsWrapper}[data-visible="true"] > *`, {
|
globalStyle(`${tipsWrapper}[data-visible="true"] > *`, {
|
||||||
pointerEvents: 'auto',
|
pointerEvents: 'auto',
|
||||||
});
|
});
|
||||||
|
// transparent background for onboarding window
|
||||||
|
globalStyle(`:root`, {
|
||||||
|
backgroundColor: 'transparent',
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { cssVarV2 } from '@toeverything/theme/v2';
|
||||||
import { keyframes, style } from '@vanilla-extract/css';
|
import { keyframes, style } from '@vanilla-extract/css';
|
||||||
|
|
||||||
import { block } from '../articles/blocks.css';
|
import { block } from '../articles/blocks.css';
|
||||||
@@ -33,24 +34,21 @@ export const switchButtons = style({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const switchButton = style({
|
export const switchButton = style({
|
||||||
width: 24,
|
width: 48,
|
||||||
height: 24,
|
height: 48,
|
||||||
transform: 'scale(2)',
|
fontSize: 36,
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
boxShadow: 'none',
|
boxShadow: 'none',
|
||||||
opacity: 0.6,
|
opacity: 0.6,
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
|
color: cssVarV2('switch/iconColor/default'),
|
||||||
|
position: 'relative',
|
||||||
selectors: {
|
selectors: {
|
||||||
'&:nth-child(1)': {
|
|
||||||
transformOrigin: 'left',
|
|
||||||
},
|
|
||||||
'&:nth-child(2)': {
|
|
||||||
transformOrigin: 'right',
|
|
||||||
},
|
|
||||||
'&[data-active="true"]': {
|
'&[data-active="true"]': {
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
|
color: cssVarV2('switch/iconColor/active'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
|
import { EdgelessIcon, PageIcon } from '@blocksuite/icons/rc';
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import type { HTMLAttributes } from 'react';
|
import type { HTMLAttributes } from 'react';
|
||||||
|
|
||||||
import {
|
|
||||||
EdgelessSwitchItem,
|
|
||||||
PageSwitchItem,
|
|
||||||
} from '../../../blocksuite/block-suite-mode-switch/switch-items';
|
|
||||||
import type { EdgelessSwitchMode } from '../types';
|
import type { EdgelessSwitchMode } from '../types';
|
||||||
import * as styles from './style.css';
|
import * as styles from './style.css';
|
||||||
|
|
||||||
@@ -27,16 +24,20 @@ export const EdgelessSwitchButtons = ({
|
|||||||
className={clsx(styles.switchButtons, className)}
|
className={clsx(styles.switchButtons, className)}
|
||||||
{...attrs}
|
{...attrs}
|
||||||
>
|
>
|
||||||
<PageSwitchItem
|
<div
|
||||||
className={styles.switchButton}
|
className={styles.switchButton}
|
||||||
data-active={mode === 'page'}
|
data-active={mode === 'page'}
|
||||||
onClick={onSwitchToPageMode}
|
onClick={onSwitchToPageMode}
|
||||||
/>
|
>
|
||||||
<EdgelessSwitchItem
|
<PageIcon />
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
className={styles.switchButton}
|
className={styles.switchButton}
|
||||||
data-active={mode === 'edgeless'}
|
data-active={mode === 'edgeless'}
|
||||||
onClick={onSwitchToEdgelessMode}
|
onClick={onSwitchToEdgelessMode}
|
||||||
/>
|
>
|
||||||
|
<EdgelessIcon />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||