|
@@ -1,6 +1,6 @@
|
|
'use strict'
|
|
'use strict'
|
|
|
|
|
|
-import { app, protocol, BrowserWindow, Menu, ipcMain } from 'electron'
|
|
|
|
|
|
+import { app, protocol, BrowserWindow, Menu, MenuItem, ipcMain } from 'electron'
|
|
import { createProtocol } from 'vue-cli-plugin-electron-builder/lib'
|
|
import { createProtocol } from 'vue-cli-plugin-electron-builder/lib'
|
|
import installExtension, { VUEJS_DEVTOOLS } from 'electron-devtools-installer'
|
|
import installExtension, { VUEJS_DEVTOOLS } from 'electron-devtools-installer'
|
|
const path = require('path')
|
|
const path = require('path')
|
|
@@ -18,6 +18,7 @@ protocol.registerSchemesAsPrivileged([
|
|
async function createWindow() {
|
|
async function createWindow() {
|
|
// 隐藏菜单栏
|
|
// 隐藏菜单栏
|
|
Menu.setApplicationMenu(null)
|
|
Menu.setApplicationMenu(null)
|
|
|
|
+
|
|
// Create the browser window.
|
|
// Create the browser window.
|
|
win = new BrowserWindow({
|
|
win = new BrowserWindow({
|
|
width: 1200,
|
|
width: 1200,
|
|
@@ -28,24 +29,36 @@ async function createWindow() {
|
|
// Use pluginOptions.nodeIntegration, leave this alone
|
|
// Use pluginOptions.nodeIntegration, leave this alone
|
|
// See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more info
|
|
// See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more info
|
|
nodeIntegration: process.env.ELECTRON_NODE_INTEGRATION,
|
|
nodeIntegration: process.env.ELECTRON_NODE_INTEGRATION,
|
|
- contextIsolation: !process.env.ELECTRON_NODE_INTEGRATION
|
|
|
|
|
|
+ contextIsolation: !process.env.ELECTRON_NODE_INTEGRATION,
|
|
|
|
+ preload: path.join(__dirname, 'preload.js')
|
|
}
|
|
}
|
|
})
|
|
})
|
|
// 检查更新
|
|
// 检查更新
|
|
// updateHandle();
|
|
// updateHandle();
|
|
|
|
|
|
// 修改成加载项目地址
|
|
// 修改成加载项目地址
|
|
- console.log('项目环境:',process.env.NODE_ENV);
|
|
|
|
if (process.env.WEBPACK_DEV_SERVER_URL) {
|
|
if (process.env.WEBPACK_DEV_SERVER_URL) {
|
|
|
|
+ console.log('项目环境:', process.env.NODE_ENV);
|
|
// Load the url of the dev server if in development mode
|
|
// Load the url of the dev server if in development mode
|
|
await win.loadURL(process.env.WEBPACK_DEV_SERVER_URL)
|
|
await win.loadURL(process.env.WEBPACK_DEV_SERVER_URL)
|
|
- if (!process.env.IS_TEST) win.webContents.openDevTools()
|
|
|
|
|
|
+ if (isDevelopment) win.webContents.openDevTools()
|
|
} else {
|
|
} else {
|
|
createProtocol('app')
|
|
createProtocol('app')
|
|
// Load the index.html when not in development
|
|
// Load the index.html when not in development
|
|
- win.loadURL('app://./index.html')
|
|
|
|
|
|
+ // win.loadURL('app://./index.html')
|
|
|
|
+ win.loadURL(process.env.WEBPACK_DEV_SERVER_URL)
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ ipcMain.on('show-context-menu', (event) => {
|
|
|
|
+ const template = [
|
|
|
|
+ { label: '复制', role: 'copy' },
|
|
|
|
+ { label: '粘贴', role: 'paste' },
|
|
|
|
+ { label: '刷新', role: 'reload' },
|
|
|
|
+ { label: '强制刷新', role: 'forceReload' },
|
|
|
|
+ { label: '开发者工具', role: 'toggleDevTools' },
|
|
|
|
+ ]
|
|
|
|
+ const menu = Menu.buildFromTemplate(template)
|
|
|
|
+ menu.popup(BrowserWindow.fromWebContents(event.sender))
|
|
|
|
+ })
|
|
// // 32位 64位
|
|
// // 32位 64位
|
|
// if (process.arch === 'x64') {
|
|
// if (process.arch === 'x64') {
|
|
// uploadUrl = uploadUrl + 'dist_electron';
|
|
// uploadUrl = uploadUrl + 'dist_electron';
|