fix(core): onboading performance improvement (#8790)

- compress images
- remove noise assets (700kb)
- remove lottie animations
- remove `perspective` after paper animation to reduce layers
This commit is contained in:
CatsJuice
2024-11-13 08:25:05 +00:00
parent f85dfae63b
commit c32b29a293
27 changed files with 67 additions and 89 deletions

View File

@@ -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,24 +1083,19 @@ 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 => { } else {
if (w && w.isFocused()) { const view = id
w.webContents.openDevTools(); ? WebContentViewsManager.instance.getViewById(id)
} else { : WebContentViewsManager.instance.activeWorkbenchView;
const view = id if (view) {
? WebContentViewsManager.instance.getViewById(id) view.webContents.openDevTools();
: WebContentViewsManager.instance.activeWorkbenchView; }
if (view) { }
view.webContents.openDevTools();
}
}
})
.catch(console.error);
}; };
export const pingAppLayoutReady = (wc: WebContents, ready: boolean) => { export const pingAppLayoutReady = (wc: WebContents, ready: boolean) => {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 KiB

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 344 KiB

After

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 636 KiB

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 324 KiB

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 289 KiB

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 464 KiB

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 KiB

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 177 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 197 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 124 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -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',

View File

@@ -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;

View File

@@ -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,38 +69,39 @@ export const fadeIn = keyframes({
opacity: 1, opacity: 1,
}, },
}); });
export const onboarding = style([ export const onboarding = style({
perspective, width: '100vw',
{ height: '100vh',
width: '100vw', display: 'flex',
height: '100vh', alignItems: 'center',
display: 'flex', justifyContent: 'center',
alignItems: 'center', position: 'relative',
justifyContent: 'center', selectors: {
position: 'relative', '&[data-is-window="false"]': {
selectors: { perspective: '10000px',
// hack background color for web transformStyle: 'preserve-3d',
'&::after': { },
content: '', // hack background color for web
position: 'absolute', '&::after': {
inset: 0, content: '',
background: onboardingVars.web.bg, position: 'absolute',
transform: 'translateZ(-1000px) scale(2)', inset: 0,
transition: 'opacity 0.3s ease', background: onboardingVars.web.bg,
}, transform: 'translateZ(-1000px) scale(2)',
'&[data-is-desktop="true"]::after': { transition: 'opacity 0.3s ease',
animation: `${fadeIn} 0.8s linear`, },
// content: 'unset', '&[data-is-desktop="true"]::after': {
background: animation: `${fadeIn} 0.8s linear`,
'linear-gradient(180deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 99.58%)', // content: 'unset',
}, background:
'&[data-is-window="true"][data-is-desktop="true"]::after': { 'linear-gradient(180deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 99.58%)',
opacity: 0, },
}, '&[data-is-window="true"][data-is-desktop="true"]::after': {
opacity: 0,
}, },
}, },
]); });
globalStyle(`${onboarding} *`, { globalStyle(`${onboarding}[data-is-window="false"] *`, {
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',
});

View File

@@ -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'),
}, },
}, },
}); });

View File

@@ -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>
); );
}; };

File diff suppressed because one or more lines are too long