This repository has been archived by the owner on Sep 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
WindowControls.vue
98 lines (92 loc) · 1.94 KB
/
WindowControls.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<template>
<title-bar
:class="{
[$style.inverted]: isLayoutInverted,
}"
:indent="!isLayoutInverted"
>
<template v-if="!$options.isMac">
<title-bar-button
icon="window-close"
schema="red"
@click="window.close()"
/>
<title-bar-button
:icon="isMaximized ? 'window-restore' : 'window-maximize'"
schema="orange"
@click="toggleMaximized()"
/>
<title-bar-button
icon="window-minimize"
schema="green"
@click="window.minimize()"
/>
</template>
<div :class="$style.spacer" />
<title-bar-button
:to="{ name: 'tabs-create' }"
icon="tab-plus"
/>
<title-bar-button
:to="{ name: 'notifications' }"
icon="bell"
/>
<title-bar-button
:to="{ name: 'settings' }"
icon="settings"
/>
</title-bar>
</template>
<script>
import TitleBar from '@/components/TitleBar.vue';
import TitleBarButton from '@/components/TitleBarButton.vue';
export default {
components: {
TitleBar,
TitleBarButton,
},
isMac: process.platform === 'darwin',
data() {
return {
isMaximized: false,
};
},
computed: {
window() {
return this.$electron.remote.getCurrentWindow();
},
isLayoutInverted() {
return this.$store.getters['Settings/isLayoutInverted'];
},
},
created() {
this.watchMaximizedState();
},
methods: {
watchMaximizedState() {
this.isMaximized = this.window.isMaximized();
this.window.on('maximize', () => {
this.isMaximized = true;
});
this.window.on('unmaximize', () => {
this.isMaximized = false;
});
},
toggleMaximized() {
if (this.isMaximized) {
this.window.unmaximize();
} else {
this.window.maximize();
}
},
},
};
</script>
<style lang="postcss" module>
.inverted {
@apply flex-row-reverse;
}
.spacer {
@apply flex-grow;
}
</style>