提交 8dd59720 编写于 作者: S sovlookup

merge

...@@ -91,6 +91,7 @@ ...@@ -91,6 +91,7 @@
"vuex-electron": "^1.0.0" "vuex-electron": "^1.0.0"
}, },
"devDependencies": { "devDependencies": {
"babel-runtime": "^6.26.0",
"ajv": "^6.5.0", "ajv": "^6.5.0",
"babel-core": "^6.26.3", "babel-core": "^6.26.3",
"babel-loader": "^7.1.4", "babel-loader": "^7.1.4",
...@@ -106,7 +107,7 @@ ...@@ -106,7 +107,7 @@
"css-loader": "^0.28.11", "css-loader": "^0.28.11",
"del": "^3.0.0", "del": "^3.0.0",
"devtron": "^1.4.0", "devtron": "^1.4.0",
"electron": "^11.0.2", "electron": "^12.0.15",
"electron-builder": "22.10.5", "electron-builder": "22.10.5",
"electron-debug": "^1.5.0", "electron-debug": "^1.5.0",
"electron-devtools-installer": "^2.2.4", "electron-devtools-installer": "^2.2.4",
...@@ -137,7 +138,7 @@ ...@@ -137,7 +138,7 @@
"iohook": { "iohook": {
"targets": [ "targets": [
"node-83", "node-83",
"electron-85" "electron-87"
], ],
"platforms": [ "platforms": [
"darwin", "darwin",
......
此差异已折叠。
import { app, globalShortcut } from 'electron' import { app, globalShortcut } from 'electron'
import '../renderer/store' import '../renderer/store'
import init from './common/common'; import init from './common/common'
import {autoUpdate} from './common/autoUpdate'; import { autoUpdate } from './common/autoUpdate'
import createTray from './tray'; import createTray from './tray'
import {commonConst} from './common/utils'; const { main } = require("./browsers")()
import pkg from '../../package.json'; /**
* Set `__static` path to static files in production
const {main} = require("./browsers")(); * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
*/
if (commonConst.production()) { if (process.env.NODE_ENV !== 'development') {
global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\') global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')
} }
// to fix https://github.com/electron/electron/issues/18397
app.allowRendererProcessReuse = false;
class initApp {
launchApp() {
const gotTheLock = app.requestSingleInstanceLock()
if (!gotTheLock) {
app.quit()
} else {
this.beforeReady()
this.onReady()
this.onRunning()
this.onQuit()
}
}
createWindow() {
main.init();
init(main.getWindow());
}
beforeReady() {
// 系统托盘
if (commonConst.macOS()) {
if (commonConst.production() && !app.isInApplicationsFolder()) {
app.moveToApplicationsFolder();
} else {
app.dock.hide();
}
}else {
app.disableHardwareAcceleration();
}
}
onReady() { function createWindow() {
const readyFunction = () => { main.init()
this.createWindow(); init(main.getWindow())
createTray(main.getWindow()); }
autoUpdate();
}
if (!app.isReady()) {
app.on('ready', readyFunction)
} else {
readyFunction()
}
}
onRunning() { app.on('ready', () => {
app.on('second-instance', (event, commandLine, workingDirectory) => { createWindow()
// 当运行第二个实例时,将会聚焦到myWindow这个窗口 createTray(main.getWindow())
const win = main.getWindow(); autoUpdate()
if (win) { })
if (win.isMinimized()) {
win.restore(); onRunning() {
} app.on('second-instance', (event, commandLine, workingDirectory) => {
win.focus(); // 当运行第二个实例时,将会聚焦到myWindow这个窗口
} const win = main.getWindow()
}); if (win) {
app.on('activate', () => { if (win.isMinimized()) {
if (!main.getWindow()) { win.restore()
this.createWindow();
} }
}); win.focus()
if (commonConst.windows()) {
app.setAppUserModelId(pkg.build.appId);
} }
} })
app.on('activate', () => {
onQuit () { if (!main.getWindow()) {
app.on('window-all-closed', () => { this.createWindow()
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('will-quit', () => {
globalShortcut.unregisterAll()
})
// Exit cleanly on request from parent process in development mode.
if (commonConst.dev()) {
if (process.platform === 'win32') {
process.on('message', data => {
if (data === 'graceful-exit') {
app.quit()
}
})
} else {
process.on('SIGTERM', () => {
app.quit()
})
}
} }
})
if (commonConst.windows()) {
app.setAppUserModelId(pkg.build.appId)
} }
} }
(new initApp()).launchApp(); app.on('activate', () => {
createWindow()
})
(new initApp()).launchApp()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册