Skip to content

Commit 600b895

Browse files
authored
Feat guide (#56)
* feat: styles update * feat: 新手引导相关调整 * feat: 新手引导相关调整
1 parent a060ef7 commit 600b895

File tree

4 files changed

+158
-52
lines changed

4 files changed

+158
-52
lines changed
Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,41 @@
11
export const Assets = {
2-
welcome: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*gACYRIZ5m0YAAAAAAAAAAAAADgOBAQ/fmt.webp',
3-
query: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*UhR6QpIWBmIAAAAAAAAAAAAADgOBAQ/fmt.webp',
4-
spread: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*6g-mS7BKH_kAAAAAAAAAAAAADgOBAQ/fmt.webp',
5-
styleBtn: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*Ls3WRaRHU30AAAAAAAAAAAAADgOBAQ/original',
6-
stylePanel: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*4OutRZw69QIAAAAAAAAAAAAADgOBAQ/fmt.webp',
7-
filterBtn: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*CiM9R73L10cAAAAAAAAAAAAADgOBAQ/original',
8-
filterPanel: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*QlKsS4gxcT8AAAAAAAAAAAAADgOBAQ/fmt.webp',
9-
download: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*QjWNRZ-LQ2kAAAAAAAAAAAAADgOBAQ/original',
2+
welcome:
3+
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*gACYRIZ5m0YAAAAAAAAAAAAADgOBAQ/fmt.webp',
4+
query:
5+
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*UhR6QpIWBmIAAAAAAAAAAAAADgOBAQ/fmt.webp',
6+
spread:
7+
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*jpB0Q7Hbm5sAAAAAAAAAAAAADgOBAQ/original',
8+
styleBtn:
9+
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*Ls3WRaRHU30AAAAAAAAAAAAADgOBAQ/original',
10+
stylePanel:
11+
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*4OutRZw69QIAAAAAAAAAAAAADgOBAQ/fmt.webp',
12+
filterBtn:
13+
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*CiM9R73L10cAAAAAAAAAAAAADgOBAQ/original',
14+
filterPanel:
15+
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*QlKsS4gxcT8AAAAAAAAAAAAADgOBAQ/fmt.webp',
16+
download:
17+
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*QjWNRZ-LQ2kAAAAAAAAAAAAADgOBAQ/original',
1018
end: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*-a6uRYo-9qEAAAAAAAAAAAAADgOBAQ/fmt.webp',
11-
close: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*1qMxQ4fS3e0AAAAAAAAAAAAADgOBAQ/original',
12-
btnWelcome: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*-0IkQ4wm8TEAAAAAAAAAAAAADgOBAQ/original',
13-
btnNext: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*T7bRTrLqVcUAAAAAAAAAAAAADgOBAQ/original',
14-
btnEnd: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*8lvqQr_me34AAAAAAAAAAAAADgOBAQ/original',
15-
afterStyle: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*x3QnTr_EA2oAAAAAAAAAAAAADgOBAQ/original',
16-
afterFilter: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*iWG-S7i0c6EAAAAAAAAAAAAADgOBAQ/original',
17-
afterSpread: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*2XqOQ4y9pjsAAAAAAAAAAAAADgOBAQ/original',
18-
styleGif: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*v8SsRJ0mkFAAAAAAAAAAAAAADgOBAQ/original',
19-
spreadGif: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*P2nrTLAjhCkAAAAAAAAAAAAADgOBAQ/original',
20-
queryGif: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*hsYDRLBPUj8AAAAAAAAAAAAADgOBAQ/original',
21-
filterGif: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*p8zcR7cc0tQAAAAAAAAAAAAADgOBAQ/original',
19+
close:
20+
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*1qMxQ4fS3e0AAAAAAAAAAAAADgOBAQ/original',
21+
btnWelcome:
22+
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*-0IkQ4wm8TEAAAAAAAAAAAAADgOBAQ/original',
23+
btnNext:
24+
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*T7bRTrLqVcUAAAAAAAAAAAAADgOBAQ/original',
25+
btnEnd:
26+
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*8lvqQr_me34AAAAAAAAAAAAADgOBAQ/original',
27+
afterStyle:
28+
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*x3QnTr_EA2oAAAAAAAAAAAAADgOBAQ/original',
29+
afterFilter:
30+
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*q5jTQ5vZLAQAAAAAAAAAAAAADgOBAQ/original',
31+
afterSpread:
32+
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*k8NSR4y7j40AAAAAAAAAAAAADgOBAQ/original',
33+
styleGif:
34+
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*v8SsRJ0mkFAAAAAAAAAAAAAADgOBAQ/original',
35+
spreadGif:
36+
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*P2nrTLAjhCkAAAAAAAAAAAAADgOBAQ/original',
37+
queryGif:
38+
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*hsYDRLBPUj8AAAAAAAAAAAAADgOBAQ/original',
39+
filterGif:
40+
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*p8zcR7cc0tQAAAAAAAAAAAAADgOBAQ/original',
2241
};

client/src/components/guidance/index.tsx

Lines changed: 93 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,50 @@ function getBoundings(selector: string): DOMRect {
3939

4040
function getClipPathByTwoRect(rect: DOMRect, fullscreen: DOMRect) {
4141
const rects = [
42-
[[fullscreen.left, fullscreen.top], [rect.left, fullscreen.bottom]],
43-
[[rect.right, fullscreen.top], [fullscreen.right, fullscreen.bottom]],
44-
[[rect.left, fullscreen.top], [rect.right, rect.top]],
45-
[[rect.left, rect.bottom], [rect.right, fullscreen.bottom]],
42+
[
43+
[fullscreen.left, fullscreen.top],
44+
[rect.left, fullscreen.bottom],
45+
],
46+
[
47+
[rect.right, fullscreen.top],
48+
[fullscreen.right, fullscreen.bottom],
49+
],
50+
[
51+
[rect.left, fullscreen.top],
52+
[rect.right, rect.top],
53+
],
54+
[
55+
[rect.left, rect.bottom],
56+
[rect.right, fullscreen.bottom],
57+
],
4658
];
4759

4860
const points = rects.map(([p1, p2]) => {
49-
return [[p1[0], p1[1]], [p2[0], p1[1]], [p2[0], p2[1]], [p1[0], p2[1]]];
50-
})
61+
return [
62+
[p1[0], p1[1]],
63+
[p2[0], p1[1]],
64+
[p2[0], p2[1]],
65+
[p1[0], p2[1]],
66+
];
67+
});
5168

52-
const path = points.map(point => (
53-
point.map(([x, y], idx) => idx === 0 ? `M${x},${y}` : `L${x},${y}`).join(' ') + 'Z'
54-
));
69+
const path = points.map(
70+
point =>
71+
point
72+
.map(([x, y], idx) => (idx === 0 ? `M${x},${y}` : `L${x},${y}`))
73+
.join(' ') + 'Z',
74+
);
5575
return `path("${path.join(' ')}")`;
5676
}
5777

