Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
3bce7dc3
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
12 个月 前同步成功
通知
11
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
3
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zentaoatf
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
3
Issue
3
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3bce7dc3
编写于
1月 07, 2022
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/main'
# Conflicts: # client/src/services.js
上级
cf6791fd
611f1157
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
54 addition
and
26 deletion
+54
-26
client/src/services.js
client/src/services.js
+54
-26
未找到文件。
client/src/services.js
浏览文件 @
3bce7dc3
...
...
@@ -4,6 +4,8 @@ import os from 'os';
import
{
app
}
from
'
electron
'
;
import
express
from
'
express
'
;
const
DEBUG
=
process
.
env
.
NODE_ENV
===
'
development
'
;
let
_ztfServerProcess
;
export
function
startZtfServer
()
{
...
...
@@ -16,7 +18,7 @@ export function startZtfServer() {
}
let
{
SERVER_EXE_PATH
:
serverExePath
}
=
process
.
env
;
if
(
!
serverExePath
&&
process
.
env
.
NODE_ENV
!==
'
development
'
)
{
if
(
!
serverExePath
&&
!
DEBUG
)
{
const
platform
=
os
.
platform
();
// 'darwin', 'linux', 'win32'
const
exePath
=
`bin/
${
platform
}
/ztf
${
platform
===
'
win32
'
?
'
.exe
'
:
''
}
`
;
serverExePath
=
path
.
resolve
(
process
.
resourcesPath
,
exePath
);
...
...
@@ -25,30 +27,39 @@ export function startZtfServer() {
if
(
!
path
.
isAbsolute
(
serverExePath
))
{
serverExePath
=
path
.
resolve
(
app
.
getAppPath
(),
serverExePath
);
}
return
new
Promise
((
resolve
)
=>
{
console
.
log
(
`>> Starting ZTF Server
with exe path
${
serverExePath
}
`
);
return
new
Promise
((
resolve
,
reject
)
=>
{
console
.
log
(
`>> Starting ZTF Server
from exe path with command "
${
serverExePath
}
-P 8085"...
`
);
const
cmd
=
spawn
(
serverExePath
,
[
'
-P
'
,
'
8085
'
],
{
cwd
:
path
.
dirname
(
serverExePath
),
shell
:
true
,
});
cmd
.
on
(
'
close
'
,
()
=>
{
cmd
=
null
;
cmd
.
on
(
'
close
'
,
(
code
)
=>
{
console
.
log
(
`>> ZTF server closed with code
${
code
}
`
);
_ztfServerProcess
=
null
;
});
cmd
.
stdout
.
on
(
'
data
'
,
data
=>
{
const
dataString
=
String
(
data
);
const
lines
=
dataString
.
split
(
'
\n
'
);
for
(
let
i
=
0
;
i
<
lines
.
length
;
i
++
)
{
const
line
=
lines
[
i
];
console
.
log
(
'
\t
>
'
,
line
);
if
(
DEBUG
)
{
console
.
log
(
'
\t
'
,
line
);
}
if
(
line
.
includes
(
'
Now listening on: http
'
))
{
resolve
(
line
.
split
(
'
Now listening on:
'
)[
1
].
trim
());
break
;
if
(
!
DEBUG
)
{
break
;
}
}
else
if
(
line
.
includes
(
'
启动HTTP服务于
'
))
{
resolve
(
line
.
split
(
/启动HTTP服务于|,/
)[
1
].
trim
());
break
;
if
(
!
DEBUG
)
{
break
;
}
}
else
if
(
line
.
startsWith
(
'
[ERRO]
'
))
{
reject
(
new
Error
(
`Start ztf server failed with error:
${
line
.
substring
(
'
[ERRO]
'
.
length
)}
`
));
break
;
if
(
!
DEBUG
)
{
break
;
}
}
}
});
...
...
@@ -61,12 +72,13 @@ export function startZtfServer() {
}
return
new
Promise
((
resolve
,
reject
)
=>
{
console
.
log
(
'
>> Starting ZTF development server...
'
);
console
.
log
(
`>> Starting ZTF development server from source with command "go run main.go -P 8085"`
);
const
cmd
=
spawn
(
'
go
'
,
[
'
run
'
,
'
main.go
'
,
'
-P
'
,
'
8085
'
],
{
cwd
:
path
.
resolve
(
app
.
getAppPath
(),
'
../cmd/server
'
),
shell
:
true
,
});
cmd
.
on
(
'
close
'
,
()
=>
{
cmd
.
on
(
'
close
'
,
(
code
)
=>
{
console
.
log
(
`>> ZTF server closed with code
${
code
}
`
);
_ztfServerProcess
=
null
;
});
cmd
.
stdout
.
on
(
'
data
'
,
data
=>
{
...
...
@@ -74,13 +86,19 @@ export function startZtfServer() {
const
lines
=
dataString
.
split
(
'
\n
'
);
for
(
let
i
=
0
;
i
<
lines
.
length
;
i
++
)
{
const
line
=
lines
[
i
];
console
.
log
(
'
\t
>
'
,
line
);
if
(
DEBUG
)
{
console
.
log
(
'
\t
'
,
line
);
}
if
(
line
.
includes
(
'
Now listening on: http
'
))
{
resolve
(
line
.
split
(
'
Now listening on:
'
)[
1
].
trim
());
break
;
if
(
!
DEBUG
)
{
break
;
}
}
else
if
(
line
.
startsWith
(
'
[ERRO]
'
))
{
reject
(
new
Error
(
`Start ztf server failed with error:
${
line
.
substring
(
'
[ERRO]
'
.
length
)}
`
));
break
;
if
(
!
DEBUG
)
{
break
;
}
}
}
});
...
...
@@ -100,7 +118,7 @@ export function getUIServerUrl() {
}
let
{
UI_SERVER_URL
:
uiServerUrl
}
=
process
.
env
;
if
(
!
uiServerUrl
&&
process
.
env
.
NODE_ENV
!==
'
development
'
)
{
if
(
!
uiServerUrl
&&
!
DEBUG
)
{
uiServerUrl
=
path
.
resolve
(
process
.
resourcesPath
,
'
ui
'
);
}
...
...
@@ -113,19 +131,19 @@ export function getUIServerUrl() {
uiServerUrl
=
path
.
resolve
(
app
.
getAppPath
(),
uiServerUrl
);
}
console
.
log
(
`>> Starting UI serer at
${
uiServerUrl
}
`
);
const
port
=
process
.
env
.
UI_SERVER_PORT
||
8000
;
console
.
log
(
`>> Starting UI serer at
${
uiServerUrl
}
with port
${
port
}
`
);
const
uiServer
=
express
();
uiServer
.
use
(
express
.
static
(
uiServerUrl
));
const
server
=
uiServer
.
listen
(
p
rocess
.
env
.
UI_SERVER_PORT
||
8000
,
serverError
=>
{
const
server
=
uiServer
.
listen
(
p
ort
,
serverError
=>
{
if
(
serverError
)
{
console
.
error
(
'
>>> Start ui server failed with error
'
,
serverError
);
_uiServerApp
=
null
;
reject
(
serverError
);
}
else
{
const
address
=
server
.
address
();
console
.
log
(
`>> UI server started successfully on http://localhost:
${
address
.
port
}
.`
);
resolve
(
`http://localhost:
${
address
.
port
}
`
);
console
.
log
(
`>> UI server started successfully on http://localhost:
${
port
}
.`
);
resolve
(
`http://localhost:
${
port
}
`
);
}
});
server
.
on
(
'
close
'
,
()
=>
{
...
...
@@ -136,14 +154,16 @@ export function getUIServerUrl() {
}
return
new
Promise
((
resolve
,
reject
)
=>
{
console
.
log
(
'
>> Starting UI development serve...
'
);
const
cwd
=
path
.
resolve
(
app
.
getAppPath
(),
'
../ui
'
);
console
.
log
(
`>> Starting UI development server with command "npm run serve" in "
${
cwd
}
"...`
);
let
resolved
=
false
;
const
cmd
=
spawn
(
'
npm
'
,
[
'
run
'
,
'
serve
'
],
{
cwd
:
path
.
resolve
(
app
.
getAppPath
(),
'
../ui
'
)
,
cwd
,
shell
:
true
,
});
cmd
.
on
(
'
close
'
,
()
=>
{
cmd
.
on
(
'
close
'
,
(
code
)
=>
{
console
.
log
(
`>> ZTF server closed with code
${
code
}
`
);
_uiServerApp
=
null
;
});
cmd
.
stdout
.
on
(
'
data
'
,
data
=>
{
...
...
@@ -154,18 +174,26 @@ export function getUIServerUrl() {
const
lines
=
dataString
.
split
(
'
\n
'
);
for
(
let
i
=
0
;
i
<
lines
.
length
;
i
++
)
{
const
line
=
lines
[
i
];
console
.
log
(
'
\t
>
'
,
line
);
if
(
DEBUG
)
{
console
.
log
(
'
\t
'
,
line
);
}
if
(
line
.
includes
(
'
App running at:
'
))
{
const
nextLine
=
lines
[
i
+
1
]
||
lines
[
i
+
2
];
if
(
DEBUG
)
{
console
.
log
(
'
\t
'
,
nextLine
);
}
if
(
!
nextLine
)
{
throw
new
Error
(
`Cannot grabing running address after line "
${
line
}
".`
)
console
.
error
(
'
\t
'
,
`Cannot grabing running address after line "
${
line
}
".`
);
throw
new
Error
(
`Cannot grabing running address after line "
${
line
}
".`
);
}
const
url
=
nextLine
.
split
(
'
Local:
'
)[
1
];
if
(
url
)
{
resolved
=
true
;
resolve
(
url
);
}
break
;
if
(
!
DEBUG
)
{
break
;
}
}
}
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录