diff --git a/src/components/proxy/proxy-groups.tsx b/src/components/proxy/proxy-groups.tsx index e852391..8386b53 100644 --- a/src/components/proxy/proxy-groups.tsx +++ b/src/components/proxy/proxy-groups.tsx @@ -118,6 +118,7 @@ export const ProxyGroups = (props: Props) => { ref={virtuosoRef} style={{ height: "100%" }} totalCount={renderList.length} + increaseViewportBy={256} itemContent={(index) => ( { selected={selected} onClick={() => onClick?.(proxy.name)} sx={[ - { borderRadius: 1, pl: 1.5, pr: 1 }, + { height: 56, borderRadius: 1, pl: 1.5, pr: 1 }, ({ palette: { mode, primary } }) => { const bgcolor = mode === "light" @@ -61,45 +54,48 @@ export const ProxyItemMini = (props: Props) => { const color = mode === "light" ? primary.main : primary.light; const showDelay = delay > 0; + const shadowColor = + mode === "light" ? "rgba(0,0,0,0.04)" : "rgba(255,255,255,0.08)"; + return { "&:hover .the-check": { display: !showDelay ? "block" : "none" }, "&:hover .the-delay": { display: showDelay ? "block" : "none" }, "&:hover .the-icon": { display: "none" }, - "&.Mui-selected": { bgcolor }, + "&.Mui-selected": { bgcolor, boxShadow: `0 0 0 1px ${bgcolor}` }, "&.Mui-selected .MuiListItemText-secondary": { color }, + boxShadow: `0 0 0 1px ${shadowColor}`, }; }, ]} > - -
- {proxy.name} -
+ + + {proxy.name} + - {showType && ( - <> - {!!proxy.provider && ( - {proxy.provider} - )} - {proxy.type} - {proxy.udp && UDP} - + {showType && ( + + {!!proxy.provider && ( + {proxy.provider} )} - - } - /> + {proxy.type} + {proxy.udp && UDP} + + )} + - + {delay === -2 && ( @@ -158,7 +154,7 @@ export const ProxyItemMini = (props: Props) => { sx={{ fontSize: 16 }} /> )} - + ); }; diff --git a/src/components/proxy/proxy-render.tsx b/src/components/proxy/proxy-render.tsx index b5f50d0..f0d197f 100644 --- a/src/components/proxy/proxy-render.tsx +++ b/src/components/proxy/proxy-render.tsx @@ -110,6 +110,7 @@ export const ProxyRender = (props: RenderProps) => { return ( { key={item.key + proxy.name} groupName={group.name} proxy={proxy!} - selected={group.now === proxy?.name} + selected={group.now === proxy.name} showType={headState?.showType} onClick={() => onChangeProxy(group, proxy!)} /> diff --git a/src/components/proxy/use-render-list.ts b/src/components/proxy/use-render-list.ts index 22fc96d..1753b01 100644 --- a/src/components/proxy/use-render-list.ts +++ b/src/components/proxy/use-render-list.ts @@ -3,6 +3,7 @@ import { useEffect, useMemo } from "react"; import { getProxies } from "@/services/api"; import { useVerge } from "@/hooks/use-verge"; import { filterSort } from "./use-filter-sort"; +import { useWindowWidth } from "./use-window-width"; import { useHeadStateNew, DEFAULT_STATE, @@ -28,7 +29,18 @@ export const useRenderList = (mode: string) => { ); const { verge } = useVerge(); - const col = verge?.proxy_layout_column || 1; + const { width } = useWindowWidth(); + + let col = verge?.proxy_layout_column || 1; + + // 自适应 + if (col === 6) { + if (width > 1450) col = 5; + else if (width > 1024) col = 4; + else if (width > 900) col = 3; + else if (width >= 600) col = 2; + else col = 1; + } const [headStates, setHeadState] = useHeadStateNew(); @@ -80,7 +92,7 @@ export const useRenderList = (mode: string) => { return ret.concat( groupList(proxies, col).map((proxyCol) => ({ type: 4, - key: `col-${group.name}`, + key: `col-${group.name}-${proxyCol[0].name}`, group, headState, col, diff --git a/src/components/proxy/use-window-width.ts b/src/components/proxy/use-window-width.ts new file mode 100644 index 0000000..d1de3c3 --- /dev/null +++ b/src/components/proxy/use-window-width.ts @@ -0,0 +1,16 @@ +import { useEffect, useState } from "react"; + +export const useWindowWidth = () => { + const [width, setWidth] = useState(() => document.body.clientWidth); + + useEffect(() => { + const handleResize = () => setWidth(document.body.clientWidth); + + window.addEventListener("resize", handleResize); + return () => { + window.removeEventListener("resize", handleResize); + }; + }, []); + + return { width }; +}; diff --git a/src/components/setting/mods/misc-viewer.tsx b/src/components/setting/mods/misc-viewer.tsx index 02a0692..d438537 100644 --- a/src/components/setting/mods/misc-viewer.tsx +++ b/src/components/setting/mods/misc-viewer.tsx @@ -99,6 +99,9 @@ export const MiscViewer = forwardRef((props, ref) => { })); }} > + + Auto + {[1, 2, 3, 4, 5].map((i) => ( {i}