5878
/**
5979
* 新手引导组件
60-
* @returns
80+
* @returns
6181
*/
6282
export const Guidance: React.FC = () => {
6383
// localStorage 存储
64-
const [isGuidanceFinished, setGuidanceFinished] = useLocalStorageState<string>(LocalStorageKey);
84+
const [isGuidanceFinished, setGuidanceFinished] =
85+
useLocalStorageState<string>(LocalStorageKey);
6586

6687
const [step, setStep] = useState<number>(0);
6788

@@ -90,47 +111,87 @@ export const Guidance: React.FC = () => {
90111
setStep(-1);
91112
setGuidanceFinished('1');
92113
},
93-
}
114+
};
94115

95116
function getGuidanceUI() {
96-
if (step === 0) return (<Welcome {...props} />);
117+
if (step === 0) return <Welcome {...props} />;
97118
if (step === 1) {
98119
const rect = getBoundings(SelectorSidebar);
99-
return (<Query {...props } x={rect.right - 16} y={rect.top + 100} />);
120+
return <Query {...props} x={rect.right - 16} y={rect.top + 100} />;
100121
}
101122
if (step === 2) {
102123
const rect = getBoundings(SelectorCanvas);
103-
return (<Spread {...props } x={rect.x + rect.width * 0.382} y={300} />);
124+
return <Spread {...props} x={rect.x + rect.width * 0.382} y={300} />;
104125
}
105126
if (step === 3) {
106127
const rect = getBoundings(SelectorStyle);
107128
const canvasRect = getBoundings(SelectorCanvas);
108129
// 32px 是箭头的偏移
109-
return (<StyleBtn {...props } x={rect.x + rect.width / 2 - 32} y={rect.bottom} canvasX={canvasRect.x + canvasRect.width * 0.382} canvasY={300} />);
130+
return (
131+
<StyleBtn
132+
{...props}
133+
x={rect.x + rect.width / 2 - 32}
134+
y={rect.bottom}
135+
canvasX={canvasRect.x + canvasRect.width * 0.382}
136+
canvasY={300}
137+
/>
138+
);
110139
}
111140
if (step === 4) {
112141
const rect = getBoundings(SelectorSidebar);
113142
const canvasRect = getBoundings(SelectorCanvas);
114-
return (<StylePanel {...props } x={rect.right - 16} y={rect.top + 200} canvasX={canvasRect.x + canvasRect.width * 0.382} canvasY={300} />);
143+
return (
144+
<StylePanel
145+
{...props}
146+
x={rect.right - 16}
147+
y={rect.top + 200}
148+
canvasX={canvasRect.x + canvasRect.width * 0.382}
149+
canvasY={300}
150+
/>
151+
);
115152
}
116153
if (step === 5) {
117154
const rect = getBoundings(SelectorFilter);
118155
const canvasRect = getBoundings(SelectorCanvas);
119156
// 32px 是箭头的偏移
120-
return (<FilterBtn {...props } x={rect.x + rect.width / 2 - 32} y={rect.bottom} canvasX={canvasRect.x + canvasRect.width * 0.382} canvasY={300} />);
157+
return (
158+
<FilterBtn
159+
{...props}
160+
x={rect.x + rect.width / 2 - 32}
161+
y={rect.bottom}
162+
canvasX={canvasRect.x + canvasRect.width * 0.382}
163+
canvasY={300}
164+
/>
165+
);
121166
}
122167
if (step === 6) {
123168
const rect = getBoundings(SelectorSidebar);
124169
const canvasRect = getBoundings(SelectorCanvas);
125-
return (<FilterPanel {...props } x={rect.right - 16} y={rect.top + 100} canvasX={canvasRect.x + canvasRect.width * 0.382} canvasY={300} />);
170+
return (
171+
<FilterPanel
172+
{...props}
173+
x={rect.right - 16}
174+
y={rect.top + 100}
175+
canvasX={canvasRect.x + canvasRect.width * 0.382}
176+
canvasY={300}
177+
/>
178+
);
126179
}
127180
if (step === 7) {
128181
const rect = getBoundings(SelectorDownload);
129182
const canvasRect = getBoundings(SelectorCanvas);
130-
return (<Download {...props } x={rect.x + rect.width / 2} y={rect.bottom} canvasX={canvasRect.x + canvasRect.width * 0.382} canvasY={300} />);
183+
return (
184+
<Download
185+
{...props}
186+
x={rect.x + rect.width / 2}
187+
y={rect.bottom}
188+
canvasX={canvasRect.x + canvasRect.width * 0.382}
189+
canvasY={300}
190+
/>
191+
);
131192
}
132193
if (step === 8) {
133-
return (<End {...props } />);
194+
return <End {...props} />;
134195
}
135196
return null;
136197
}
@@ -157,9 +218,15 @@ export const Guidance: React.FC = () => {
157218
return 'none';
158219
}
159220

