ADD: Proper window handling (max, min)
This commit is contained in:
@@ -64,18 +64,20 @@
|
|||||||
</MenubarMenu>
|
</MenubarMenu>
|
||||||
<div class="flex h-full">
|
<div class="flex h-full">
|
||||||
<button
|
<button
|
||||||
v-if="resizeable"
|
v-if="minimizable"
|
||||||
class="grow flex justify-center items-center app-titlebar-button hover:text-white px-2">
|
class="grow flex justify-center items-center app-titlebar-button hover:text-white px-2"
|
||||||
|
@click="electron.minimizeWindow">
|
||||||
<Minus class="h-5 w-5" />
|
<Minus class="h-5 w-5" />
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
v-if="resizeable"
|
v-if="maximizable"
|
||||||
class="grow flex justify-center items-center app-titlebar-button hover:text-white px-2">
|
class="grow flex justify-center items-center app-titlebar-button hover:text-white px-2"
|
||||||
|
@click="electron.toggleMaximizeWindow">
|
||||||
<Square class="h-3.5 w-3.5 mr-0.5" />
|
<Square class="h-3.5 w-3.5 mr-0.5" />
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="grow flex justify-center items-center app-titlebar-button hover:text-white px-2"
|
class="grow flex justify-center items-center app-titlebar-button hover:text-white px-2"
|
||||||
@click="window.close">
|
@click="electron.closeWindow">
|
||||||
<X class="h-5 w-5 mr-0.5" />
|
<X class="h-5 w-5 mr-0.5" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -100,7 +102,10 @@ import { useStore } from '@/store'
|
|||||||
|
|
||||||
const store = useStore()
|
const store = useStore()
|
||||||
|
|
||||||
const resizeable = ref(false)
|
const minimizable = ref(true)
|
||||||
|
const maximizable = ref(true)
|
||||||
|
|
||||||
|
const { electron } = window
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
<div v-else class="flex flex-col items-center text-center mix-blend-screen">
|
<div v-else class="flex flex-col items-center text-center mix-blend-screen">
|
||||||
<ScrambleText
|
<ScrambleText
|
||||||
:text="offlineText"
|
:text="offlineText"
|
||||||
|
character-set="_()*=0011"
|
||||||
scramble-on-mount
|
scramble-on-mount
|
||||||
:fill-interval="50"
|
:fill-interval="50"
|
||||||
:replace-interval="50"
|
:replace-interval="50"
|
||||||
@@ -93,7 +94,6 @@ const offlineTexts = [
|
|||||||
|
|
||||||
let offlineTextIndex = 0
|
let offlineTextIndex = 0
|
||||||
const nextOfflineText = () => {
|
const nextOfflineText = () => {
|
||||||
console.log(offlineText.value)
|
|
||||||
if (offlineText.value === '') {
|
if (offlineText.value === '') {
|
||||||
offlineText.value = offlineTexts[offlineTextIndex]
|
offlineText.value = offlineTexts[offlineTextIndex]
|
||||||
offlineTextIndex = (offlineTextIndex + 1) % offlineTexts.length
|
offlineTextIndex = (offlineTextIndex + 1) % offlineTexts.length
|
||||||
|
|||||||
12
src/main.js
12
src/main.js
@@ -24,7 +24,7 @@ const createWindow = () => {
|
|||||||
resizable: true,
|
resizable: true,
|
||||||
minWidth: width / 3,
|
minWidth: width / 3,
|
||||||
minHeight: height / 3,
|
minHeight: height / 3,
|
||||||
maximizable: false,
|
maximizable: true,
|
||||||
fullscreenable: false,
|
fullscreenable: false,
|
||||||
center: true,
|
center: true,
|
||||||
backgroundColor: '#000',
|
backgroundColor: '#000',
|
||||||
@@ -33,6 +33,7 @@ const createWindow = () => {
|
|||||||
devTools: !app.isPackaged,
|
devTools: !app.isPackaged,
|
||||||
preload: path.join(__dirname, 'preload.js'),
|
preload: path.join(__dirname, 'preload.js'),
|
||||||
zoomFactor: zoomFactor,
|
zoomFactor: zoomFactor,
|
||||||
|
enableRemoteModule: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -64,6 +65,15 @@ app.whenReady().then(() => {
|
|||||||
ipcMain.handle('nano:get', nano.get)
|
ipcMain.handle('nano:get', nano.get)
|
||||||
ipcMain.handle('nano:set', nano.set)
|
ipcMain.handle('nano:set', nano.set)
|
||||||
const mainWindow = createWindow()
|
const mainWindow = createWindow()
|
||||||
|
ipcMain.on('electron:minimizeWindow', () => mainWindow.minimize())
|
||||||
|
ipcMain.on('electron:toggleMaximizeWindow', () => {
|
||||||
|
if (mainWindow.isMaximized()) {
|
||||||
|
mainWindow.unmaximize()
|
||||||
|
} else {
|
||||||
|
mainWindow.maximize()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
ipcMain.on('electron:closeWindow', () => mainWindow.close())
|
||||||
nanodevices.onAttach((device) => {
|
nanodevices.onAttach((device) => {
|
||||||
console.log('Attached device', device)
|
console.log('Attached device', device)
|
||||||
mainWindow.webContents.send('nanodevice-attached', device)
|
mainWindow.webContents.send('nanodevice-attached', device)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// See the Electron documentation for details on how to use preload scripts:
|
// See the Electron documentation for details on how to use preload scripts:
|
||||||
// https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts
|
// https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts
|
||||||
|
|
||||||
const { contextBridge, ipcRenderer } = require('electron')
|
const { contextBridge, ipcRenderer, remote } = require('electron')
|
||||||
|
|
||||||
|
|
||||||
// expose an API to choose available devices
|
// expose an API to choose available devices
|
||||||
@@ -36,3 +36,13 @@ contextBridge.exposeInMainWorld('nanodevice', {
|
|||||||
ipcRenderer.on('nano-onvalue', (_event, value) => listener(value))
|
ipcRenderer.on('nano-onvalue', (_event, value) => listener(value))
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
//window.maximize = () => remote.BrowserWindow.getFocusedWindow().maximize()
|
||||||
|
//window.maximize = () => remote.BrowserWindow.getFocusedWindow().minimize()
|
||||||
|
window.funnyThing = 'This is a funny thing!'
|
||||||
|
|
||||||
|
contextBridge.exposeInMainWorld('electron', {
|
||||||
|
minimizeWindow: () => ipcRenderer.send('electron:minimizeWindow'),
|
||||||
|
toggleMaximizeWindow: () => ipcRenderer.send('electron:toggleMaximizeWindow'),
|
||||||
|
closeWindow: () => ipcRenderer.send('electron:closeWindow'),
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user