ee-core 2.5.0-beta.2 → 2.5.0-beta.3

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/ee/eeApp.js CHANGED
@@ -15,6 +15,7 @@ const Ps = require('../ps');
15
15
  const Socket = require('../socket');
16
16
  const GetPort = require('../utils/get-port');
17
17
  const UtilsHelper = require('../utils/helper');
18
+ const HttpClient = require('../httpclient');
18
19
 
19
20
  class EeApp extends BaseApp {
20
21
  constructor(options = {}) {
@@ -91,7 +92,7 @@ class EeApp extends BaseApp {
91
92
  /**
92
93
  * 应用类型 (远程、html、单页应用)
93
94
  */
94
- selectAppType() {
95
+ async selectAppType() {
95
96
  let type = '';
96
97
  let url = '';
97
98
 
@@ -129,6 +130,36 @@ class EeApp extends BaseApp {
129
130
  load = 'file';
130
131
  }
131
132
 
133
+ // 检查 UI serve是否启动,先加载一个boot page
134
+ if (load == 'url') {
135
+ const bootPage = path.join(__dirname, '..', 'html', 'boot.html');
136
+ this.mainWindow.loadFile(bootPage);
137
+ let count = 0;
138
+ let frontendReady = false;
139
+ const hc = new HttpClient();
140
+ while(!frontendReady && count < 30){
141
+ await UtilsHelper.sleep(1 * 1000);
142
+ try {
143
+ await hc.request(url, {
144
+ method: 'GET',
145
+ timeout: 1000,
146
+ });
147
+ frontendReady = true;
148
+ } catch(err) {
149
+ // console.log('The frontend service is starting');
150
+ }
151
+
152
+ count++;
153
+ }
154
+
155
+ if (frontendReady == false) {
156
+ const bootFailurePage = path.join(__dirname, '..', 'html', 'failure.html');
157
+ this.mainWindow.loadFile(bootFailurePage);
158
+ Log.coreLogger.error(`[ee-core] Please check the ${url} !`);
159
+ return;
160
+ }
161
+ }
162
+
132
163
  this.loadMainUrl('spa', url, load);
133
164
  return;
134
165
  }
package/html/boot.html ADDED
@@ -0,0 +1,97 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1.0, minimum-scale=1.0" />
7
+ <style>
8
+ #loadingPage {
9
+ background-color: #dedede;
10
+ font-size: 12px;
11
+ }
12
+ .base {
13
+ left: 45%;
14
+ position: absolute;
15
+ top: 40%;
16
+ }
17
+ .desc {
18
+ margin: 0, 0, 20px, 0;
19
+ }
20
+ .loading,
21
+ .loading > div {
22
+ position: relative;
23
+ box-sizing: border-box;
24
+ }
25
+ .loading {
26
+ display: block;
27
+ font-size: 0;
28
+ color: #06b359;
29
+ }
30
+ .loading.la-dark {
31
+ color: #07C160;
32
+ }
33
+ .loading > div {
34
+ display: inline-block;
35
+ float: none;
36
+ background-color: currentColor;
37
+ border: 0 solid currentColor;
38
+ }
39
+ .loading {
40
+ width: 92px;
41
+ height: 92px;
42
+ }
43
+ .loading > div {
44
+ position: absolute;
45
+ top: 50%;
46
+ left: 50%;
47
+ background: transparent;
48
+ border-style: solid;
49
+ border-width: 2px;
50
+ border-radius: 100%;
51
+ animation: ball-clip-rotate-multiple-rotate 1s ease-in-out infinite;
52
+ }
53
+ .loading > div:first-child {
54
+ position: absolute;
55
+ width: 92px;
56
+ height: 92px;
57
+ border-right-color: transparent;
58
+ border-left-color: transparent;
59
+ }
60
+ .loading > div:last-child {
61
+ width: 16px;
62
+ height: 16px;
63
+ border-top-color: transparent;
64
+ border-bottom-color: transparent;
65
+ animation-duration: 0.5s;
66
+ animation-direction: reverse;
67
+ }
68
+ @keyframes ball-clip-rotate-multiple-rotate {
69
+ 0% {
70
+ transform: translate(-50%, -50%) rotate(0deg);
71
+ }
72
+
73
+ 50% {
74
+ transform: translate(-50%, -50%) rotate(180deg);
75
+ }
76
+
77
+ 100% {
78
+ transform: translate(-50%, -50%) rotate(360deg);
79
+ }
80
+ }
81
+ </style>
82
+ </head>
83
+ <body>
84
+ <div id="boot">
85
+ <div class='base'>
86
+ <!-- Booting the frontend service ... -->
87
+ <!-- <div class='desc'>
88
+ Booting frontend
89
+ </div> -->
90
+ <div class="loading">
91
+ <div></div>
92
+ <div></div>
93
+ </div>
94
+ </div>
95
+ </div>
96
+ </body>
97
+ </html>
@@ -0,0 +1,28 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1.0, minimum-scale=1.0" />
7
+ <title>Booting failure</title>
8
+ <style>
9
+ #failure {
10
+ background-color: #dedede;
11
+ font-size: 14px;
12
+ }
13
+ .base {
14
+ position: absolute;
15
+ top: 50%;
16
+ left: 50%;
17
+ transform: translate(-50%, -50%);
18
+ }
19
+ </style>
20
+ </head>
21
+ <body>
22
+ <div id="failure">
23
+ <div class='base'>
24
+ Booting failure, please check frontend serve is runing !
25
+ </div>
26
+ </div>
27
+ </body>
28
+ </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ee-core",
3
- "version": "2.5.0-beta.2",
3
+ "version": "2.5.0-beta.3",
4
4
  "description": "ee core",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/utils/helper.js CHANGED
@@ -169,3 +169,7 @@ exports.loadConfig = function(prop) {
169
169
 
170
170
  return ret || {};
171
171
  };
172
+
173
+ exports.sleep = function(ms) {
174
+ return new Promise(resolve => setTimeout(resolve, ms));
175
+ };