|
@@ -1,4 +1,5 @@
|
|
|
-const { app, BrowserWindow } = require('electron')
|
|
|
+const { app, BrowserWindow, ipcMain, clipboard } = require('electron')
|
|
|
+const path = require('path')
|
|
|
|
|
|
let mainWindow = null
|
|
|
|
|
@@ -8,7 +9,7 @@ function createWindow () {
|
|
|
height: 400,
|
|
|
title: 'Clipboard paste',
|
|
|
webPreferences: {
|
|
|
- nodeIntegration: true
|
|
|
+ preload: path.join(__dirname, 'preload.js')
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -20,6 +21,22 @@ function createWindow () {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ipcMain.handle('clipboard:readText', () => {
|
|
|
+ return clipboard.readText()
|
|
|
+})
|
|
|
+
|
|
|
+ipcMain.handle('clipboard:writeText', (event, text) => {
|
|
|
+ clipboard.writeText(text)
|
|
|
+})
|
|
|
+
|
|
|
app.whenReady().then(() => {
|
|
|
createWindow()
|
|
|
+
|
|
|
+ app.on('activate', function () {
|
|
|
+ if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+app.on('window-all-closed', function () {
|
|
|
+ if (process.platform !== 'darwin') app.quit()
|
|
|
})
|