添加注解
This commit is contained in:
parent
64de640cb8
commit
4e5c5aec6d
14
main.js
14
main.js
|
@ -4,22 +4,34 @@ const path = require('path')
|
||||||
|
|
||||||
// electorn
|
// electorn
|
||||||
const createWindow = () => {
|
const createWindow = () => {
|
||||||
|
// Create the browser window.
|
||||||
const win = new BrowserWindow({
|
const win = new BrowserWindow({
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
preload: path.join(__dirname, 'preload.js')
|
preload: path.join(__dirname, 'preload.js')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
// 加载 index.html
|
||||||
win.loadFile('index.html')
|
win.loadFile('index.html')
|
||||||
|
// 打开开发工具
|
||||||
|
// mainWindow.webContents.openDevTools()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 这段程序将会在 Electron 结束初始化
|
||||||
|
// 和创建浏览器窗口的时候调用
|
||||||
|
// 部分 API 在 ready 事件触发后才能使用。
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
createWindow()
|
createWindow()
|
||||||
|
// 在 macOS 系统内, 如果没有已开启的应用窗口
|
||||||
|
// 点击托盘图标时通常会重新创建一个新窗口
|
||||||
app.on('activate', () => {
|
app.on('activate', () => {
|
||||||
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
// 除了 macOS 外,当所有窗口都被关闭的时候退出程序。 因此, 通常
|
||||||
|
// 对应用程序和它们的菜单栏来说应该时刻保持激活状态,
|
||||||
|
// 直到用户使用 Cmd + Q 明确退出
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
if (process.platform !== 'darwin') app.quit()
|
if (process.platform !== 'darwin') app.quit()
|
||||||
})
|
})
|
|
@ -1,3 +1,5 @@
|
||||||
|
// 所有的 Node.js API接口 都可以在 preload 进程中被调用.
|
||||||
|
// 它拥有与Chrome扩展一样的沙盒。
|
||||||
window.addEventListener('DOMContentLoaded', () => {
|
window.addEventListener('DOMContentLoaded', () => {
|
||||||
const replaceText = (selector, text) => {
|
const replaceText = (selector, text) => {
|
||||||
const element = document.getElementById(selector)
|
const element = document.getElementById(selector)
|
||||||
|
|
Loading…
Reference in New Issue