1.0.0 • Published 2 years ago
yxlolxy-electron-plugins v1.0.0
yxlolxy-electron-plugins
Install
yarn add yxlolxy-electron-plugins
# Or with npm:
npm i yxlolxy-electron-plugins
Note: this package has a peerDependency of electron@^15.1.2, and only works in window10+
Usage
- import pkg into your main.js
// main.js of your electron app
const { useCapture, usePreview } = require('yxlolxy-electron-plugins')
let mainWindow = null;
...
app.whenReady().then(() => {
...
useCapture(mainWindow) // transfer mainWindow to send message to mainWindow render process
usePreview()
})
...
- events of capture
// renderer.js
// start the event
ipcRenderer.invoke('screen-capture', {
type: 'start'
})
// handle the event
ipcRenderer.on('screen-capture', (e, url) => {
// handle the url
...
})
// close the event,press ESC or click right button of your mouse
- events of preview
// renderer.js
// start the event
ipcRenderer.invoke('image-preview', {
type: 'show',
url:: '', // your image url
filename: '' // your image origin filename
})
enjoy it!
1.0.0
2 years ago