mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 23:03:44 +08:00
fix: connections is null
This commit is contained in:
parent
f032228d0e
commit
aba0826c38
@ -56,15 +56,16 @@ const ConnectionsPage = () => {
|
|||||||
|
|
||||||
const { connect, disconnect } = useWebsocket(
|
const { connect, disconnect } = useWebsocket(
|
||||||
(event) => {
|
(event) => {
|
||||||
|
// meta v1.15.0 出现data.connections为null的情况
|
||||||
const data = JSON.parse(event.data) as IConnections;
|
const data = JSON.parse(event.data) as IConnections;
|
||||||
// 尽量与前一次connections的展示顺序保持一致
|
// 尽量与前一次connections的展示顺序保持一致
|
||||||
setConnData((old) => {
|
setConnData((old) => {
|
||||||
const oldConn = old.connections;
|
const oldConn = old.connections;
|
||||||
const maxLen = data.connections.length;
|
const maxLen = data.connections?.length;
|
||||||
|
|
||||||
const connections: typeof oldConn = [];
|
const connections: typeof oldConn = [];
|
||||||
|
|
||||||
const rest = data.connections.filter((each) => {
|
const rest = data.connections?.filter((each) => {
|
||||||
const index = oldConn.findIndex((o) => o.id === each.id);
|
const index = oldConn.findIndex((o) => o.id === each.id);
|
||||||
|
|
||||||
if (index >= 0 && index < maxLen) {
|
if (index >= 0 && index < maxLen) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user