Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
dba5db26
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
9 个月 前同步成功
通知
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 搜索 >>
提交
dba5db26
编写于
4月 15, 2022
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix websocket connection issue in electron
上级
18e71739
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
43 addition
and
40 deletion
+43
-40
client/src/app/app.js
client/src/app/app.js
+23
-2
client/src/app/core/ui.js
client/src/app/core/ui.js
+2
-2
ui/package.json
ui/package.json
+2
-0
ui/src/layouts/IndexLayout/components/TopSettings.vue
ui/src/layouts/IndexLayout/components/TopSettings.vue
+3
-3
ui/src/locales/en-US.ts
ui/src/locales/en-US.ts
+1
-1
ui/src/locales/zh-CN.ts
ui/src/locales/zh-CN.ts
+1
-1
ui/src/services/websocket.ts
ui/src/services/websocket.ts
+8
-28
ui/src/views/script/component/execLog.vue
ui/src/views/script/component/execLog.vue
+3
-3
未找到文件。
client/src/app/app.js
浏览文件 @
dba5db26
import
{
app
,
BrowserWindow
,
Menu
,
shell
}
from
'
electron
'
;
import
main
from
"
@electron/remote/main
"
;
import
{
app
,
BrowserWindow
,
ipcMain
,
Menu
,
shell
}
from
'
electron
'
;
import
{
DEBUG
}
from
'
./utils/consts
'
;
import
{
IS_MAC_OSX
}
from
'
./utils/env
'
;
...
...
@@ -8,6 +7,7 @@ import Config, {updateConfig} from './utils/config';
import
Lang
,
{
initLang
}
from
'
./core/lang
'
;
import
{
startUIService
}
from
"
./core/ui
"
;
import
{
startZtfServer
,
killZtfServer
}
from
"
./core/ztf
"
;
// import {main} from "@electron/remote";
export
default
class
ZtfApp
{
constructor
()
{
...
...
@@ -42,6 +42,7 @@ export default class ZtfApp {
process
.
env
[
'
ELECTRON_DISABLE_SECURITY_WARNINGS
'
]
=
'
true
'
;
const
remoteMain
=
require
(
'
@electron/remote/main
'
)
logInfo
(
remoteMain
)
remoteMain
.
initialize
()
const
mainWin
=
new
BrowserWindow
({
...
...
@@ -62,6 +63,26 @@ export default class ZtfApp {
const
url
=
await
startUIService
()
await
mainWin
.
loadURL
(
url
);
// const { ipcMain } = require('electron')
// ipcMain.on('renderer-msg', (event, arg) => {
// logInfo('msg from renderer: ' + arg)
// switch (arg) {
// case 'fullScreen':
// const mainWin = this._windows.get('main');
// mainWin.setFullScreen(!mainWin.isFullScreen());
// break;
// case 'help':
// shell.openExternal('https://ztf.im');
// break;
// case 'exit':
// app.quit()
// break;
// default:
// }
//
// // event.reply('main-msg', '好的');
// })
// if (DEBUG) {
mainWin
.
webContents
.
openDevTools
({
mode
:
'
bottom
'
});
// }
...
...
client/src/app/core/ui.js
浏览文件 @
dba5db26
...
...
@@ -38,8 +38,8 @@ export function startUIService() {
_uiService
=
null
;
reject
(
serverError
);
}
else
{
logInfo
(
`>> ui server started successfully on http://
localhost
:
${
port
}
.`
);
resolve
(
`http://
localhost
:
${
port
}
`
);
logInfo
(
`>> ui server started successfully on http://
127.0.0.1
:
${
port
}
.`
);
resolve
(
`http://
127.0.0.1
:
${
port
}
`
);
}
});
server
.
on
(
'
close
'
,
()
=>
{
...
...
ui/package.json
浏览文件 @
dba5db26
...
...
@@ -11,11 +11,13 @@
"svgo"
:
"svgo -f src/assets/iconsvg --config=src/assets/iconsvg/svgo.yml"
},
"dependencies"
:
{
"@electron/remote"
:
"^2.0.8"
,
"@toast-ui/editor"
:
"^2.5.3"
,
"ant-design-vue"
:
"^2.2.8"
,
"axios"
:
"^0.21.4"
,
"core-js"
:
"^3.18.0"
,
"echarts"
:
"^4.9.0"
,
"electron"
:
"^18.0.3"
,
"localforage"
:
"^1.10.0"
,
"lodash.debounce"
:
"^4.0.8"
,
"lodash.throttle"
:
"^4.1.1"
,
...
...
ui/src/layouts/IndexLayout/components/TopSettings.vue
浏览文件 @
dba5db26
...
...
@@ -95,12 +95,12 @@ export default defineComponent({
console
.
log
(
'
fullScreen
'
)
fullScreenDef
.
value
=
!
fullScreenDef
.
value
const
remote
=
window
.
require
(
'
@electron/remote
'
)
const
mainWin
=
remote
.
getCurrentWindow
();
mainWin
.
setFullScreen
(
!
mainWin
.
isFullScreen
());
const
{
BrowserWindow
}
=
window
.
require
(
"
@electron/remote
"
)
BrowserWindow
.
setFullScreen
(
!
BrowserWindow
.
isFullScreen
());
}
const
help
=
():
void
=>
{
console
.
log
(
'
help
'
)
const
shell
=
window
.
require
(
'
@electron/remote
'
).
shell
shell
.
openExternal
(
'
https://ztf.im
'
);
}
...
...
ui/src/locales/en-US.ts
浏览文件 @
dba5db26
...
...
@@ -7,7 +7,7 @@ export default {
'
settings
'
:
'
Settings
'
,
'
exit
'
:
'
Exit
'
,
'
fullScreen
'
:
'
Full S
creen
'
,
'
fullScreen
'
:
'
Toggle Fulls
creen
'
,
'
help
'
:
'
Help
'
,
'
index
'
:
'
Index
'
,
...
...
ui/src/locales/zh-CN.ts
浏览文件 @
dba5db26
...
...
@@ -7,7 +7,7 @@ export default {
'
settings
'
:
'
设置
'
,
'
exit
'
:
'
退出
'
,
'
fullScreen
'
:
'
全屏
'
,
'
fullScreen
'
:
'
切换
全屏
'
,
'
help
'
:
'
帮助
'
,
'
index
'
:
'
索引
'
,
...
...
ui/src/services/websocket.ts
浏览文件 @
dba5db26
import
*
as
neffos
from
'
neffos.js
'
;
import
{
getCurrentInstance
}
from
'
vue
'
;
import
{
NSConn
}
from
"
neffos.js
"
;
import
{
Component
InternalInstance
,
Component
PublicInstance
}
from
"
@vue/runtime-core
"
;
import
{
ComponentPublicInstance
}
from
"
@vue/runtime-core
"
;
const
WebSocketPath
=
'
api/v1/ws
'
;
export
const
WebSocketBaseDev
=
'
ws://127.0.0.1:8085/
'
;
export
type
WsObject
=
{
conn
?:
any
;
};
export
type
WsEvent
=
{
room
:
string
;
code
:
string
;
...
...
@@ -90,27 +86,11 @@ export function getWebSocketApi (): string {
const
isProd
=
process
.
env
.
NODE_ENV
===
'
production
'
const
loc
=
window
.
location
console
.
log
(
loc
)
console
.
log
(
loc
.
hostname
)
let
wsUri
=
''
if
(
!
isProd
)
{
wsUri
=
WebSocketBaseDev
}
else
{
const
loc
=
window
.
location
if
(
loc
.
hostname
===
'
localhost
'
)
{
// run in electron or dev machine
wsUri
=
WebSocketBaseDev
}
else
{
if
(
loc
.
protocol
===
'
https:
'
)
{
wsUri
=
'
wss:
'
}
else
{
wsUri
=
'
ws:
'
}
wsUri
+=
'
//
'
+
loc
.
host
wsUri
+=
loc
.
pathname
}
}
console
.
log
(
`
${
isProd
}
,
${
loc
.
toString
()}
`
)
const
wsUri
=
process
.
env
.
VUE_APP_APIHOST
.
replace
(
'
http
'
,
'
ws
'
)
const
url
=
wsUri
+
WebSocketPath
console
.
log
(
`websocket url =
${
url
}
`
)
return
wsUri
+
WebSocketPath
return
url
}
ui/src/views/script/component/execLog.vue
浏览文件 @
dba5db26
<
template
>
<div
id=
"exec-log-main"
>
<div
v-if=
"
currProduct.id &&
wsStatus === 'success'"
class=
"ws-status"
:class=
"wsStatus"
>
<div
v-if=
"wsStatus === 'success'"
class=
"ws-status"
:class=
"wsStatus"
>
<CheckOutlined
/>
<span
class=
"text"
>
{{
t
(
'
ws_conn_success
'
)
}}
</span>
<span
@
click=
"hideWsStatus"
class=
"icon-close"
><CloseCircleOutlined
/></span>
</div>
<div
v-if=
"
currProduct.id &&
wsStatus === 'fail'"
class=
"ws-status"
:class=
"wsStatus"
>
<div
v-if=
"wsStatus === 'fail'"
class=
"ws-status"
:class=
"wsStatus"
>
<CloseOutlined
/>
<span
class=
"text"
>
{{
t
(
'
ws_conn_success
'
)
}}
</span>
<span
@
click=
"hideWsStatus"
class=
"icon-close"
><CloseCircleOutlined
/></span>
...
...
@@ -116,7 +116,7 @@ export default defineComponent({
const
{
proxy
}
=
getCurrentInstance
()
as
any
;
WebSocket
.
init
(
proxy
)
let
wsStatus
=
ref
(
'
success
'
)
let
wsStatus
=
ref
(
''
)
if
(
init
)
{
proxy
.
$sub
(
WsEventName
,
(
data
)
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录