|
@@ -1,6 +1,6 @@
|
|
|
'use strict'
|
|
|
|
|
|
-import { app, protocol, BrowserWindow, Menu, globalShortcut } from 'electron'
|
|
|
+import { app, protocol, BrowserWindow, Menu, globalShortcut, screen } from 'electron'
|
|
|
import { createProtocol } from 'vue-cli-plugin-electron-builder/lib'
|
|
|
import installExtension, { VUEJS_DEVTOOLS } from 'electron-devtools-installer'
|
|
|
import { updateHandle } from './update'
|
|
@@ -39,21 +39,24 @@ protocol.registerSchemesAsPrivileged([
|
|
|
])
|
|
|
|
|
|
async function createWindow() {
|
|
|
+ const {width,height} = screen.getPrimaryDisplay().workAreaSize;//获取到屏幕的宽度和高度
|
|
|
+ console.log(width,height);
|
|
|
// Create the browser window.
|
|
|
const win = new BrowserWindow({
|
|
|
- width: 800,
|
|
|
- height: 600,
|
|
|
+ width: width,
|
|
|
+ height: height,
|
|
|
darkTheme: true,
|
|
|
minWidth: 710,
|
|
|
minHeight: 500,
|
|
|
- show: false, // 先隐藏
|
|
|
+ show: true,
|
|
|
backgroundColor: '#211f1d',
|
|
|
+ fullscreen: false,
|
|
|
webPreferences: {
|
|
|
- webSecurity: false,
|
|
|
+ webSecurity: true,
|
|
|
enableRemoteModule: true,
|
|
|
// Use pluginOptions.nodeIntegration, leave this alone
|
|
|
// See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more info
|
|
|
- nodeIntegration: true,
|
|
|
+ nodeIntegration: false,
|
|
|
contextIsolation: false,
|
|
|
icon: `${__static}/app.ico`
|
|
|
}
|
|
@@ -67,11 +70,12 @@ async function createWindow() {
|
|
|
} else {
|
|
|
createProtocol('app')
|
|
|
win.loadURL(process.env.VUE_APP_API_BASE_URL)
|
|
|
- win.on('ready-to-show', function () {
|
|
|
- loadingWindow.hide();
|
|
|
- loadingWindow.close();
|
|
|
- win.maximize()
|
|
|
- win.show() // 初始化后再显示
|
|
|
+ win.on('ready-to-show', (event) => {
|
|
|
+ setTimeout(() => {
|
|
|
+ // loadingWindow.hide();
|
|
|
+ // loadingWindow.close();
|
|
|
+ win.show()
|
|
|
+ }, 2000);
|
|
|
})
|
|
|
}
|
|
|
// 在开发环境和生产环境均可通过快捷键打开devTools
|
|
@@ -109,7 +113,7 @@ if (!gotTheLock) {
|
|
|
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
|
|
})
|
|
|
// 禁用缓存
|
|
|
- app.commandLine.appendSwitch("--disable-http-cache")
|
|
|
+ // app.commandLine.appendSwitch("--disable-http-cache")
|
|
|
// This method will be called when Electron has finished
|
|
|
// initialization and is ready to create browser windows.
|
|
|
// Some APIs can only be used after this event occurs.
|
|
@@ -122,7 +126,9 @@ if (!gotTheLock) {
|
|
|
console.error('Vue Devtools failed to install:', e.toString())
|
|
|
}
|
|
|
}
|
|
|
- showLoading(createWindow);
|
|
|
+
|
|
|
+ // showLoading(createWindow);
|
|
|
+ createWindow()
|
|
|
})
|
|
|
}
|
|
|
|