ee-core 1.2.4 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/config.default.js +10 -0
- package/lib/eeApp.js +17 -22
- package/package.json +1 -1
- package/utils/common.js +30 -0
- package/utils/index.js +30 -0
package/config/config.default.js
CHANGED
package/lib/eeApp.js
CHANGED
|
@@ -5,6 +5,7 @@ const BaseApp = require('./baseApp');
|
|
|
5
5
|
const is = require('is-type-of');
|
|
6
6
|
const Koa = require('koa');
|
|
7
7
|
const koaServe = require('koa-static');
|
|
8
|
+
const utilsCommon = require('../utils/common');
|
|
8
9
|
|
|
9
10
|
class EeApp extends BaseApp {
|
|
10
11
|
constructor(options = {}) {
|
|
@@ -84,6 +85,11 @@ class EeApp extends BaseApp {
|
|
|
84
85
|
app.on('before-quit', () => {
|
|
85
86
|
self.electron.extra.closeWindow = true;
|
|
86
87
|
})
|
|
88
|
+
|
|
89
|
+
if (this.config.hardGpu == false) {
|
|
90
|
+
app.disableHardwareAcceleration();
|
|
91
|
+
}
|
|
92
|
+
|
|
87
93
|
await this.electronAppReady();
|
|
88
94
|
}
|
|
89
95
|
|
|
@@ -93,6 +99,12 @@ class EeApp extends BaseApp {
|
|
|
93
99
|
async createWindow () {
|
|
94
100
|
const winOptions = this.config.windowsOption;
|
|
95
101
|
this.electron.mainWindow = new BrowserWindow(winOptions);
|
|
102
|
+
let win = this.electron.mainWindow;
|
|
103
|
+
if (winOptions.show === false) {
|
|
104
|
+
win.once('ready-to-show', () => {
|
|
105
|
+
win.show();
|
|
106
|
+
})
|
|
107
|
+
}
|
|
96
108
|
|
|
97
109
|
// 菜单显示/隐藏
|
|
98
110
|
if (this.config.openAppMenu === 'dev-show'
|
|
@@ -114,7 +126,7 @@ class EeApp extends BaseApp {
|
|
|
114
126
|
|
|
115
127
|
// DevTools
|
|
116
128
|
if (!app.isPackaged && this.config.openDevTools) {
|
|
117
|
-
|
|
129
|
+
win.webContents.openDevTools();
|
|
118
130
|
}
|
|
119
131
|
}
|
|
120
132
|
|
|
@@ -142,10 +154,13 @@ class EeApp extends BaseApp {
|
|
|
142
154
|
* 加载loading页面
|
|
143
155
|
*/
|
|
144
156
|
loadingView (winOptions) {
|
|
157
|
+
let currentV = process.versions.electron;
|
|
158
|
+
if (utilsCommon.compareVersion(currentV, '12.2.3') == 1) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
145
161
|
if (!this.config.loadingPage) {
|
|
146
162
|
return;
|
|
147
163
|
}
|
|
148
|
-
|
|
149
164
|
const self = this;
|
|
150
165
|
const loadingBrowserView = new BrowserView();
|
|
151
166
|
this.electron.mainWindow.setBrowserView(loadingBrowserView);
|
|
@@ -237,31 +252,11 @@ class EeApp extends BaseApp {
|
|
|
237
252
|
this.electron.mainWindow.loadURL(url);
|
|
238
253
|
}
|
|
239
254
|
|
|
240
|
-
/**
|
|
241
|
-
* 限制一个窗口
|
|
242
|
-
*/
|
|
243
|
-
// async limitOneWindow () {
|
|
244
|
-
// const gotTheLock = app.requestSingleInstanceLock();
|
|
245
|
-
// if (!gotTheLock) {
|
|
246
|
-
// await this.appQuit();
|
|
247
|
-
// }
|
|
248
|
-
// }
|
|
249
|
-
|
|
250
255
|
/**
|
|
251
256
|
* electron app退出
|
|
252
257
|
*/
|
|
253
258
|
async appQuit () {
|
|
254
259
|
await this.beforeClose();
|
|
255
|
-
|
|
256
|
-
// 窗口销毁
|
|
257
|
-
//this.electron.mainWindow.close();
|
|
258
|
-
|
|
259
|
-
//console.log('Exit now!');
|
|
260
|
-
// 托盘销毁
|
|
261
|
-
// if (this.electron.tray) {
|
|
262
|
-
// console.log('ssssssssssss');
|
|
263
|
-
// this.electron.tray.destroy();
|
|
264
|
-
// }
|
|
265
260
|
|
|
266
261
|
app.quit();
|
|
267
262
|
}
|
package/package.json
CHANGED
package/utils/common.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* 版本号比较
|
|
4
|
+
*/
|
|
5
|
+
exports.compareVersion = function (v1, v2) {
|
|
6
|
+
v1 = v1.split('.')
|
|
7
|
+
v2 = v2.split('.')
|
|
8
|
+
const len = Math.max(v1.length, v2.length)
|
|
9
|
+
|
|
10
|
+
while (v1.length < len) {
|
|
11
|
+
v1.push('0')
|
|
12
|
+
}
|
|
13
|
+
while (v2.length < len) {
|
|
14
|
+
v2.push('0')
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
for (let i = 0; i < len; i++) {
|
|
18
|
+
const num1 = parseInt(v1[i])
|
|
19
|
+
const num2 = parseInt(v2[i])
|
|
20
|
+
|
|
21
|
+
if (num1 > num2) {
|
|
22
|
+
return 1
|
|
23
|
+
} else if (num1 < num2) {
|
|
24
|
+
return -1
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return 0
|
|
29
|
+
}
|
|
30
|
+
|
package/utils/index.js
CHANGED
|
@@ -170,3 +170,33 @@ exports.callFn = async function (fn, args, ctx) {
|
|
|
170
170
|
exports.middleware = function (fn) {
|
|
171
171
|
return is.generatorFunction(fn) ? convert(fn) : fn;
|
|
172
172
|
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 版本号比较
|
|
176
|
+
*/
|
|
177
|
+
exports.compareVersion = function (v1, v2) {
|
|
178
|
+
v1 = v1.split('.')
|
|
179
|
+
v2 = v2.split('.')
|
|
180
|
+
const len = Math.max(v1.length, v2.length)
|
|
181
|
+
|
|
182
|
+
while (v1.length < len) {
|
|
183
|
+
v1.push('0')
|
|
184
|
+
}
|
|
185
|
+
while (v2.length < len) {
|
|
186
|
+
v2.push('0')
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
for (let i = 0; i < len; i++) {
|
|
190
|
+
const num1 = parseInt(v1[i])
|
|
191
|
+
const num2 = parseInt(v2[i])
|
|
192
|
+
|
|
193
|
+
if (num1 > num2) {
|
|
194
|
+
return 1
|
|
195
|
+
} else if (num1 < num2) {
|
|
196
|
+
return -1
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return 0
|
|
201
|
+
}
|
|
202
|
+
|