Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Clash Verge
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Clash Verge
Commits
4b6189af
There was an error fetching the commit references. Please try again later.
Unverified
Commit
4b6189af
authored
3 years ago
by
GyDi
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
feat: enhance connections display order
parent
5d0ffbe4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pages/connections.tsx
+31
-3
31 additions, 3 deletions
src/pages/connections.tsx
with
31 additions
and
3 deletions
src/pages/connections.tsx
+
31
−
3
View file @
4b6189af
...
...
@@ -12,7 +12,7 @@ const ConnectionsPage = () => {
const
initConn
=
{
uploadTotal
:
0
,
downloadTotal
:
0
,
connections
:
[]
};
const
{
t
}
=
useTranslation
();
const
[
conn
,
setConn
]
=
useState
<
ApiType
.
Connections
>
(
initConn
);
const
[
conn
Data
,
setConn
Data
]
=
useState
<
ApiType
.
Connections
>
(
initConn
);
useEffect
(()
=>
{
let
ws
:
WebSocket
|
null
=
null
;
...
...
@@ -23,7 +23,35 @@ const ConnectionsPage = () => {
ws
.
addEventListener
(
"
message
"
,
(
event
)
=>
{
const
data
=
JSON
.
parse
(
event
.
data
)
as
ApiType
.
Connections
;
setConn
(
data
);
setConnData
((
old
)
=>
{
const
oldConn
=
old
.
connections
;
const
oldList
=
oldConn
.
map
((
each
)
=>
each
.
id
);
const
maxLen
=
data
.
connections
.
length
;
const
connections
:
typeof
oldConn
=
[];
// 与前一次连接的顺序尽量保持一致
data
.
connections
.
filter
((
each
)
=>
{
const
index
=
oldList
.
indexOf
(
each
.
id
);
if
(
index
>=
0
&&
index
<
maxLen
)
{
connections
[
index
]
=
each
;
return
false
;
}
return
true
;
})
.
forEach
((
each
)
=>
{
for
(
let
i
=
0
;
i
<
maxLen
;
++
i
)
{
if
(
!
connections
[
i
])
{
connections
[
i
]
=
each
;
return
;
}
}
});
return
{
...
data
,
connections
};
});
});
});
...
...
@@ -50,7 +78,7 @@ const ConnectionsPage = () => {
<
Paper
sx
=
{
{
boxShadow
:
2
,
height
:
"
100%
"
}
}
>
<
Virtuoso
initialTopMostItemIndex
=
{
999
}
data
=
{
conn
.
connections
}
data
=
{
conn
Data
.
connections
}
itemContent
=
{
(
index
,
item
)
=>
<
ConnectionItem
value
=
{
item
}
/>
}
/>
</
Paper
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment