Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
652a82c1
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,发现更多精彩内容 >>
提交
652a82c1
编写于
2月 15, 2022
作者:
m0_58228130
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/main' into main
上级
0d8029ac
bb0bf410
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
38 addition
and
22 deletion
+38
-22
client/package-lock.json
client/package-lock.json
+8
-3
client/package.json
client/package.json
+1
-0
client/src/log.js
client/src/log.js
+9
-0
client/src/main.js
client/src/main.js
+5
-5
client/src/service.js
client/src/service.js
+15
-14
未找到文件。
client/package-lock.json
浏览文件 @
652a82c1
...
...
@@ -2580,6 +2580,11 @@
}
}
},
"electron-log"
:
{
"version"
:
"4.4.6"
,
"resolved"
:
"https://registry.npmmirror.com/electron-log/-/electron-log-4.4.6.tgz"
,
"integrity"
:
"sha512-nirYgRdY+F+vclr8ijdwy2vW03IzFpDHTaKNWu76dEN21Y76+smcES5knS7cgHUUB0qNLOi8vZO36taakjbSXA=="
},
"electron-notarize"
:
{
"version"
:
"1.1.1"
,
"resolved"
:
"https://registry.npmmirror.com/electron-notarize/-/electron-notarize-1.1.1.tgz"
,
...
...
@@ -2636,7 +2641,7 @@
"dependencies"
:
{
"debug"
:
{
"version"
:
"2.6.9"
,
"resolved"
:
"https://registry.npmmirror.com/debug/
-
/debug-2.6.9.tgz"
,
"resolved"
:
"https://registry.npmmirror.com/debug/
download
/debug-2.6.9.tgz"
,
"integrity"
:
"sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA=="
,
"dev"
:
true
,
"requires"
:
{
...
...
@@ -3565,7 +3570,7 @@
"dependencies"
:
{
"debug"
:
{
"version"
:
"3.2.7"
,
"resolved"
:
"https://registry.npmmirror.com/debug/
-
/debug-3.2.7.tgz"
,
"resolved"
:
"https://registry.npmmirror.com/debug/
download
/debug-3.2.7.tgz"
,
"integrity"
:
"sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ=="
,
"dev"
:
true
,
"requires"
:
{
...
...
@@ -3660,7 +3665,7 @@
"dependencies"
:
{
"debug"
:
{
"version"
:
"2.6.9"
,
"resolved"
:
"https://registry.npmmirror.com/debug/
-
/debug-2.6.9.tgz"
,
"resolved"
:
"https://registry.npmmirror.com/debug/
download
/debug-2.6.9.tgz"
,
"integrity"
:
"sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA=="
,
"dev"
:
true
,
"requires"
:
{
...
...
client/package.json
浏览文件 @
652a82c1
...
...
@@ -39,6 +39,7 @@
"style-loader"
:
"^3.3.1"
},
"dependencies"
:
{
"electron-log"
:
"^4.4.6"
,
"electron-squirrel-startup"
:
"^1.0.0"
}
}
client/src/log.js
0 → 100644
浏览文件 @
652a82c1
const
logger
=
require
(
'
electron-log
'
);
logger
.
transports
.
file
.
resolvePath
=
()
=>
require
(
"
path
"
).
join
(
require
(
"
os
"
).
homedir
(),
'
ztf
'
,
'
log
'
,
'
electron.log
'
);
export
function
logInfo
(
str
)
{
logger
.
info
(
str
);
}
export
function
logErr
(
str
)
{
logger
.
error
(
str
);
}
client/src/main.js
浏览文件 @
652a82c1
import
{
app
,
BrowserWindow
}
from
'
electron
'
;
import
{
getUIServerUrl
,
startZtfServer
,
killZtfServer
}
from
'
./services
'
;
import
{
getUIServerUrl
,
startZtfServer
,
killZtfServer
}
from
'
./service
'
;
import
{
logInfo
,
logErr
}
from
'
./log
'
;
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if
(
require
(
'
electron-squirrel-startup
'
))
{
// eslint-disable-line global-require
...
...
@@ -24,7 +25,6 @@ const createWindow = (url) => {
mainWindow
.
webContents
.
openDevTools
({
mode
:
'
bottom
'
});
};
let
_starting
=
false
;
async
function
startApp
()
{
...
...
@@ -35,16 +35,16 @@ async function startApp() {
try
{
const
ztfServerUrl
=
await
startZtfServer
();
console
.
log
(
`>> ZTF Server started successfully:
${
ztfServerUrl
}
`
);
logInfo
(
`>> ZTF Server started successfully:
${
ztfServerUrl
}
`
);
}
catch
(
error
)
{
console
.
erro
r
(
'
>> Start ztf server failed:
'
+
error
);
logEr
r
(
'
>> Start ztf server failed:
'
+
error
);
process
.
exit
(
1
);
return
;
}
const
url
=
await
getUIServerUrl
();
console
.
log
(
'
>> UI server url is
'
,
url
);
logInfo
(
`>> UI server url is
${
url
}
`
);
createWindow
(
url
);
...
...
client/src/service
s
.js
→
client/src/service.js
浏览文件 @
652a82c1
...
...
@@ -3,6 +3,7 @@ import {spawn} from 'child_process';
import
os
from
'
os
'
;
import
{
app
}
from
'
electron
'
;
import
express
from
'
express
'
;
import
{
logInfo
,
logErr
}
from
'
./log
'
;
const
DEBUG
=
process
.
env
.
NODE_ENV
===
'
development
'
;
...
...
@@ -10,7 +11,7 @@ let _ztfServerProcess;
export
function
startZtfServer
()
{
if
(
process
.
env
.
SKIP_SERVER
)
{
console
.
log
(
`>> Skip to start ZTF Server by env "SKIP_SERVER=
${
process
.
env
.
SKIP_SERVER
}
".`
);
logInfo
(
`>> Skip to start ZTF Server by env "SKIP_SERVER=
${
process
.
env
.
SKIP_SERVER
}
".`
);
return
Promise
.
resolve
();
}
if
(
_ztfServerProcess
)
{
...
...
@@ -29,13 +30,13 @@ export function startZtfServer() {
}
return
new
Promise
((
resolve
,
reject
)
=>
{
const
cwd
=
process
.
env
.
SERVER_CWD_PATH
||
path
.
dirname
(
serverExePath
);
console
.
log
(
`>> Starting ZTF Server from exe path with command "
${
serverExePath
}
-P 8085" in "
${
cwd
}
"...`
);
logInfo
(
`>> Starting ZTF Server from exe path with command "
${
serverExePath
}
-P 8085" in "
${
cwd
}
"...`
);
const
cmd
=
spawn
(
serverExePath
,
[
'
-P
'
,
'
8085
'
],
{
cwd
,
shell
:
true
,
});
cmd
.
on
(
'
close
'
,
(
code
)
=>
{
console
.
log
(
`>> ZTF server closed with code
${
code
}
`
);
logInfo
(
`>> ZTF server closed with code
${
code
}
`
);
_ztfServerProcess
=
null
;
cmd
.
kill
()
});
...
...
@@ -45,7 +46,7 @@ export function startZtfServer() {
for
(
let
i
=
0
;
i
<
lines
.
length
;
i
++
)
{
const
line
=
lines
[
i
];
if
(
DEBUG
)
{
console
.
log
(
'
\t
'
,
line
);
logInfo
(
'
\t
'
+
line
);
}
if
(
line
.
includes
(
'
Now listening on: http
'
))
{
resolve
(
line
.
split
(
'
Now listening on:
'
)[
1
].
trim
());
...
...
@@ -75,13 +76,13 @@ export function startZtfServer() {
return
new
Promise
((
resolve
,
reject
)
=>
{
const
cwd
=
process
.
env
.
SERVER_CWD_PATH
||
path
.
resolve
(
app
.
getAppPath
(),
'
../
'
);
console
.
log
(
`>> Starting ZTF development server from source with command "go run cmd/server/main.go -P 8085" in "
${
cwd
}
"`
);
logInfo
(
`>> Starting ZTF development server from source with command "go run cmd/server/main.go -P 8085" in "
${
cwd
}
"`
);
const
cmd
=
spawn
(
'
go
'
,
[
'
run
'
,
'
main.go
'
,
'
-P
'
,
'
8085
'
],
{
cwd
,
shell
:
true
,
});
cmd
.
on
(
'
close
'
,
(
code
)
=>
{
console
.
log
(
`>> ZTF server closed with code
${
code
}
`
);
logInfo
(
`>> ZTF server closed with code
${
code
}
`
);
_ztfServerProcess
=
null
;
});
cmd
.
stdout
.
on
(
'
data
'
,
data
=>
{
...
...
@@ -90,7 +91,7 @@ export function startZtfServer() {
for
(
let
i
=
0
;
i
<
lines
.
length
;
i
++
)
{
const
line
=
lines
[
i
];
if
(
DEBUG
)
{
console
.
log
(
'
\t
'
,
line
);
logInfo
(
'
\t
'
+
line
);
}
if
(
line
.
includes
(
'
Now listening on: http
'
))
{
resolve
(
line
.
split
(
'
Now listening on:
'
)[
1
].
trim
());
...
...
@@ -139,7 +140,7 @@ export function getUIServerUrl() {
}
const
port
=
process
.
env
.
UI_SERVER_PORT
||
8000
;
console
.
log
(
`>> Starting UI serer at
${
uiServerUrl
}
with port
${
port
}
`
);
logInfo
(
`>> Starting UI serer at
${
uiServerUrl
}
with port
${
port
}
`
);
const
uiServer
=
express
();
uiServer
.
use
(
express
.
static
(
uiServerUrl
));
...
...
@@ -149,7 +150,7 @@ export function getUIServerUrl() {
_uiServerApp
=
null
;
reject
(
serverError
);
}
else
{
console
.
log
(
`>> UI server started successfully on http://localhost:
${
port
}
.`
);
logInfo
(
`>> UI server started successfully on http://localhost:
${
port
}
.`
);
resolve
(
`http://localhost:
${
port
}
`
);
}
});
...
...
@@ -162,7 +163,7 @@ export function getUIServerUrl() {
return
new
Promise
((
resolve
,
reject
)
=>
{
const
cwd
=
path
.
resolve
(
app
.
getAppPath
(),
'
../ui
'
);
console
.
log
(
`>> Starting UI development server with command "npm run serve" in "
${
cwd
}
"...`
);
logInfo
(
`>> Starting UI development server with command "npm run serve" in "
${
cwd
}
"...`
);
let
resolved
=
false
;
const
cmd
=
spawn
(
'
npm
'
,
[
'
run
'
,
'
serve
'
],
{
...
...
@@ -170,7 +171,7 @@ export function getUIServerUrl() {
shell
:
true
,
});
cmd
.
on
(
'
close
'
,
(
code
)
=>
{
console
.
log
(
`>> ZTF server closed with code
${
code
}
`
);
logInfo
(
`>> ZTF server closed with code
${
code
}
`
);
_uiServerApp
=
null
;
});
cmd
.
stdout
.
on
(
'
data
'
,
data
=>
{
...
...
@@ -182,15 +183,15 @@ export function getUIServerUrl() {
for
(
let
i
=
0
;
i
<
lines
.
length
;
i
++
)
{
const
line
=
lines
[
i
];
if
(
DEBUG
)
{
console
.
log
(
'
\t
'
,
line
);
logInfo
(
'
\t
'
+
line
);
}
if
(
line
.
includes
(
'
App running at:
'
))
{
const
nextLine
=
lines
[
i
+
1
]
||
lines
[
i
+
2
];
if
(
DEBUG
)
{
console
.
log
(
'
\t
'
,
nextLine
);
logInfo
(
'
\t
'
+
nextLine
);
}
if
(
!
nextLine
)
{
console
.
error
(
'
\t
'
,
`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
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录