Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
072cb029
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
10 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
提交
072cb029
编写于
1月 05, 2022
作者:
H
Hao Sun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
* make package script work.
上级
14a04389
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
85 addition
and
29 deletion
+85
-29
client/.gitignore
client/.gitignore
+6
-0
client/README.md
client/README.md
+8
-1
client/forge.config.js
client/forge.config.js
+26
-21
client/src/main.js
client/src/main.js
+0
-2
client/src/services.js
client/src/services.js
+45
-5
未找到文件。
client/.gitignore
浏览文件 @
072cb029
...
...
@@ -87,3 +87,9 @@ typings/
# Electron-Forge
out/
# ZTF binary
bin/
# ZTF UI
ui/
client/README.md
浏览文件 @
072cb029
...
...
@@ -46,7 +46,7 @@ UI_SERVER_URL=../ui/dist UI_SERVER_PORT=8000 npm run start
**模式三:自定义 ZTF 服务执行文件路径**
```
SERVER_EXE_PATH=bin/ztf npm run start
SERVER_EXE_PATH=bin/
darwin/
ztf npm run start
```
**模式四:跳过启动 ZTF 服务,使用外部 ZTF 服务**
...
...
@@ -83,6 +83,13 @@ npm run package
参考:https://www.electronforge.io/cli#package
打包之前确保如下目录有相应的资源文件:
*
`client/ui/`
:包含 UI 服务相关的所有文件,并且包含
`client/ui/index.html`
文件,作为 UI 服务入口;
*
`client/bin/win32/`
:包含适用于 Windows 的 ZTF 程序;
*
`client/bin/darwin/`
:包含适用于 macOS 的 ZTF 程序;
*
`client/bin/linux/`
:包含适用于 Linux 的 ZTF 程序;
## 发布
```
...
...
client/forge.config.js
浏览文件 @
072cb029
module
.
exports
=
{
"
packagerConfig
"
:
{},
"
makers
"
:
[
packagerConfig
:
{
extraResource
:
[
'
./bin
'
,
'
./ui
'
]
},
makers
:
[
{
"
name
"
:
"
@electron-forge/maker-squirrel
"
,
"
config
"
:
{
"
name
"
:
"
ztf_client
"
name
:
'
@electron-forge/maker-squirrel
'
,
config
:
{
name
:
'
ztf_client
'
}
},
{
"
name
"
:
"
@electron-forge/maker-zip
"
,
"
platforms
"
:
[
"
darwin
"
name
:
'
@electron-forge/maker-zip
'
,
platforms
:
[
'
darwin
'
]
},
{
"
name
"
:
"
@electron-forge/maker-deb
"
,
"
config
"
:
{}
name
:
'
@electron-forge/maker-deb
'
,
config
:
{}
},
{
"
name
"
:
"
@electron-forge/maker-rpm
"
,
"
config
"
:
{}
name
:
'
@electron-forge/maker-rpm
'
,
config
:
{}
}
],
"
plugins
"
:
[
plugins
:
[
[
"
@electron-forge/plugin-webpack
"
,
'
@electron-forge/plugin-webpack
'
,
{
"
mainConfig
"
:
"
./webpack.main.config.js
"
,
"
renderer
"
:
{
"
config
"
:
"
./webpack.renderer.config.js
"
,
"
entryPoints
"
:
[
mainConfig
:
'
./webpack.main.config.js
'
,
renderer
:
{
config
:
'
./webpack.renderer.config.js
'
,
entryPoints
:
[
// {
//
"html": "./src/index.html"
,
//
"js": "./src/renderer.js"
,
//
"name": "main_window"
//
html: './src/index.html'
,
//
js: './src/renderer.js'
,
//
name: 'main_window'
// }
]
}
...
...
client/src/main.js
浏览文件 @
072cb029
...
...
@@ -29,8 +29,6 @@ async function startApp() {
}
_starting
=
true
;
console
.
log
(
'
>> Starting ZTF Server...
'
);
try
{
const
ztfServerUrl
=
await
startZtfServer
();
console
.
log
(
`>> ZTF Server started successfully:
${
ztfServerUrl
}
`
);
...
...
client/src/services.js
浏览文件 @
072cb029
import
path
from
'
path
'
;
import
{
spawn
}
from
'
child_process
'
;
import
os
from
'
os
'
;
import
{
app
}
from
'
electron
'
;
import
express
from
'
express
'
;
...
...
@@ -7,6 +8,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
}
".`
);
return
Promise
.
resolve
();
}
if
(
_ztfServerProcess
)
{
...
...
@@ -14,21 +16,52 @@ export function startZtfServer() {
}
let
{
SERVER_EXE_PATH
:
serverExePath
}
=
process
.
env
;
if
(
!
serverExePath
&&
process
.
env
.
NODE_ENV
!==
'
development
'
)
{
const
platform
=
os
.
platform
();
// 'darwin', 'linux', 'win32'
const
exePath
=
`bin/
${
platform
}
/ztf
${
platform
===
'
win32
'
?
'
.exe
'
:
''
}
`
;
serverExePath
=
path
.
resolve
(
process
.
resourcesPath
,
exePath
);
}
if
(
serverExePath
)
{
if
(
!
path
.
isAbsolute
(
serverExePath
))
{
serverExePath
=
path
.
resolve
(
app
.
getAppPath
(),
serverExePath
);
}
return
new
Promise
((
resolve
)
=>
{
_ztfServerProcess
=
spawn
(
serverExePath
);
_ztfServerProcess
.
on
(
'
close
'
,
()
=>
{
_ztfServerProcess
=
null
;
console
.
log
(
`>> Starting ZTF Server with exe path
${
serverExePath
}
`
);
const
cmd
=
spawn
(
serverExePath
,
[
'
-P
'
,
'
8085
'
],
{
cwd
:
path
.
dirname
(
serverExePath
),
shell
:
true
,
});
cmd
.
on
(
'
close
'
,
()
=>
{
cmd
=
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
];
if
(
line
.
includes
(
'
Now listening on: http
'
))
{
resolve
(
line
.
split
(
'
Now listening on:
'
)[
1
].
trim
());
break
;
}
else
if
(
line
.
includes
(
'
启动HTTP服务于
'
))
{
resolve
(
line
.
split
(
/启动HTTP服务于|,/
)[
1
].
trim
());
break
;
}
else
if
(
line
.
startsWith
(
'
[ERRO]
'
))
{
reject
(
new
Error
(
`Start ztf server failed with error:
${
line
.
substring
(
'
[ERRO]
'
.
length
)}
`
));
break
;
}
}
});
resolve
(
_ztfServerProcess
);
cmd
.
on
(
'
error
'
,
spawnError
=>
{
console
.
error
(
'
>>> Start ztf server failed with error
'
,
spawnError
);
reject
(
spawnError
)
});
_ztfServerProcess
=
cmd
;
});
}
return
new
Promise
((
resolve
,
reject
)
=>
{
const
cmd
=
spawn
(
'
go
'
,
[
'
run
'
,
'
main.go
'
,
'
-p
'
,
'
8085
'
],
{
console
.
log
(
'
>> Starting ZTF development server...
'
);
const
cmd
=
spawn
(
'
go
'
,
[
'
run
'
,
'
main.go
'
,
'
-P
'
,
'
8085
'
],
{
cwd
:
path
.
resolve
(
app
.
getAppPath
(),
'
../cmd/server
'
),
shell
:
true
,
});
...
...
@@ -65,6 +98,10 @@ export function getUIServerUrl() {
}
let
{
UI_SERVER_URL
:
uiServerUrl
}
=
process
.
env
;
if
(
!
uiServerUrl
&&
process
.
env
.
NODE_ENV
!==
'
development
'
)
{
uiServerUrl
=
path
.
resolve
(
process
.
resourcesPath
,
'
ui
'
);
}
if
(
uiServerUrl
)
{
if
(
/^https
?
:
\/\/
/
.
test
(
uiServerUrl
))
{
return
Promise
.
resolve
(
uiServerUrl
);
...
...
@@ -117,6 +154,9 @@ export function getUIServerUrl() {
const
line
=
lines
[
i
];
if
(
line
.
includes
(
'
App running at:
'
))
{
const
nextLine
=
lines
[
i
+
1
]
||
lines
[
i
+
2
];
if
(
!
nextLine
)
{
throw
new
Error
(
`Cannot grabing running address after line "
${
line
}
".`
)
}
const
url
=
nextLine
.
split
(
'
Local:
'
)[
1
];
if
(
url
)
{
resolved
=
true
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录