docs: update clipboard fiddles (#36946)
This commit is contained in:
parent
55c818d0a8
commit
4e4ae9ff53
10 changed files with 55 additions and 20 deletions
|
@ -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 copy',
|
||||
webPreferences: {
|
||||
nodeIntegration: true
|
||||
preload: path.join(__dirname, 'preload.js')
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,6 +21,18 @@ function createWindow () {
|
|||
})
|
||||
}
|
||||
|
||||
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()
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue