Skip to content

Commit 7c10782

Browse files
CatsJuicepull[bot]
authored andcommitted
fix(core): onboading performance improvement (#8790)
- compress images - remove noise assets (700kb) - remove lottie animations - remove `perspective` after paper animation to reduce layers
1 parent c62cc00 commit 7c10782

27 files changed

+67
-89
lines changed

packages/frontend/apps/electron/src/main/windows-manager/tab-views.ts

+14-19
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { join } from 'node:path';
22

33
import {
44
app,
5+
BrowserWindow,
56
Menu,
67
MenuItem,
78
session,
@@ -38,7 +39,6 @@ import {
3839
type WorkbenchViewMeta,
3940
} from '../shared-state-schema';
4041
import { globalStateStorage } from '../shared-storage/storage';
41-
import { getCustomThemeWindow } from './custom-theme-window';
4242
import { getMainWindow, MainWindowManager } from './main-window';
4343

4444
async function getAdditionalArguments() {
@@ -1083,24 +1083,19 @@ export const onActiveTabChanged = (fn: (tabId: string) => void) => {
10831083

10841084
export const showDevTools = (id?: string) => {
10851085
// use focusedWindow?
1086-
// const focusedWindow = BrowserWindow.getFocusedWindow()
1087-
1088-
// workaround for opening devtools for theme-editor window
1089-
// there should be some strategy like windows manager, so we can know which window is active
1090-
getCustomThemeWindow()
1091-
.then(w => {
1092-
if (w && w.isFocused()) {
1093-
w.webContents.openDevTools();
1094-
} else {
1095-
const view = id
1096-
? WebContentViewsManager.instance.getViewById(id)
1097-
: WebContentViewsManager.instance.activeWorkbenchView;
1098-
if (view) {
1099-
view.webContents.openDevTools();
1100-
}
1101-
}
1102-
})
1103-
.catch(console.error);
1086+
const focusedWindow = BrowserWindow.getFocusedWindow();
1087+
// check if focused window is main window
1088+
const mainWindow = WebContentViewsManager.instance.mainWindow;
1089+
if (focusedWindow && focusedWindow.id !== mainWindow?.id) {
1090+
focusedWindow.webContents.openDevTools();
1091+
} else {
1092+
const view = id
1093+
? WebContentViewsManager.instance.getViewById(id)
1094+
: WebContentViewsManager.instance.activeWorkbenchView;
1095+
if (view) {
1096+
view.webContents.openDevTools();
1097+
}
1098+
}
11041099
};
11051100

11061101
export const pingAppLayoutReady = (wc: WebContents, ready: boolean) => {
Loading
Loading
Loading
Loading

packages/frontend/core/src/components/affine/onboarding/steps/edgeless-switch.css.ts

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export const orbitItem = style({
5252
flexShrink: 0,
5353
flexGrow: 0,
5454
overflow: 'hidden',
55+
position: 'relative',
5556
});
5657
export const doc = style({
5758
selectors: {
@@ -171,6 +172,7 @@ export const noDragWrapper = style({
171172
position: 'absolute',
172173
inset: 0,
173174
pointerEvents: 'none',
175+
width: '100%',
174176
});
175177
globalStyle(`${noDragWrapper} > *`, {
176178
pointerEvents: 'auto',

packages/frontend/core/src/components/affine/onboarding/steps/edgeless-switch.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ export const EdgelessSwitch = ({
113113
turnOffScalingRef.current?.();
114114
};
115115

116-
// TODO(@catsjuice): mobile support
117116
const onMouseDown = (e: MouseEvent) => {
118117
const target = e.target as HTMLElement;
119118
if (target.closest('[data-no-drag]')) return;

packages/frontend/core/src/components/affine/onboarding/style.css.ts

+35-34
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ export const onboardingVars = {
6161
nextButtonShowUpDelay: '20s',
6262
},
6363
};
64-
export const perspective = style({
65-
perspective: '10000px',
66-
transformStyle: 'preserve-3d',
67-
});
6864
export const fadeIn = keyframes({
6965
from: {
7066
opacity: 0,
@@ -73,38 +69,39 @@ export const fadeIn = keyframes({
7369
opacity: 1,
7470
},
7571
});
76-
export const onboarding = style([
77-
perspective,
78-
{
79-
width: '100vw',
80-
height: '100vh',
81-
display: 'flex',
82-
alignItems: 'center',
83-
justifyContent: 'center',
84-
position: 'relative',
85-
selectors: {
86-
// hack background color for web
87-
'&::after': {
88-
content: '',
89-
position: 'absolute',
90-
inset: 0,
91-
background: onboardingVars.web.bg,
92-
transform: 'translateZ(-1000px) scale(2)',
93-
transition: 'opacity 0.3s ease',
94-
},
95-
'&[data-is-desktop="true"]::after': {
96-
animation: `${fadeIn} 0.8s linear`,
97-
// content: 'unset',
98-
background:
99-
'linear-gradient(180deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 99.58%)',
100-
},
101-
'&[data-is-window="true"][data-is-desktop="true"]::after': {
102-
opacity: 0,
103-
},
72+
export const onboarding = style({
73+
width: '100vw',
74+
height: '100vh',
75+
display: 'flex',
76+
alignItems: 'center',
77+
justifyContent: 'center',
78+
position: 'relative',
79+
selectors: {
80+
'&[data-is-window="false"]': {
81+
perspective: '10000px',
82+
transformStyle: 'preserve-3d',
83+
},
84+
// hack background color for web
85+
'&::after': {
86+
content: '',
87+
position: 'absolute',
88+
inset: 0,
89+
background: onboardingVars.web.bg,
90+
transform: 'translateZ(-1000px) scale(2)',
91+
transition: 'opacity 0.3s ease',
92+
},
93+
'&[data-is-desktop="true"]::after': {
94+
animation: `${fadeIn} 0.8s linear`,
95+
// content: 'unset',
96+
background:
97+
'linear-gradient(180deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 99.58%)',
98+
},
99+
'&[data-is-window="true"][data-is-desktop="true"]::after': {
100+
opacity: 0,
104101
},
105102
},
106-
]);
107-
globalStyle(`${onboarding} *`, {
103+
});
104+
globalStyle(`${onboarding}[data-is-window="false"] *`, {
108105
perspective: '10000px',
109106
transformStyle: 'preserve-3d',
110107
});
@@ -146,3 +143,7 @@ globalStyle(`${tipsWrapper} > *`, {
146143
globalStyle(`${tipsWrapper}[data-visible="true"] > *`, {
147144
pointerEvents: 'auto',
148145
});
146+
// transparent background for onboarding window
147+
globalStyle(`:root`, {
148+
backgroundColor: 'transparent',
149+
});

packages/frontend/core/src/components/affine/onboarding/switch-widgets/style.css.tsx

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { cssVarV2 } from '@toeverything/theme/v2';
12
import { keyframes, style } from '@vanilla-extract/css';
23

34
import { block } from '../articles/blocks.css';
@@ -33,24 +34,21 @@ export const switchButtons = style({
3334
});
3435

3536
export const switchButton = style({
36-
width: 24,
37-
height: 24,
38-
transform: 'scale(2)',
37+
width: 48,
38+
height: 48,
39+
fontSize: 36,
3940
display: 'flex',
4041
alignItems: 'center',
4142
justifyContent: 'center',
4243
boxShadow: 'none',
4344
opacity: 0.6,
4445
cursor: 'pointer',
46+
color: cssVarV2('switch/iconColor/default'),
47+
position: 'relative',
4548
selectors: {
46-
'&:nth-child(1)': {
47-
transformOrigin: 'left',
48-
},
49-
'&:nth-child(2)': {
50-
transformOrigin: 'right',
51-
},
5249
'&[data-active="true"]': {
5350
opacity: 1,
51+
color: cssVarV2('switch/iconColor/active'),
5452
},
5553
},
5654
});

packages/frontend/core/src/components/affine/onboarding/switch-widgets/switch.tsx

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1+
import { EdgelessIcon, PageIcon } from '@blocksuite/icons/rc';
12
import clsx from 'clsx';
23
import type { HTMLAttributes } from 'react';
34

4-
import {
5-
EdgelessSwitchItem,
6-
PageSwitchItem,
7-
} from '../../../blocksuite/block-suite-mode-switch/switch-items';
85
import type { EdgelessSwitchMode } from '../types';
96
import * as styles from './style.css';
107

@@ -27,16 +24,20 @@ export const EdgelessSwitchButtons = ({
2724
className={clsx(styles.switchButtons, className)}
2825
{...attrs}
2926
>
30-
<PageSwitchItem
27+
<div
3128
className={styles.switchButton}
3229
data-active={mode === 'page'}
3330
onClick={onSwitchToPageMode}
34-
/>
35-
<EdgelessSwitchItem
31+
>
32+
<PageIcon />
33+
</div>
34+
<div
3635
className={styles.switchButton}
3736
data-active={mode === 'edgeless'}
3837
onClick={onSwitchToEdgelessMode}
39-
/>
38+
>
39+
<EdgelessIcon />
40+
</div>
4041
</div>
4142
);
4243
};

packages/frontend/core/src/components/affine/onboarding/switch-widgets/toolbar.tsx

-18
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)