Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
W
web-monitor
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
web-monitor
Commits
e54babf2
Commit
e54babf2
authored
Mar 10, 2022
by
neogcg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
3/10
parent
3d429703
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
49 deletions
+3
-49
main.js
src/main.js
+1
-2
websocket.js
src/utils/websocket.js
+0
-45
vue.config.js
vue.config.js
+2
-2
No files found.
src/main.js
View file @
e54babf2
...
...
@@ -11,8 +11,7 @@ import '@/icons' // icon
import
'@/permission'
// permission control
import
performLoader
from
'@/utils/global_main_loader.js'
import
WS
from
'@/util/websocket'
Vue
.
prototype
.
$ws
=
WS
Vue
.
use
(
ElementUI
,
{
locale
})
performLoader
(
Vue
)
// 所有的第三方插件性质的东西都放到这里面了
Vue
.
config
.
productionTip
=
false
...
...
src/utils/websocket.js
deleted
100644 → 0
View file @
3d429703
import
store
from
'../store'
const
WS
=
{
$ws
:
null
,
// webscoket实例
wsUrl
:
'ws://192.168.0.111:8885/websocket/1'
,
// websocket链接地址
createWS
:
function
()
{
if
(
'WebSocket'
in
window
)
{
this
.
$ws
=
new
WebSocket
(
wsURl
)
this
.
$ws
.
onopen
=
this
.
wsOpen
this
.
$ws
.
onmessage
=
this
.
wsMessage
this
.
$ws
.
onerror
=
this
.
wsError
this
.
$ws
.
onclose
=
this
.
wsClose
}
else
{
alert
(
'当前浏览器不支持webSocket'
)
}
},
wsOpen
:
function
()
{
this
.
$ws
.
send
(
'连接成功'
)
console
.
log
(
'== websocket open =='
)
heartBeat
.
start
()
},
wsMessage
:
function
(
msg
)
{
console
.
log
(
'== websocket message =='
,
msg
)
heartBeat
.
reset
()
store
.
commit
(
'SET_WS_MSG'
,
msg
.
data
)
},
wsError
:
function
(
err
)
{
console
.
log
(
'== websocket error =='
,
err
)
},
wsClose
:
function
(
event
)
{
console
.
log
(
'== websocket close =='
,
event
)
}
}
const
heartBeat
=
{
timeout
:
30000
,
// 心跳重连时间
timeoutObj
:
null
,
// 定时器
reset
:
function
()
{
clearInterVal
(
this
.
timeoutObj
)
console
.
log
(
'websocket 心跳'
)
WS
.
start
()
},
start
:
function
()
{
this
.
timeoutObj
=
setTimeout
(
function
()
{
if
(
WS
.
$ws
.
readyState
===
1
)
{
WS
.
$ws
.
send
(
'HeartBeat'
)
}
},
this
.
timeout
)
}
}
export
default
WS
\ No newline at end of file
vue.config.js
View file @
e54babf2
...
...
@@ -11,8 +11,8 @@ const port = process.env.port || process.env.npm_config_port || 8886 // dev port
const
rewriteDefaultConfig
=
{
changeOrigin
:
true
,
target
:
'http://8.142.143.40:8886'
,
//
target: 'http://192.168.0.111:8886',
//
target: 'http://8.142.143.40:8886',
target
:
'http://192.168.0.111:8886'
,
// ws: true,
headers
:
{
referer
:
'laddercloud.cn'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment