1
0
mirror of https://github.com/S2-/gitlit synced 2025-08-03 21:00:04 +02:00
Files
gitlit/app/node_modules/electron-find/example/main.js
2019-06-06 15:56:42 +02:00

48 lines
1.0 KiB
JavaScript

const electron = require('electron')
const { app, BrowserWindow, globalShortcut } = electron
const path = require('path')
let win
const winURL = 'file://' + path.normalize(`${__dirname}/index.html`)
function createWindow () {
win = new BrowserWindow({
width: 1280,
height: 1040,
center: false,
webPreferences: {
nodeIntegration: true,
plugins: true,
}
})
win.loadURL(winURL)
//win.webContents.openDevTools()
win.on('closed', () => {
win = null
})
win.on('focus', () => {
globalShortcut.register('CommandOrControl+F', function () {
if (win && win.webContents) {
win.webContents.send('on-find', '')
}
})
})
win.on('blur', () => {
globalShortcut.unregister('CommandOrControl+F')
})
}
app.on('ready', createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
globalShortcut.unregister('CommandOrControl+F')
})
app.on('activate', () => {
if (win === null) createWindow()
})