Skip to content

Commit 94f343f

Browse files
committed
feat: update pencil menu Toolbar Fastboard UI
1 parent d550b12 commit 94f343f

File tree

3 files changed

+41
-16
lines changed

3 files changed

+41
-16
lines changed

Diff for: docs/zh/appliance-plugin.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { ApplianceSinglePlugin } from '@netless/appliance-plugin';
3636
>
3737
>我们采用双worker并发来提高绘制效率,这样让它比主进程效率提高了40%以上.但是两个worker文件上的公共依赖都是重复的,所以如果直接构建到包中,那么会大大增加包体积.所以我们允许workerjs文件cdn部署,只要把@netless/appliance-plugin/cdn下的文件部署到cdn中即可,然后通过插件中的getInstance的第二个参数options.cdn中配置上两个workerjs的cdn地址即可.这样就可以解决包体积过大的问题.
3838
>
39-
> - **总包大概在400kB,两个wokerjs各有800kB.** 如果需要考虑构建的包体积大小的,请选择配置cdn.
39+
> **总包大概在400kB,两个wokerjs各有800kB.** 如果需要考虑构建的包体积大小的,请选择配置cdn.
4040
4141
### 接入方式参考
4242

Diff for: packages/fastboard-ui/src/components/Toolbar/components/Contents.svelte

+22-7
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,17 @@
9797
}
9898
function pencil() {
9999
if (hasAppliancePlugin) {
100-
app?.appliancePlugin?.setMemberState({
101-
currentApplianceName: "pencil",
102-
useLaserPen: false,
103-
strokeOpacity: 1,
104-
} as ExtendMemberState);
100+
if (appliance !== "pencil") {
101+
if (pencilType === "mark") {
102+
useMarkPen();
103+
} else if (pencilType === "laser") {
104+
useLaserPen();
105+
} else {
106+
usePencil();
107+
}
108+
}
105109
} else {
106-
app?.setAppliance("pencil");
110+
usePencil();
107111
}
108112
}
109113
function text() {
@@ -121,6 +125,17 @@
121125
function clear() {
122126
app?.cleanCurrentScene();
123127
}
128+
function usePencil() {
129+
if (hasAppliancePlugin) {
130+
app?.appliancePlugin?.setMemberState({
131+
currentApplianceName: "pencil",
132+
useLaserPen: false,
133+
strokeOpacity: 1,
134+
} as ExtendMemberState);
135+
} else {
136+
app?.setAppliance("pencil");
137+
}
138+
}
124139
function useLaserPen() {
125140
app?.appliancePlugin?.setMemberState({
126141
currentApplianceName: "laserPen",
@@ -195,7 +210,7 @@
195210
<div class="{name}-panel-switch-pencil">
196211
{#if !!app?.appliancePlugin}
197212
{#if pencilType !== "pencil"}
198-
<Button class="{name}-panel-switch-btn" {...btn_props} on:click={pencil}>
213+
<Button class="{name}-panel-switch-btn" {...btn_props} on:click={usePencil}>
199214
<Icons.Pencil {theme} />
200215
</Button>
201216
{:else if pencilType === "pencil"}

Diff for: packages/fastboard-ui/src/components/Toolbar/definitions/Pencil.svelte

+18-8
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,23 @@
1313
</script>
1414

1515
<Button class="pencil" {...btn_props} on:click {content} {menu}>
16-
{#if appliance === "pencil" && pencilType === "mark"}
17-
<Icons.MarkPenFilled {theme} active />
18-
{:else if appliance === "pencil" && pencilType === "laser"}
19-
<Icons.LaserPenFilled {theme} active />
20-
{:else if appliance === "pencil" && pencilType === "pencil"}
21-
<Icons.PencilFilled {theme} active />
22-
{:else}
23-
<Icons.Pencil {theme} />
16+
{#if pencilType === "mark"}
17+
{#if appliance === "pencil"}
18+
<Icons.MarkPenFilled {theme} active />
19+
{:else}
20+
<Icons.MarkPen {theme} />
21+
{/if}
22+
{:else if pencilType === "laser"}
23+
{#if appliance === "pencil"}
24+
<Icons.LaserPenFilled {theme} active />
25+
{:else}
26+
<Icons.LaserPen {theme} />
27+
{/if}
28+
{:else if pencilType === "pencil"}
29+
{#if appliance === "pencil"}
30+
<Icons.PencilFilled {theme} active />
31+
{:else}
32+
<Icons.Pencil {theme} />
33+
{/if}
2434
{/if}
2535
</Button>

0 commit comments

Comments
 (0)