张恒

小幅度修改小毛病

...@@ -17,10 +17,6 @@ const menu = [ ...@@ -17,10 +17,6 @@ const menu = [
17 }, { 17 }, {
18 label: '帮助', 18 label: '帮助',
19 submenu: [{ 19 submenu: [{
20 - label: '切换到开发者模式',
21 - accelerator: 'CmdOrCtrl+I',
22 - role: 'toggledevtools'
23 - }, {
24 label: '关于', 20 label: '关于',
25 role: 'about', 21 role: 'about',
26 click: function () { 22 click: function () {
......
...@@ -2,20 +2,10 @@ ...@@ -2,20 +2,10 @@
2 2
3 import { app } from 'electron' 3 import { app } from 'electron'
4 import initWindow from './services/windowManager' 4 import initWindow from './services/windowManager'
5 -import path from 'path'
6 import DisableButton from './config/DisableButton' 5 import DisableButton from './config/DisableButton'
7 -/**
8 - * Set `__static` path to static files in production
9 - * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
10 - */
11 -if (process.env.NODE_ENV !== 'development') {
12 - global.__static = path.join(__dirname, '/static').replace(/\\/g, '\\\\')
13 -}
14 -
15 -const loadingURL = process.env.NODE_ENV === 'development' ? 'http://localhost:9080/static/loader.html' : `file://${__static}/loader.html`
16 6
17 function onAppReady () { 7 function onAppReady () {
18 - initWindow(loadingURL) 8 + initWindow()
19 DisableButton.Disablef12() 9 DisableButton.Disablef12()
20 } 10 }
21 11
......
...@@ -4,8 +4,18 @@ import config from '@config' ...@@ -4,8 +4,18 @@ import config from '@config'
4 import setIpc from './ipcMain' 4 import setIpc from './ipcMain'
5 import electronDevtoolsInstaller, { VUEJS_DEVTOOLS } from 'electron-devtools-installer' 5 import electronDevtoolsInstaller, { VUEJS_DEVTOOLS } from 'electron-devtools-installer'
6 import upload from './checkupdate' 6 import upload from './checkupdate'
7 - 7 +import path from 'path'
8 +/**
9 + * Set `__static` path to static files in production
10 + * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
11 + */
12 +// 这个瓜皮全局变量只能在单个js中生效,而并不是整个主进程中
13 +if (process.env.NODE_ENV !== 'development') {
14 + global.__static = path.join(__dirname, '/static').replace(/\\/g, '\\\\')
15 +}
16 +// 将文件地址挪到这里
8 const winURL = process.env.NODE_ENV === 'development' ? 'http://localhost:9080' : `file://${__dirname}/index.html` 17 const winURL = process.env.NODE_ENV === 'development' ? 'http://localhost:9080' : `file://${__dirname}/index.html`
18 +const loadingURL = process.env.NODE_ENV === 'development' ? 'http://localhost:9080/static/loader.html' : `file://${__static}/loader.html`
9 var loadWindow = null 19 var loadWindow = null
10 var mainWindow = null 20 var mainWindow = null
11 21
...@@ -30,7 +40,18 @@ function createMainWindow () { ...@@ -30,7 +40,18 @@ function createMainWindow () {
30 scrollBounce: process.platform === 'darwin' 40 scrollBounce: process.platform === 'darwin'
31 } 41 }
32 }) 42 })
33 - 43 + // 这里设置只有开发环境才注入显示开发者模式
44 + if (process.env.NODE_ENV === 'development') {
45 + menuconfig.push({
46 + label: '开发者设置',
47 + submenu: [{
48 + label: '切换到开发者模式',
49 + accelerator: 'CmdOrCtrl+I',
50 + role: 'toggledevtools'
51 + }]
52 + })
53 + }
54 + // 载入菜单
34 const menu = Menu.buildFromTemplate(menuconfig) 55 const menu = Menu.buildFromTemplate(menuconfig)
35 Menu.setApplicationMenu(menu) 56 Menu.setApplicationMenu(menu)
36 mainWindow.loadURL(winURL) 57 mainWindow.loadURL(winURL)
...@@ -58,7 +79,7 @@ function createMainWindow () { ...@@ -58,7 +79,7 @@ function createMainWindow () {
58 }) 79 })
59 } 80 }
60 81
61 -function loadindWindow (loadingURL) { 82 +function loadindWindow () {
62 loadWindow = new BrowserWindow({ 83 loadWindow = new BrowserWindow({
63 width: 400, 84 width: 400,
64 height: 600, 85 height: 600,
...@@ -77,9 +98,9 @@ function loadindWindow (loadingURL) { ...@@ -77,9 +98,9 @@ function loadindWindow (loadingURL) {
77 }, 2000) 98 }, 2000)
78 } 99 }
79 100
80 -function initWindow (loadingURL) { 101 +function initWindow () {
81 if (config.UseStartupChart) { 102 if (config.UseStartupChart) {
82 - return loadindWindow(loadingURL) 103 + return loadindWindow()
83 } else { 104 } else {
84 return createMainWindow() 105 return createMainWindow()
85 } 106 }
......