UPD: ECMA2020 Linting + Working close button

This commit is contained in:
Robert Kossessa
2024-02-02 01:26:13 +01:00
parent e09076fc1f
commit a18f661358
4 changed files with 757 additions and 16 deletions

View File

@@ -61,18 +61,18 @@
<button
v-if="resizeable"
class="grow flex justify-center items-center app-titlebar-button hover:text-white px-2"
@click="oi('Not implemented ¯\\_(ツ)_/¯')">
@click="window.window.minimize">
<Minus class="h-5 w-5" />
</button>
<button
v-if="resizeable"
class="grow flex justify-center items-center app-titlebar-button hover:text-white px-2"
@click="oi('Not implemented ¯\\_(ツ)_/¯')">
@click="window.window.maximize">
<Square class="h-3.5 w-3.5 mr-0.5" />
</button>
<button
class="grow flex justify-center items-center app-titlebar-button hover:text-white px-2"
@click="oi('Not implemented ¯\\_(ツ)_/¯')">
@click="window.window.close">
<X class="h-5 w-5 mr-0.5" />
</button>
</div>
@@ -94,8 +94,6 @@ import { X, Square, Minus } from 'lucide-vue-next'
import { Button } from '@/components/ui/button'
import { ref } from 'vue'
const oi = (msg) => alert(msg)
const resizeable = ref(false)
</script>

View File

@@ -1,22 +1,51 @@
// See the Electron documentation for details on how to use preload scripts:
// https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts
const { contextBridge, ipcRenderer } = require('electron')
const { contextBridge, ipcRenderer, BrowserWindow } = require('electron')
// expose an API to choose available devices
contextBridge.exposeInMainWorld('nanodevices', {
list() { ipcRenderer.invoke('nanodevices:list'); },
connect(devicename) { ipcRenderer.invoke('nanodevices:connect', devicename); },
disconnect() { ipcRenderer.invoke('nanodevices:disconnect'); },
on_device_attached(listener) { ipcRenderer.on('nanodevice-attached', (_event, value) => listener(value)); },
on_device_detached(listener) { ipcRenderer.on('nanodevice-detached', (_event, value) => listener(value)); },
});
list() {
ipcRenderer.invoke('nanodevices:list')
},
connect(devicename) {
ipcRenderer.invoke('nanodevices:connect', devicename)
},
disconnect() {
ipcRenderer.invoke('nanodevices:disconnect')
},
on_device_attached(listener) {
ipcRenderer.on('nanodevice-attached', (_event, value) => listener(value))
},
on_device_detached(listener) {
ipcRenderer.on('nanodevice-detached', (_event, value) => listener(value))
},
})
// expose an API to communicate with the nano device
contextBridge.exposeInMainWorld('nanodevice', {
get_value(pid, tid, vid){ ipcRenderer.invoke('nano:get', pid, tid, vid); },
set_value(pid, tid, vid, value){ ipcRenderer.invoke('nano:set', pid, tid, vid, value); },
on_value(listener){ ipcRenderer.on('nano-onvalue', (_event, value) => listener(value)); }
});
get_value(pid, tid, vid) {
ipcRenderer.invoke('nano:get', pid, tid, vid)
},
set_value(pid, tid, vid, value) {
ipcRenderer.invoke('nano:set', pid, tid, vid, value)
},
on_value(listener) {
ipcRenderer.on('nano-onvalue', (_event, value) => listener(value))
},
})
// expose an API to close the app
contextBridge.exposeInMainWorld('window', {
minimize() {
BrowserWindow.getFocusedWindow()?.minimize()
},
maximize() {
BrowserWindow.getFocusedWindow()?.maximize()
},
close() {
BrowserWindow.getFocusedWindow()?.close()
},
})