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
63d92a08
There was an error fetching the commit references. Please try again later.
Commit
63d92a08
authored
2 years ago
by
FoundTheWOUT
Browse files
Options
Downloads
Patches
Plain Diff
Support ordering connection
parent
509d8336
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/locales/zh.json
+5
-1
5 additions, 1 deletion
src/locales/zh.json
src/pages/connections.tsx
+55
-4
55 additions, 4 deletions
src/pages/connections.tsx
src/services/types.d.ts
+2
-2
2 additions, 2 deletions
src/services/types.d.ts
with
62 additions
and
7 deletions
src/locales/zh.json
+
5
−
1
View file @
63d92a08
...
...
@@ -87,5 +87,9 @@
"Back"
:
"返回"
,
"Save"
:
"保存"
,
"Cancel"
:
"取消"
"Cancel"
:
"取消"
,
"Default"
:
"默认"
,
"Download Speed"
:
"下载速度"
,
"Upload Speed"
:
"上传速度"
}
This diff is collapsed.
Click to expand it.
src/pages/connections.tsx
+
55
−
4
View file @
63d92a08
import
{
useEffect
,
useMemo
,
useState
}
from
"
react
"
;
import
{
useLockFn
}
from
"
ahooks
"
;
import
{
Box
,
Button
,
Paper
,
TextField
}
from
"
@mui/material
"
;
import
{
Box
,
Button
,
ButtonGroup
,
Paper
,
TextField
}
from
"
@mui/material
"
;
import
{
Virtuoso
}
from
"
react-virtuoso
"
;
import
{
useTranslation
}
from
"
react-i18next
"
;
import
{
closeAllConnections
,
getInformation
}
from
"
@/services/api
"
;
...
...
@@ -10,6 +10,14 @@ import BaseEmpty from "@/components/base/base-empty";
const
initConn
=
{
uploadTotal
:
0
,
downloadTotal
:
0
,
connections
:
[]
};
type
IOderOpts
=
{
[
key
in
string
]:
{
orderFunc
(
connections
:
ApiType
.
ConnectionsItem
[]
):
ApiType
.
ConnectionsItem
[];
};
};
const
ConnectionsPage
=
()
=>
{
const
{
t
}
=
useTranslation
();
...
...
@@ -22,6 +30,25 @@ const ConnectionsPage = () => {
);
},
[
connData
,
filterText
]);
const
orderOpts
:
IOderOpts
=
{
Default
:
{
orderFunc
:
(
list
)
=>
list
,
},
// "Download Traffic": {
// orderFunc: (list) => list,
// },
// "Upload Traffic": {
// orderFunc: (list) => list,
// },
"
Download Speed
"
:
{
orderFunc
:
(
list
)
=>
list
.
sort
((
a
,
b
)
=>
b
.
curDownload
!
-
a
.
curDownload
!
),
},
"
Upload Speed
"
:
{
orderFunc
:
(
list
)
=>
list
.
sort
((
a
,
b
)
=>
b
.
curUpload
!
-
a
.
curUpload
!
),
},
};
const
[
curOrderOpt
,
setOrderOpt
]
=
useState
(
"
Default
"
);
useEffect
(()
=>
{
let
ws
:
WebSocket
|
null
=
null
;
...
...
@@ -61,13 +88,19 @@ const ConnectionsPage = () => {
}
}
return
{
...
data
,
connections
};
const
orderedConnections
=
orderOpts
[
curOrderOpt
].
orderFunc
(
connections
);
return
{
...
data
,
connections
:
orderedConnections
,
};
});
});
});
return
()
=>
ws
?.
close
();
},
[]);
},
[
curOrderOpt
]);
const
onCloseAll
=
useLockFn
(
closeAllConnections
);
...
...
@@ -122,7 +155,25 @@ const ConnectionsPage = () => {
/>
</
Box
>
<
Box
height
=
"calc(100% - 50px)"
>
<
Box
sx
=
{
{
mx
:
"
12px
"
,
mb
:
0.5
}
}
>
<
ButtonGroup
size
=
"small"
sx
=
{
{
width
:
"
100%
"
}
}
>
{
Object
.
keys
(
orderOpts
).
map
((
opt
)
=>
(
<
Button
key
=
{
opt
}
variant
=
{
opt
===
curOrderOpt
?
"
contained
"
:
"
outlined
"
}
onClick
=
{
()
=>
setOrderOpt
(
opt
)
}
sx
=
{
{
fontSize
:
"
0.5rem
"
,
textTransform
:
"
capitalize
"
,
}
}
>
{
t
(
opt
)
}
</
Button
>
))
}
</
ButtonGroup
>
</
Box
>
<
Box
height
=
"calc(100% - 50px - 30px)"
>
{
filterConn
.
length
>
0
?
(
<
Virtuoso
data
=
{
filterConn
}
...
...
This diff is collapsed.
Click to expand it.
src/services/types.d.ts
+
2
−
2
View file @
63d92a08
...
...
@@ -74,8 +74,8 @@ declare namespace ApiType {
chains
:
string
[];
rule
:
string
;
rulePayload
:
string
;
curUpload
?:
number
;
//
calculat
e
curDownload
?:
number
;
//
calculat
e
curUpload
?:
number
;
//
upload speed, calculate at runtim
e
curDownload
?:
number
;
//
download speed, calculate at runtim
e
}
interface
Connections
{
...
...
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