Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
max_android_panel
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Zhang Xin
max_android_panel
Commits
dc5ea835
Commit
dc5ea835
authored
Nov 12, 2019
by
niuxinyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
关门优化
parent
f6d557a2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
8 deletions
+55
-8
client/actions/chooseTaskContainer.js
+17
-1
client/containers/HomePageContainer/HomePageContainer.jsx
+38
-7
client/util/socket.js
+0
-0
No files found.
client/actions/chooseTaskContainer.js
View file @
dc5ea835
...
...
@@ -13,12 +13,14 @@ const willCloseDoor=(data,flag=false)=>{
UTILPATH
.
myLogger
.
info
(
"finish_task url "
,
url
);
UTILPATH
.
myLogger
.
info
(
"finish_task flag "
,
flag
);
UTILPATH
.
myLogger
.
info
(
"finish_task request "
,
bodyData
);
return
async
(
dispatch
)
=>
{
let
success
=
(
json
)
=>
{
UTILPATH
.
myLogger
.
info
(
"finish_task response "
,
json
);
if
(
flag
){
//回收箱完成
dispatch
(
getTaskList
(
data
))
}
};
let
fail
=
(
err
)
=>
{
...
...
@@ -34,9 +36,23 @@ const willCloseDoor=(data,flag=false)=>{
'Content-Type'
:
'application/json; charset=UTF-8'
},
body
:
JSON
.
stringify
(
bodyData
)
}).
then
((
response
)
=>
response
.
json
());
}).
then
((
response
)
=>
{
if
(
response
.
status
==
200
&&
response
){
response
.
json
()
}
else
{
var
error
=
new
Error
(
response
.
statusText
)
error
.
response
=
response
throw
error
}
}).
catch
(()
=>
{
alert
(
'网络状态不好,请稍后重试'
)
})
return
success
(
result
)
}
catch
(
err
)
{
return
fail
(
err
)
}
}
...
...
client/containers/HomePageContainer/HomePageContainer.jsx
View file @
dc5ea835
...
...
@@ -37,29 +37,60 @@ export default class HomePageContainer extends React.Component{
text
:
text
})
}
onConnectionChange
(){
const
{
rtt
,
downlink
,
effectiveType
,
saveData
}
=
navigator
.
connection
;
console
.
log
(
`有效网络连接类型:
${
effectiveType
}
`
);
console
.
log
(
`估算的下行速度/带宽:
${
downlink
}
Mb/s`
);
console
.
log
(
`估算的往返时间:
${
rtt
}
ms`
);
console
.
log
(
`打开/请求数据保护模式:
${
saveData
}
`
);
console
.
log
(
navigator
.
connection
.
effectiveType
)
}
logout
(){
if
(
this
.
state
.
closeDoorStatus
===
0
){
this
.
setState
({
closeDoorStatus
:
1
},()
=>
{
UTILPATH
.
myLogger
.
info
(
"logout startStopServer "
,
this
.
props
.
startStopServer
);
if
(
this
.
props
.
startStopServer
){
if
(
!
navigator
.
onLine
){
// 断网调用
this
.
props
.
willCloseDoor
().
then
(()
=>
{
this
.
props
.
endCountBack
();
this
.
props
.
tempLogout
()
});
// this.props.willCloseDoor().then(()=>{
// this.props.endCountBack();
// this.props.tempLogout()
// })
this
.
setState
({
closeDoorStatus
:
0
},()
=>
{
alert
(
'当前无网络连接,稍后重试'
)
})
}
else
{
//正常调用
try
{
this
.
onConnectionChange
()
const
{
rtt
,
downlink
,
effectiveType
,
saveData
}
=
navigator
.
connection
;
if
(
rtt
<
3000
&&
rtt
!=
0
){
this
.
props
.
willCloseDoor
().
then
(()
=>
{
this
.
props
.
endCountBack
();
let
msg
=
{
type
:
'WILL_CLOSEDOOR'
};
sendMsg
(
JSON
.
stringify
(
msg
));
this
.
props
.
changeIsSend
(
true
);
// this.props.tempLogout()
});
console
.
log
(
'有网络'
,
this
.
props
)
})
}
else
{
this
.
setState
({
closeDoorStatus
:
0
},()
=>
{
alert
(
'当前网络不佳,请稍后重试'
)
})
}
}
catch
(
error
)
{
console
.
log
(
error
,
'cuowu'
)
}
}
...
...
client/util/socket.js
View file @
dc5ea835
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