mirror of
https://github.com/rubickCenter/rubick
synced 2025-06-20 19:22:43 +08:00
merge
This commit is contained in:
commit
8dd59720e0
@ -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 @@
|
|||||||
"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 @@
|
|||||||
"iohook": {
|
"iohook": {
|
||||||
"targets": [
|
"targets": [
|
||||||
"node-83",
|
"node-83",
|
||||||
"electron-85"
|
"electron-87"
|
||||||
],
|
],
|
||||||
"platforms": [
|
"platforms": [
|
||||||
"darwin",
|
"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 { 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 {
|
function createWindow() {
|
||||||
launchApp() {
|
main.init()
|
||||||
const gotTheLock = app.requestSingleInstanceLock()
|
init(main.getWindow())
|
||||||
if (!gotTheLock) {
|
|
||||||
app.quit()
|
|
||||||
} else {
|
|
||||||
this.beforeReady()
|
|
||||||
this.onReady()
|
|
||||||
this.onRunning()
|
|
||||||
this.onQuit()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
createWindow() {
|
app.on('ready', () => {
|
||||||
main.init();
|
createWindow()
|
||||||
init(main.getWindow());
|
createTray(main.getWindow())
|
||||||
}
|
autoUpdate()
|
||||||
|
})
|
||||||
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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onRunning() {
|
onRunning() {
|
||||||
app.on('second-instance', (event, commandLine, workingDirectory) => {
|
app.on('second-instance', (event, commandLine, workingDirectory) => {
|
||||||
// 当运行第二个实例时,将会聚焦到myWindow这个窗口
|
// 当运行第二个实例时,将会聚焦到myWindow这个窗口
|
||||||
const win = main.getWindow();
|
const win = main.getWindow()
|
||||||
if (win) {
|
if (win) {
|
||||||
if (win.isMinimized()) {
|
if (win.isMinimized()) {
|
||||||
win.restore();
|
win.restore()
|
||||||
}
|
}
|
||||||
win.focus();
|
win.focus()
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
app.on('activate', () => {
|
app.on('activate', () => {
|
||||||
if (!main.getWindow()) {
|
if (!main.getWindow()) {
|
||||||
this.createWindow();
|
this.createWindow()
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
if (commonConst.windows()) {
|
if (commonConst.windows()) {
|
||||||
app.setAppUserModelId(pkg.build.appId);
|
app.setAppUserModelId(pkg.build.appId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onQuit () {
|
app.on('activate', () => {
|
||||||
app.on('window-all-closed', () => {
|
createWindow()
|
||||||
if (process.platform !== 'darwin') {
|
|
||||||
app.quit()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('will-quit', () => {
|
(new initApp()).launchApp()
|
||||||
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()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
(new initApp()).launchApp();
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user