mirror of
https://github.com/rubickCenter/rubick
synced 2025-06-19 02:08:37 +08:00
merge
This commit is contained in:
commit
8dd59720e0
@ -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",
|
||||
|
11567
pnpm-lock.yaml
generated
Normal file
11567
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,109 +1,51 @@
|
||||
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()
|
||||
}
|
||||
}
|
||||
function createWindow() {
|
||||
main.init()
|
||||
init(main.getWindow())
|
||||
}
|
||||
|
||||
createWindow() {
|
||||
main.init();
|
||||
init(main.getWindow());
|
||||
}
|
||||
app.on('ready', () => {
|
||||
createWindow()
|
||||
createTray(main.getWindow())
|
||||
autoUpdate()
|
||||
})
|
||||
|
||||
beforeReady() {
|
||||
// 系统托盘
|
||||
if (commonConst.macOS()) {
|
||||
if (commonConst.production() && !app.isInApplicationsFolder()) {
|
||||
app.moveToApplicationsFolder();
|
||||
} else {
|
||||
app.dock.hide();
|
||||
onRunning() {
|
||||
app.on('second-instance', (event, commandLine, workingDirectory) => {
|
||||
// 当运行第二个实例时,将会聚焦到myWindow这个窗口
|
||||
const win = main.getWindow()
|
||||
if (win) {
|
||||
if (win.isMinimized()) {
|
||||
win.restore()
|
||||
}
|
||||
}else {
|
||||
app.disableHardwareAcceleration();
|
||||
win.focus()
|
||||
}
|
||||
}
|
||||
|
||||
onReady() {
|
||||
const readyFunction = () => {
|
||||
this.createWindow();
|
||||
createTray(main.getWindow());
|
||||
autoUpdate();
|
||||
}
|
||||
if (!app.isReady()) {
|
||||
app.on('ready', readyFunction)
|
||||
} else {
|
||||
readyFunction()
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
});
|
||||
if (commonConst.windows()) {
|
||||
app.setAppUserModelId(pkg.build.appId);
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user