summaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authorLarvan2 <[email protected]>2023-06-05 17:18:55 +0800
committerLarvan2 <[email protected]>2023-06-05 17:21:43 +0800
commit3ef02fa1dd220373124138e5aeaf9aa21a213e9f (patch)
treed7a68e404e3518b63598d913bec98d870c545f20 /src/components
parent9eb478232a93a4e1370592bc64ce78369e58ee4f (diff)
chore: 根据屏幕大小调整箭头和测速图标
Diffstat (limited to 'src/components')
-rw-r--r--src/components/proxies/ProxyGroup.tsx82
1 files changed, 62 insertions, 20 deletions
diff --git a/src/components/proxies/ProxyGroup.tsx b/src/components/proxies/ProxyGroup.tsx
index bb79564..038c69d 100644
--- a/src/components/proxies/ProxyGroup.tsx
+++ b/src/components/proxies/ProxyGroup.tsx
@@ -20,7 +20,7 @@ import { useFilteredAndSorted } from './hooks';
import s0 from './ProxyGroup.module.scss';
import { ProxyList, ProxyListSummaryView } from './ProxyList';
-const { createElement, useCallback, useMemo, useState } = React;
+const { createElement, useCallback, useMemo, useState, useEffect } = React;
function ZapWrapper() {
return (
@@ -86,29 +86,71 @@ function ProxyGroupImpl({
setIsTestingLatency(false);
}, [all, apiConfig, dispatch, name, version.meta]);
+ const [windowWidth, setWindowWidth] = useState(window.innerWidth);
+
+ const updateWindowWidth = () => {
+ setWindowWidth(window.innerWidth);
+ };
+
+ useEffect(() => {
+ window.addEventListener('resize', updateWindowWidth);
+ return () => window.removeEventListener('resize', updateWindowWidth);
+ }, []);
+
return (
<div className={s0.group}>
- <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
+ <div
+ style={{
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: windowWidth > 768 ? 'start' : 'space-between',
+ }}
+ >
<CollapsibleSectionHeader name={name} type={type} toggle={toggle} qty={all.length} />
<div style={{ display: 'flex' }}>
- <Button
- title="Test latency"
- kind="minimal"
- onClick={testLatency}
- isLoading={isTestingLatency}
- >
- <ZapWrapper />
- </Button>
- <Button
- kind="minimal"
- onClick={toggle}
- className={s0.btn}
- title="Toggle collapsible section"
- >
- <span className={cx(s0.arrow, { [s0.isOpen]: isOpen })}>
- <ChevronDown size={20} />
- </span>
- </Button>
+ {windowWidth > 768 ? (
+ <>
+ <Button
+ kind="minimal"
+ onClick={toggle}
+ className={s0.btn}
+ title="Toggle collapsible section"
+ >
+ <span className={cx(s0.arrow, { [s0.isOpen]: isOpen })}>
+ <ChevronDown size={20} />
+ </span>
+ </Button>
+ <Button
+ title="Test latency"
+ kind="minimal"
+ onClick={testLatency}
+ isLoading={isTestingLatency}
+ >
+ <ZapWrapper />
+ </Button>
+ </>
+ ) : (
+ <>
+ <Button
+ title="Test latency"
+ kind="minimal"
+ onClick={testLatency}
+ isLoading={isTestingLatency}
+ >
+ <ZapWrapper />
+ </Button>
+ <Button
+ kind="minimal"
+ onClick={toggle}
+ className={s0.btn}
+ title="Toggle collapsible section"
+ >
+ <span className={cx(s0.arrow, { [s0.isOpen]: isOpen })}>
+ <ChevronDown size={20} />
+ </span>
+ </Button>
+ </>
+ )}
</div>
</div>
{createElement(isOpen ? ProxyList : ProxyListSummaryView, {