2023-08-28 11:23:10 +00:00
|
|
|
const { app, BrowserWindow, ipcMain, clipboard } = require('electron/main')
|
2023-07-17 08:30:53 +00:00
|
|
|
const path = require('node:path')
|
2019-10-10 13:48:33 +00:00
|
|
|
|
|
|
|
let mainWindow = null
|
|
|
|
|
|
|
|
function createWindow () {
|
|
|
|
const windowOptions = {
|
|
|
|
width: 600,
|
|
|
|
height: 400,
|
|
|
|
title: 'Clipboard copy',
|
|
|
|
webPreferences: {
|
2023-01-19 19:59:35 +00:00
|
|
|
preload: path.join(__dirname, 'preload.js')
|
2019-10-10 13:48:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mainWindow = new BrowserWindow(windowOptions)
|
|
|
|
mainWindow.loadFile('index.html')
|
|
|
|
|
|
|
|
mainWindow.on('closed', () => {
|
|
|
|
mainWindow = null
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-01-19 19:59:35 +00:00
|
|
|
ipcMain.handle('clipboard:writeText', (event, text) => {
|
|
|
|
clipboard.writeText(text)
|
|
|
|
})
|
|
|
|
|
2020-02-03 22:43:22 +00:00
|
|
|
app.whenReady().then(() => {
|
2019-10-10 13:48:33 +00:00
|
|
|
createWindow()
|
2023-02-01 11:59:16 +00:00
|
|
|
|
2023-01-19 19:59:35 +00:00
|
|
|
app.on('activate', function () {
|
|
|
|
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
app.on('window-all-closed', function () {
|
|
|
|
if (process.platform !== 'darwin') app.quit()
|
2019-10-10 13:48:33 +00:00
|
|
|
})
|