160-
return !isGuidanceFinished &&
161-
<div className={styles.guidance} style={{ display: step >= 0 && step <= 8 ? 'unset' : 'none' }}>
162-
<div className={styles.mask} style={{ clipPath: getClipPath() }} />
163-
{ getGuidanceUI() }
164-
</div>;
221+
return (
222+
!isGuidanceFinished && (
223+
<div
224+
className={styles.guidance}
225+
style={{ display: step >= 0 && step <= 8 ? 'unset' : 'none' }}
226+
>
227+
<div className={styles.mask} style={{ clipPath: getClipPath() }} />
228+
{getGuidanceUI()}
229+
</div>
230+
)
231+
);
165232
};

client/src/components/guidance/spread.tsx

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,41 @@ import styles from './index.module.less';
66

77
/**
88
* 新手引导 - 扩散
9-
* @returns
9+
* @returns
1010
*/
11-
export const Spread: React.FC<StepUIProps> = ({ prev, next, end, x = 0, y = 0 }) => {
11+
export const Spread: React.FC<StepUIProps> = ({
12+
prev,
13+
next,
14+
end,
15+
x = 0,
16+
y = 0,
17+
}) => {
1218
return (
1319
<div className={styles.spread} style={{ top: y, left: x }}>
1420
<div className={styles.container}>
15-
<img className={styles.background} style={{ width: 430 }} src={Assets.spread} />
16-
<img className={styles.gif} src={Assets.spreadGif} style={{ top: 82, left: 77, maxWidth: 246 }} />
21+
<img
22+
className={styles.background}
23+
style={{ width: 430 }}
24+
src={Assets.spread}
25+
/>
26+
<img
27+
className={styles.gif}
28+
src={Assets.spreadGif}
29+
style={{ top: 105, left: 92, width: '238px', height: '206px' }}
30+
/>
1731
<div className={styles.btnContainer} style={{ top: 356, left: 245 }}>
1832
<div className={styles.nextBtn}>
1933
<img className={styles.btnBackground} src={Assets.btnNext} />
20-
<div className={styles.nextText} onClick={next}>下一步</div>
34+
<div className={styles.nextText} onClick={next}>
35+
下一步
36+
</div>
2137
</div>
2238
</div>
23-
<div className={styles.close} onClick={end} style={{ top: 0, left: 358 }}>
39+
<div
40+
className={styles.close}
41+
onClick={end}
42+
style={{ top: 0, left: 358 }}
43+
>
2444
<img src={Assets.close} />
2545
</div>
2646
</div>

client/src/pages/analysis.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
22
import { useRafInterval } from 'ahooks';
33
import { Guidance } from '@/components/guidance';
44
import TuGraphGraphAppConfig from '@/constants/GI_EXPORT_FILES';
5-
import '../components/studio/global.less'
5+
import '../components/studio/global.less';
66

77
//@ts-ignore
88
const { default: GI_SDK_APP } = window?.GI_SDK_APP;

0 commit comments

Comments
 (0)