Skip to content

Commit d84f7f2

Browse files
committed
fix: use webview window for help button in desktop app
1 parent d054ae3 commit d84f7f2

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

src-tauri/capabilities/default.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"core:default",
1010
"fs:default",
1111
"http:default",
12+
"core:webview:allow-create-webview-window",
1213
{
1314
"identifier": "http:allow-fetch",
1415
"allow": [

src/components/Panels/Shared/HelpButton.vue

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,39 @@
22
<p v-if="helplink" class="btn-parent">
33
<button
44
id="HelpButton"
5-
class="btn btn-primary btn-xs" type="button"
5+
class="btn btn-primary btn-xs"
6+
type="button"
67
@click="helpButtonClick"
78
>
8-
&#9432 Help
9+
&#9432; Help
910
</button>
1011
</p>
1112
</template>
1213

1314
<script lang="ts" setup>
15+
import { isTauri } from '@tauri-apps/api/core'
16+
import { WebviewWindow } from '@tauri-apps/api/webviewWindow'
17+
import { computed } from 'vue'
18+
1419
const props = defineProps({
15-
obj: { type: Object, default: undefined },
20+
obj: { type: Object, default: undefined },
1621
})
17-
const helplink = props.obj ?. helplink
18-
function helpButtonClick() {
19-
window.open(helplink)
22+
23+
const helplink = computed(() => props.obj?.helplink)
24+
25+
async function helpButtonClick() {
26+
const link = helplink.value
27+
if (!link) return
28+
29+
if (await isTauri()) {
30+
new WebviewWindow(`help-${Date.now()}`, {
31+
url: link,
32+
title: 'Help - CircuitVerse',
33+
width: 1000,
34+
height: 700
35+
})
36+
} else {
37+
window.open(link, '_blank')
38+
}
2039
}
2140
</script>

0 commit comments

Comments
 (0)