Skip to content

Commit 1c52194

Browse files
committed
1.升级electron版本,2.修改基础配置
1 parent 2cbebf9 commit 1c52194

File tree

6 files changed

+1513
-1867
lines changed

6 files changed

+1513
-1867
lines changed

package.json

+22-21
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,34 @@
1414
},
1515
"main": "background.js",
1616
"dependencies": {
17-
"axios": "^0.19.0",
18-
"core-js": "^3.6.4",
17+
"axios": "^0.19.2",
18+
"core-js": "^3.6.5",
1919
"cross-env": "^7.0.2",
2020
"element-ui": "^2.13.0",
21-
"fs-extra": "^9.0.0",
2221
"vue": "^2.6.11",
23-
"vue-router": "^3.1.5",
24-
"vuex": "^3.1.2"
22+
"vue-router": "^3.2.0",
23+
"vuex": "^3.4.0"
2524
},
2625
"devDependencies": {
27-
"@vue/cli-plugin-babel": "^4.1.0",
28-
"@vue/cli-plugin-eslint": "^4.1.0",
29-
"@vue/cli-plugin-router": "^4.1.0",
30-
"@vue/cli-plugin-vuex": "^4.1.0",
31-
"@vue/cli-service": "^4.1.0",
32-
"@vue/eslint-config-prettier": "^5.0.0",
33-
"babel-eslint": "^10.0.3",
26+
"@vue/cli-plugin-babel": "~4.4.0",
27+
"@vue/cli-plugin-eslint": "~4.4.0",
28+
"@vue/cli-plugin-router": "~4.4.0",
29+
"@vue/cli-plugin-vuex": "~4.4.0",
30+
"@vue/cli-service": "~4.4.0",
31+
"@vue/eslint-config-prettier": "^6.0.0",
32+
"babel-eslint": "^10.1.0",
3433
"copy-webpack-plugin": "^5.0.3",
35-
"electron": "^6.0.0",
36-
"eslint": "^5.16.0",
37-
"eslint-plugin-prettier": "^3.1.1",
38-
"eslint-plugin-vue": "^5.0.0",
34+
"electron": "^9.0.0",
35+
"electron-devtools-installer": "^3.1.0",
36+
"eslint": "^6.7.2",
37+
"eslint-plugin-prettier": "^3.1.3",
38+
"eslint-plugin-vue": "^6.2.2",
3939
"prettier": "^1.19.1",
40-
"sass": "^1.23.7",
41-
"sass-loader": "^8.0.0",
42-
"svg-sprite-loader": "^4.1.6",
43-
"vue-cli-plugin-electron-builder": "^1.4.6",
44-
"vue-template-compiler": "^2.6.10"
40+
"sass": "^1.26.10",
41+
"sass-loader": "^9.0.1",
42+
"svg-sprite-loader": "^5.0.0",
43+
"url-loader": "^4.1.0",
44+
"vue-cli-plugin-electron-builder": "~2.0.0-rc.4",
45+
"vue-template-compiler": "^2.6.11"
4546
}
4647
}

public/assets/images/logo.png

6.69 KB
Loading

src/background.js

+11-19
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
'use strict'
22

3-
import { app, protocol, BrowserWindow, Menu } from 'electron'
4-
import {
5-
createProtocol
6-
/* installVueDevtools */
7-
} from 'vue-cli-plugin-electron-builder/lib'
3+
import { app, protocol, BrowserWindow } from 'electron'
4+
import { createProtocol } from 'vue-cli-plugin-electron-builder/lib'
5+
import installExtension, { VUEJS_DEVTOOLS } from 'electron-devtools-installer'
86
const isDevelopment = process.env.NODE_ENV !== 'production'
97

108
// Keep a global reference of the window object, if you don't, the window will
@@ -17,15 +15,14 @@ protocol.registerSchemesAsPrivileged([
1715
])
1816

1917
function createWindow() {
20-
// hide Menu
21-
Menu.setApplicationMenu(null)
22-
2318
// Create the browser window.
2419
win = new BrowserWindow({
2520
width: 800,
2621
height: 600,
2722
webPreferences: {
28-
nodeIntegration: true
23+
// Use pluginOptions.nodeIntegration, leave this alone
24+
// See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more info
25+
nodeIntegration: process.env.ELECTRON_NODE_INTEGRATION
2926
}
3027
})
3128

@@ -67,16 +64,11 @@ app.on('activate', () => {
6764
app.on('ready', async () => {
6865
if (isDevelopment && !process.env.IS_TEST) {
6966
// Install Vue Devtools
70-
// Devtools extensions are broken in Electron 6.0.0 and greater
71-
// See https://github.com/nklayman/vue-cli-plugin-electron-builder/issues/378 for more info
72-
// Electron will not launch with Devtools extensions installed on Windows 10 with dark mode
73-
// If you are not using Windows 10 dark mode, you may uncomment these lines
74-
// In addition, if the linked issue is closed, you can upgrade electron and uncomment these lines
75-
// try {
76-
// await installVueDevtools()
77-
// } catch (e) {
78-
// console.error('Vue Devtools failed to install:', e.toString())
79-
// }
67+
try {
68+
await installExtension(VUEJS_DEVTOOLS)
69+
} catch (e) {
70+
console.error('Vue Devtools failed to install:', e.toString())
71+
}
8072
}
8173
createWindow()
8274
})

src/views/index.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="index">
3-
<img alt="Vue logo" src="../assets/logo.png" />
3+
<img alt="Vue logo" src="assets/images/logo.png" />
44
<HelloWorld msg="Welcome to Your Vue.js App" />
55
</div>
66
</template>

vue.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @Author: Caven
33
* @Date: 2018-12-15 00:33:19
44
* @Last Modified by: Caven
5-
* @Last Modified time: 2020-06-19 16:13:33
5+
* @Last Modified time: 2020-07-08 13:19:22
66
*/
77
'use strict'
88
const path = require('path')
@@ -60,6 +60,7 @@ module.exports = {
6060
},
6161
pluginOptions: {
6262
electronBuilder: {
63+
nodeIntegration: true,
6364
chainWebpackMainProcess: config => {},
6465
chainWebpackRendererProcess: config => {
6566
config.plugin('define').tap(args => {

0 commit comments

Comments
 (0)