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

merge

......@@ -91,6 +91,7 @@
"vuex-electron": "^1.0.0"
},
"devDependencies": {
"babel-runtime": "^6.26.0",
"ajv": "^6.5.0",
"babel-core": "^6.26.3",
"babel-loader": "^7.1.4",
......@@ -106,7 +107,7 @@
"css-loader": "^0.28.11",
"del": "^3.0.0",
"devtron": "^1.4.0",
"electron": "^11.0.2",
"electron": "^12.0.15",
"electron-builder": "22.10.5",
"electron-debug": "^1.5.0",
"electron-devtools-installer": "^2.2.4",
......@@ -137,7 +138,7 @@
"iohook": {
"targets": [
"node-83",
"electron-85"
"electron-87"
],
"platforms": [
"darwin",
......
此差异已折叠。
import { app, globalShortcut } from 'electron'
import '../renderer/store'
import init from './common/common';
import {autoUpdate} from './common/autoUpdate';
import createTray from './tray';
import {commonConst} from './common/utils';
import pkg from '../../package.json';
const {main} = require("./browsers")();
if (commonConst.production()) {
import init from './common/common'
import { autoUpdate } from './common/autoUpdate'
import createTray from './tray'
const { main } = require("./browsers")()
/**
* Set `__static` path to static files in production
* https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
*/
if (process.env.NODE_ENV !== 'development') {
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() {
const readyFunction = () => {
this.createWindow();
createTray(main.getWindow());
autoUpdate();
}
if (!app.isReady()) {
app.on('ready', readyFunction)
} else {
readyFunction()
}
}
function createWindow() {
main.init()
init(main.getWindow())
}
onRunning() {
app.on('second-instance', (event, commandLine, workingDirectory) => {
// 当运行第二个实例时,将会聚焦到myWindow这个窗口
const win = main.getWindow();
if (win) {
if (win.isMinimized()) {
win.restore();
}
win.focus();
}
});
app.on('activate', () => {
if (!main.getWindow()) {
this.createWindow();
app.on('ready', () => {
createWindow()
createTray(main.getWindow())
autoUpdate()
})
onRunning() {
app.on('second-instance', (event, commandLine, workingDirectory) => {
// 当运行第二个实例时,将会聚焦到myWindow这个窗口
const win = main.getWindow()
if (win) {
if (win.isMinimized()) {
win.restore()
}
});
if (commonConst.windows()) {
app.setAppUserModelId(pkg.build.appId);
win.focus()
}
}
onQuit () {
app.on('window-all-closed', () => {
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()
})
}
})
app.on('activate', () => {
if (!main.getWindow()) {
this.createWindow()
}
})
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.
先完成此消息的编辑!
想要评论请 注册