From de18ae367e54b625ae9d9072f2f4a3066e62af60 Mon Sep 17 00:00:00 2001 From: pompurin404 Date: Wed, 14 Aug 2024 10:54:05 +0800 Subject: [PATCH] disable dnd scale --- .../src/components/override/override-item.tsx | 10 +++++++++- src/renderer/src/components/profiles/profile-item.tsx | 10 +++++++++- src/renderer/src/components/sider/conn-card.tsx | 11 +++++++++-- src/renderer/src/components/sider/dns-card.tsx | 10 +++++++++- src/renderer/src/components/sider/log-card.tsx | 10 +++++++++- .../src/components/sider/mihomo-core-card.tsx | 11 +++++++++-- src/renderer/src/components/sider/override-card.tsx | 10 +++++++++- src/renderer/src/components/sider/profile-card.tsx | 10 +++++++++- src/renderer/src/components/sider/proxy-card.tsx | 10 +++++++++- src/renderer/src/components/sider/resource-card.tsx | 10 +++++++++- src/renderer/src/components/sider/rule-card.tsx | 11 +++++++++-- src/renderer/src/components/sider/sniff-card.tsx | 11 +++++++++-- .../src/components/sider/sysproxy-switcher.tsx | 10 +++++++++- src/renderer/src/components/sider/tun-switcher.tsx | 11 +++++++++-- 14 files changed, 126 insertions(+), 19 deletions(-) diff --git a/src/renderer/src/components/override/override-item.tsx b/src/renderer/src/components/override/override-item.tsx index 5e729dc..08126ee 100644 --- a/src/renderer/src/components/override/override-item.tsx +++ b/src/renderer/src/components/override/override-item.tsx @@ -62,9 +62,17 @@ const OverrideItem: React.FC = (props) => { const [updating, setUpdating] = useState(false) const [openInfo, setOpenInfo] = useState(false) const [openFile, setOpenFile] = useState(false) - const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ + const { + attributes, + listeners, + setNodeRef, + transform: tf, + transition, + isDragging + } = useSortable({ id: info.id }) + const transform = tf ? { x: tf.x, y: tf.y, scaleX: 1, scaleY: 1 } : null const [disableOpen, setDisableOpen] = useState(false) const onMenuAction = (key: Key): void => { diff --git a/src/renderer/src/components/profiles/profile-item.tsx b/src/renderer/src/components/profiles/profile-item.tsx index 436e4d9..04b886a 100644 --- a/src/renderer/src/components/profiles/profile-item.tsx +++ b/src/renderer/src/components/profiles/profile-item.tsx @@ -53,9 +53,17 @@ const ProfileItem: React.FC = (props) => { const [selecting, setSelecting] = useState(false) const [openInfo, setOpenInfo] = useState(false) const [openFile, setOpenFile] = useState(false) - const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ + const { + attributes, + listeners, + setNodeRef, + transform: tf, + transition, + isDragging + } = useSortable({ id: info.id }) + const transform = tf ? { x: tf.x, y: tf.y, scaleX: 1, scaleY: 1 } : null const [disableSelect, setDisableSelect] = useState(false) const menuItems: MenuItem[] = useMemo(() => { diff --git a/src/renderer/src/components/sider/conn-card.tsx b/src/renderer/src/components/sider/conn-card.tsx index 2bb0a40..e815c4d 100644 --- a/src/renderer/src/components/sider/conn-card.tsx +++ b/src/renderer/src/components/sider/conn-card.tsx @@ -14,10 +14,17 @@ const ConnCard: React.FC = () => { const [upload, setUpload] = useState(0) const [download, setDownload] = useState(0) - const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ + const { + attributes, + listeners, + setNodeRef, + transform: tf, + transition, + isDragging + } = useSortable({ id: 'connection' }) - + const transform = tf ? { x: tf.x, y: tf.y, scaleX: 1, scaleY: 1 } : null useEffect(() => { window.electron.ipcRenderer.on('mihomoTraffic', (_e, info: IMihomoTrafficInfo) => { setUpload(info.up) diff --git a/src/renderer/src/components/sider/dns-card.tsx b/src/renderer/src/components/sider/dns-card.tsx index 87e88f5..10071e4 100644 --- a/src/renderer/src/components/sider/dns-card.tsx +++ b/src/renderer/src/components/sider/dns-card.tsx @@ -13,9 +13,17 @@ const DNSCard: React.FC = () => { const { controledMihomoConfig, patchControledMihomoConfig } = useControledMihomoConfig(true) const { dns, tun } = controledMihomoConfig || {} const { enable } = dns || {} - const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ + const { + attributes, + listeners, + setNodeRef, + transform: tf, + transition, + isDragging + } = useSortable({ id: 'dns' }) + const transform = tf ? { x: tf.x, y: tf.y, scaleX: 1, scaleY: 1 } : null const onChange = async (enable: boolean): Promise => { await patchControledMihomoConfig({ dns: { enable } }) await patchMihomoConfig({ dns: { enable } }) diff --git a/src/renderer/src/components/sider/log-card.tsx b/src/renderer/src/components/sider/log-card.tsx index f3d4fad..3f7a9b3 100644 --- a/src/renderer/src/components/sider/log-card.tsx +++ b/src/renderer/src/components/sider/log-card.tsx @@ -7,9 +7,17 @@ const LogCard: React.FC = () => { const navigate = useNavigate() const location = useLocation() const match = location.pathname.includes('/logs') - const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ + const { + attributes, + listeners, + setNodeRef, + transform: tf, + transition, + isDragging + } = useSortable({ id: 'log' }) + const transform = tf ? { x: tf.x, y: tf.y, scaleX: 1, scaleY: 1 } : null return (
{ const navigate = useNavigate() const location = useLocation() const match = location.pathname.includes('/mihomo') - const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ + const { + attributes, + listeners, + setNodeRef, + transform: tf, + transition, + isDragging + } = useSortable({ id: 'mihomo' }) - + const transform = tf ? { x: tf.x, y: tf.y, scaleX: 1, scaleY: 1 } : null const [mem, setMem] = useState(0) useEffect(() => { diff --git a/src/renderer/src/components/sider/override-card.tsx b/src/renderer/src/components/sider/override-card.tsx index cfeffef..d092d5c 100644 --- a/src/renderer/src/components/sider/override-card.tsx +++ b/src/renderer/src/components/sider/override-card.tsx @@ -9,9 +9,17 @@ const OverrideCard: React.FC = () => { const navigate = useNavigate() const location = useLocation() const match = location.pathname.includes('/override') - const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ + const { + attributes, + listeners, + setNodeRef, + transform: tf, + transition, + isDragging + } = useSortable({ id: 'override' }) + const transform = tf ? { x: tf.x, y: tf.y, scaleX: 1, scaleY: 1 } : null return (
{ const [showRuntimeConfig, setShowRuntimeConfig] = useState(false) const { profileConfig, addProfileItem } = useProfileConfig() const { current, items } = profileConfig ?? {} - const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ + const { + attributes, + listeners, + setNodeRef, + transform: tf, + transition, + isDragging + } = useSortable({ id: 'profile' }) + const transform = tf ? { x: tf.x, y: tf.y, scaleX: 1, scaleY: 1 } : null const info = items?.find((item) => item.id === current) ?? { id: 'default', type: 'local', diff --git a/src/renderer/src/components/sider/proxy-card.tsx b/src/renderer/src/components/sider/proxy-card.tsx index 327b973..fead778 100644 --- a/src/renderer/src/components/sider/proxy-card.tsx +++ b/src/renderer/src/components/sider/proxy-card.tsx @@ -12,9 +12,17 @@ const ProxyCard: React.FC = () => { const location = useLocation() const match = location.pathname.includes('/proxies') const { data: proxies = { proxies: {} } } = useSWR('mihomoProxies', mihomoProxies) - const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ + const { + attributes, + listeners, + setNodeRef, + transform: tf, + transition, + isDragging + } = useSortable({ id: 'proxy' }) + const transform = tf ? { x: tf.x, y: tf.y, scaleX: 1, scaleY: 1 } : null const filtered = useMemo(() => { return Object.keys(proxies.proxies).filter((key) => 'all' in proxies.proxies[key]) }, [proxies]) diff --git a/src/renderer/src/components/sider/resource-card.tsx b/src/renderer/src/components/sider/resource-card.tsx index 158305a..077c3ec 100644 --- a/src/renderer/src/components/sider/resource-card.tsx +++ b/src/renderer/src/components/sider/resource-card.tsx @@ -8,9 +8,17 @@ const ResourceCard: React.FC = () => { const navigate = useNavigate() const location = useLocation() const match = location.pathname.includes('/resources') - const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ + const { + attributes, + listeners, + setNodeRef, + transform: tf, + transition, + isDragging + } = useSortable({ id: 'resource' }) + const transform = tf ? { x: tf.x, y: tf.y, scaleX: 1, scaleY: 1 } : null return (
{ const { data: rules } = useSWR('mihomoRules', mihomoRules, { refreshInterval: 5000 }) - const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ + const { + attributes, + listeners, + setNodeRef, + transform: tf, + transition, + isDragging + } = useSortable({ id: 'rule' }) - + const transform = tf ? { x: tf.x, y: tf.y, scaleX: 1, scaleY: 1 } : null return (
{ const { controledMihomoConfig, patchControledMihomoConfig } = useControledMihomoConfig(true) const { sniffer } = controledMihomoConfig || {} const { enable } = sniffer || {} - const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ + const { + attributes, + listeners, + setNodeRef, + transform: tf, + transition, + isDragging + } = useSortable({ id: 'sniff' }) - + const transform = tf ? { x: tf.x, y: tf.y, scaleX: 1, scaleY: 1 } : null const onChange = async (enable: boolean): Promise => { await patchControledMihomoConfig({ sniffer: { enable } }) await patchMihomoConfig({ sniffer: { enable } }) diff --git a/src/renderer/src/components/sider/sysproxy-switcher.tsx b/src/renderer/src/components/sider/sysproxy-switcher.tsx index e0e5719..cb3d941 100644 --- a/src/renderer/src/components/sider/sysproxy-switcher.tsx +++ b/src/renderer/src/components/sider/sysproxy-switcher.tsx @@ -15,9 +15,17 @@ const SysproxySwitcher: React.FC = () => { const { appConfig, patchAppConfig } = useAppConfig(true) const { sysProxy } = appConfig || {} const { enable } = sysProxy || {} - const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ + const { + attributes, + listeners, + setNodeRef, + transform: tf, + transition, + isDragging + } = useSortable({ id: 'sysproxy' }) + const transform = tf ? { x: tf.x, y: tf.y, scaleX: 1, scaleY: 1 } : null const onChange = async (enable: boolean): Promise => { await triggerSysProxy(enable) await patchAppConfig({ sysProxy: { enable } }) diff --git a/src/renderer/src/components/sider/tun-switcher.tsx b/src/renderer/src/components/sider/tun-switcher.tsx index 6a659bd..2b64b75 100644 --- a/src/renderer/src/components/sider/tun-switcher.tsx +++ b/src/renderer/src/components/sider/tun-switcher.tsx @@ -20,10 +20,17 @@ const TunSwitcher: React.FC = () => { const { controledMihomoConfig, patchControledMihomoConfig } = useControledMihomoConfig(true) const { tun } = controledMihomoConfig || {} const { enable } = tun || {} - const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ + const { + attributes, + listeners, + setNodeRef, + transform: tf, + transition, + isDragging + } = useSortable({ id: 'tun' }) - + const transform = tf ? { x: tf.x, y: tf.y, scaleX: 1, scaleY: 1 } : null const onChange = async (enable: boolean): Promise => { if (enable && platform !== 'win32') { const encryptionAvailable = await isEncryptionAvailable()