fix: group proxies render list is null
This commit is contained in:
parent
bd0e932910
commit
b3c1c56579
@ -174,7 +174,7 @@ function ProxyRenderItem(props: RenderProps) {
|
|||||||
if (type === 1) {
|
if (type === 1) {
|
||||||
return (
|
return (
|
||||||
<ProxyHead
|
<ProxyHead
|
||||||
sx={{ pl: indent ? 4.5 : 2.5, pr: 3, my: 1, button: { mr: 0.5 } }}
|
sx={{ pl: indent ? 4.5 : 2.5, pr: 3, mt: indent ? 1 : 0.5, mb: 1 }}
|
||||||
groupName={group.name}
|
groupName={group.name}
|
||||||
headState={headState!}
|
headState={headState!}
|
||||||
onLocation={() => onLocation(group)}
|
onLocation={() => onLocation(group)}
|
||||||
|
@ -49,7 +49,7 @@ export const ProxyHead = (props: Props) => {
|
|||||||
}, [groupName, testUrl, verge?.default_latency_test]);
|
}, [groupName, testUrl, verge?.default_latency_test]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ display: "flex", alignItems: "center", ...sx }}>
|
<Box sx={{ display: "flex", alignItems: "center", gap: 0.5, ...sx }}>
|
||||||
<IconButton
|
<IconButton
|
||||||
size="small"
|
size="small"
|
||||||
color="inherit"
|
color="inherit"
|
||||||
@ -86,7 +86,7 @@ export const ProxyHead = (props: Props) => {
|
|||||||
onHeadState({ sortType: ((sortType + 1) % 3) as ProxySortType })
|
onHeadState({ sortType: ((sortType + 1) % 3) as ProxySortType })
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{sortType === 0 && <SortRounded />}
|
{sortType !== 1 && sortType !== 2 && <SortRounded />}
|
||||||
{sortType === 1 && <AccessTimeRounded />}
|
{sortType === 1 && <AccessTimeRounded />}
|
||||||
{sortType === 2 && <SortByAlphaRounded />}
|
{sortType === 2 && <SortByAlphaRounded />}
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
@ -2,7 +2,11 @@ import useSWR from "swr";
|
|||||||
import { getProxies } from "@/services/api";
|
import { getProxies } from "@/services/api";
|
||||||
import { useEffect, useMemo } from "react";
|
import { useEffect, useMemo } from "react";
|
||||||
import { filterSort } from "./use-filter-sort";
|
import { filterSort } from "./use-filter-sort";
|
||||||
import { useHeadStateNew, type HeadState } from "./use-head-state";
|
import {
|
||||||
|
useHeadStateNew,
|
||||||
|
DEFAULT_STATE,
|
||||||
|
type HeadState,
|
||||||
|
} from "./use-head-state";
|
||||||
|
|
||||||
export interface IRenderItem {
|
export interface IRenderItem {
|
||||||
type: 0 | 1 | 2 | 3; // 组 | head | item | empty
|
type: 0 | 1 | 2 | 3; // 组 | head | item | empty
|
||||||
@ -36,17 +40,19 @@ export const useRenderList = (mode: string) => {
|
|||||||
|
|
||||||
const renderList: IRenderItem[] = useMemo(() => {
|
const renderList: IRenderItem[] = useMemo(() => {
|
||||||
if (!proxiesData) return [];
|
if (!proxiesData) return [];
|
||||||
|
|
||||||
|
// global 和 direct 使用展开的样式
|
||||||
const useRule = mode === "rule" || mode === "script";
|
const useRule = mode === "rule" || mode === "script";
|
||||||
const renderGroups =
|
const renderGroups =
|
||||||
(useRule ? proxiesData?.groups : [proxiesData?.global!]) || [];
|
(useRule ? proxiesData?.groups : [proxiesData?.global!]) || [];
|
||||||
|
|
||||||
const retList = renderGroups.flatMap((group) => {
|
const retList = renderGroups.flatMap((group) => {
|
||||||
const headState = headStates[group.name];
|
const headState = headStates[group.name] || DEFAULT_STATE;
|
||||||
const ret: IRenderItem[] = [
|
const ret: IRenderItem[] = [
|
||||||
{ type: 0, key: group.name, group, headState },
|
{ type: 0, key: group.name, group, headState },
|
||||||
];
|
];
|
||||||
|
|
||||||
if (headState?.open) {
|
if (headState?.open || !useRule) {
|
||||||
const proxies = filterSort(
|
const proxies = filterSort(
|
||||||
group.all,
|
group.all,
|
||||||
group.name,
|
group.name,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user