Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
192035ac
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
192035ac
编写于
2月 15, 2022
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
save election logs to file
上级
0ba9f814
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
26 addition
and
25 deletion
+26
-25
client/src/log.js
client/src/log.js
+9
-0
client/src/main.js
client/src/main.js
+3
-2
client/src/services.js
client/src/services.js
+14
-23
未找到文件。
client/src/log.js
0 → 100644
浏览文件 @
192035ac
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
浏览文件 @
192035ac
import
{
app
,
BrowserWindow
}
from
'
electron
'
;
import
{
getUIServerUrl
,
startZtfServer
,
killZtfServer
,
logInfo
,
logErr
}
from
'
./services
'
;
import
{
getUIServerUrl
,
startZtfServer
,
killZtfServer
}
from
'
./services
'
;
import
{
logInfo
,
logErr
}
from
'
./log
'
;
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if
(
require
(
'
electron-squirrel-startup
'
))
{
// eslint-disable-line global-require
...
...
@@ -43,7 +44,7 @@ async function startApp() {
const
url
=
await
getUIServerUrl
();
console
.
log
(
'
>> UI server url is
'
,
url
);
logInfo
(
'
>> UI server url is
'
,
url
);
createWindow
(
url
);
...
...
client/src/services.js
浏览文件 @
192035ac
...
...
@@ -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,12 +183,12 @@ 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
}
".`
);
...
...
@@ -211,13 +212,3 @@ export function getUIServerUrl() {
_uiServerApp
=
cmd
;
});
}
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
);
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录