mirror of
https://github.com/S2-/gitlit
synced 2025-08-03 12:50:04 +02:00
fix search window
This commit is contained in:
22
app/node_modules/electron-find/example2/inner1.html
generated
vendored
Normal file
22
app/node_modules/electron-find/example2/inner1.html
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>webview 1</title>
|
||||
<style>
|
||||
.content{
|
||||
margin: 10px;
|
||||
padding: 10px;
|
||||
border: 1px solid rgb(236, 119, 236);
|
||||
border-radius: 4px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
<h3>In webview 1</h3>
|
||||
<div>content 1</div>
|
||||
<div>content 1</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
22
app/node_modules/electron-find/example2/inner2.html
generated
vendored
Normal file
22
app/node_modules/electron-find/example2/inner2.html
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>webview 2</title>
|
||||
<style>
|
||||
.content{
|
||||
margin: 10px;
|
||||
padding: 10px;
|
||||
border: 1px solid rgb(164, 195, 216);
|
||||
border-radius: 4px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
<h3>In webview 2</h3>
|
||||
<div>content 2</div>
|
||||
<div>content 2</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
47
app/node_modules/electron-find/example2/main.js
generated
vendored
Normal file
47
app/node_modules/electron-find/example2/main.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
const electron = require('electron')
|
||||
const { app, BrowserWindow, globalShortcut } = electron
|
||||
const path = require('path')
|
||||
let win
|
||||
const winURL = 'file://' + path.normalize(`${__dirname}/outer.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()
|
||||
})
|
||||
|
27
app/node_modules/electron-find/example2/outer.html
generated
vendored
Normal file
27
app/node_modules/electron-find/example2/outer.html
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Outer</title>
|
||||
<style>
|
||||
.app{
|
||||
height: 100%;
|
||||
}
|
||||
.outer{
|
||||
padding: 16px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="app">
|
||||
<div class="outer">
|
||||
<h3>Is in app</h3>
|
||||
<div>Main content</div>
|
||||
</div>
|
||||
<hr>
|
||||
<webview id="webview1" src="./inner1.html"></webview>
|
||||
<webview id="webview2" src="./inner2.html"></webview>
|
||||
</div>
|
||||
<script src="outer.js"></script>
|
||||
</body>
|
||||
</html>
|
37
app/node_modules/electron-find/example2/outer.js
generated
vendored
Normal file
37
app/node_modules/electron-find/example2/outer.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
const { remote, ipcRenderer } = require('electron')
|
||||
const { FindInPage } = require('../src/index.js')
|
||||
|
||||
let findInPage = null
|
||||
const webview1 = document.querySelector('#webview1')
|
||||
webview1.addEventListener('dom-ready', () => {
|
||||
findInPage = new FindInPage(webview1.getWebContents())
|
||||
ipcRenderer.on('on-find', (e, args) => {
|
||||
findInPage.openFindWindow()
|
||||
})
|
||||
})
|
||||
webview1.addEventListener('close', () => {
|
||||
console.log('webview1 close', )
|
||||
if (findInPage) {
|
||||
findInPage.destroy()
|
||||
findInPage = null
|
||||
}
|
||||
})
|
||||
webview1.addEventListener('destroyed', () => {
|
||||
console.log('webview1 destroyed', )
|
||||
if (findInPage) {
|
||||
findInPage.destroy()
|
||||
findInPage = null
|
||||
}
|
||||
})
|
||||
|
||||
webview1.addEventListener('crashed', () => {
|
||||
console.log('webview1 crashed', )
|
||||
if (findInPage) {
|
||||
findInPage.destroy()
|
||||
findInPage = null
|
||||
}
|
||||
})
|
||||
|
||||
ipcRenderer.on('on-find', (e, args) => {
|
||||
findInPage ? findInPage.openFindWindow() : ''
|
||||
})
|
Reference in New Issue
Block a user