Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
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
shenshaokai
jinfa-platform
Commits
a5e388c5
Commit
a5e388c5
authored
Dec 07, 2020
by
Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修改socket添加token以及规定接收信息的数据结构
parent
ebf4cdf9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
RightContent.tsx
src/layouts/components/RightContent.tsx
+7
-3
No files found.
src/layouts/components/RightContent.tsx
View file @
a5e388c5
...
...
@@ -16,6 +16,7 @@ import { SOCKET_URL } from '@/constants';
// layout: 'sidemenu' | 'topmenu';
// }
const
NOT_READ_MESSAGE
=
1
;
const
GlobalHeaderRight
:
React
.
FC
<
{}
>
=
(
props
)
=>
{
// const { theme, layout } = props;
const
[
message
,
setMessage
]
=
useState
<
number
>
(
0
);
...
...
@@ -31,17 +32,20 @@ const GlobalHeaderRight: React.FC<{}> = (props) => {
const
webSocketInit
=
useCallback
(()
=>
{
console
.
log
(
ws
.
current
)
if
((
!
ws
.
current
||
ws
.
current
.
readyState
===
3
)
&&
userInfo
)
{
ws
.
current
=
new
WebSocket
(
`
${
SOCKET_URL
}
/report/websocket?memberId=
${
userInfo
.
memberId
}
&roleId=
${
userInfo
.
memberRoleId
}
`
);
const
url
=
`
${
SOCKET_URL
}
/report/websocket?memberId=
${
userInfo
.
memberId
}
&roleId=
${
userInfo
.
memberRoleId
}
&token=
${
userInfo
.
token
}
`
;
ws
.
current
=
new
WebSocket
(
url
);
ws
.
current
.
onopen
=
(
e
)
=>
{
console
.
log
(
e
)
}
ws
.
current
.
onmessage
=
(
e
)
=>
{
console
.
log
(
e
)
setMessage
(
e
.
data
)
if
(
e
.
data
.
type
===
NOT_READ_MESSAGE
)
{
setMessage
(
e
.
data
.
data
);
}
};
ws
.
current
.
onclose
=
(
e
)
=>
{
console
.
log
(
"关闭连接"
)
}
}
ws
.
current
.
onerror
=
(
e
)
=>
{
console
.
log
(
"socket 出错"
)
}
...
...
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