Skip to content

Commit 4817570

Browse files
committed
custom window frame on windows
1 parent 717af09 commit 4817570

3 files changed

Lines changed: 76 additions & 5 deletions

File tree

app/app.vue

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,60 @@ const dir = computed(() => locales[locale.value].dir)
99
useHead({
1010
htmlAttrs: { lang, dir },
1111
})
12+
13+
const closeWindow = () => {
14+
electrobun.rpc?.send("windowClose", {})
15+
}
16+
17+
const platform = ref("unknown")
18+
19+
onMounted(async () => {
20+
const platformResponse = await electrobun.rpc?.request("getPlatform", {})
21+
if (platformResponse?.output) {
22+
platform.value = platformResponse.output
23+
}
24+
})
1225
</script>
1326

1427
<template>
1528
<UApp :locale="locales[locale]">
16-
<UHeader title="dlpgui" :toggle="false" to="/download">
29+
<UHeader
30+
title="dlpgui"
31+
:toggle="false"
32+
to="/download"
33+
class="electrobun-webkit-app-region-drag"
34+
:ui="{
35+
left: 'electrobun-webkit-app-region-no-drag',
36+
right: 'electrobun-webkit-app-region-no-drag',
37+
}"
38+
>
1739
<template #right>
1840
<UButton
1941
to="/settings"
2042
color="neutral"
2143
variant="ghost"
2244
icon="lucide:settings"
45+
size="sm"
46+
class="opacity-75"
47+
/>
48+
<!-- <UButton
49+
color="neutral"
50+
variant="ghost"
51+
icon="material-symbols:chrome-minimize-rounded"
52+
/>
53+
<UButton
54+
color="neutral"
55+
variant="ghost"
56+
icon="material-symbols:chrome-maximize-outline"
57+
/> -->
58+
<UButton
59+
color="neutral"
60+
variant="ghost"
61+
icon="material-symbols:close-rounded"
62+
size="xl"
63+
@click="closeWindow"
64+
class="ml-4"
65+
v-if="platform !== 'darwin'"
2366
/>
2467
</template>
2568
</UHeader>

bun/index.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import type { MyRPC } from "../shared/types/rpc"
22

3+
import { platform } from "node:os"
4+
35
import {
46
BrowserWindow,
57
Updater,
@@ -83,8 +85,23 @@ const rpc = BrowserView.defineRPC<MyRPC>({
8385
await Updater.applyUpdate()
8486
}
8587
},
88+
getPlatform: async () => {
89+
return {
90+
output: platform(),
91+
}
92+
},
93+
},
94+
messages: {
95+
windowMinimize: () => mainWindow.minimize(),
96+
windowMaximize: () => {
97+
if (mainWindow.isMaximized()) {
98+
mainWindow.unmaximize()
99+
} else {
100+
mainWindow.maximize()
101+
}
102+
},
103+
windowClose: () => mainWindow.close(),
86104
},
87-
messages: {},
88105
},
89106
})
90107

@@ -113,8 +130,7 @@ const display = Screen.getPrimaryDisplay()
113130
const windowWidth = 800
114131
const windowHeight = 600
115132

116-
// const mainWindow =
117-
new BrowserWindow({
133+
const mainWindow = new BrowserWindow({
118134
title: "dlpgui",
119135
url,
120136
rpc,
@@ -124,4 +140,8 @@ new BrowserWindow({
124140
width: windowWidth,
125141
height: windowHeight,
126142
},
143+
titleBarStyle: platform() === "darwin" ? "default" : "hidden",
144+
styleMask: {
145+
Resizable: false,
146+
},
127147
})

shared/types/rpc.d.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,16 @@ export type MyRPC = {
2424
params: {}
2525
response: {}
2626
}
27+
getPlatform: {
28+
params: {}
29+
response: { output: string }
30+
}
31+
}
32+
messages: {
33+
windowMinimize: {}
34+
windowMaximize: {}
35+
windowClose: {}
2736
}
28-
messages: {}
2937
}>
3038
webview: RPCSchema<{
3139
requests: {}

0 commit comments

Comments
 (0)