From c4dcead397f65af9c20529b1af8c45dc2f60da34 Mon Sep 17 00:00:00 2001 From: pompurin404 Date: Fri, 2 Aug 2024 14:01:17 +0800 Subject: [PATCH] refactor border switch --- .../{sider/sider-swtich.tsx => base/border-swtich.tsx} | 8 ++++---- src/renderer/src/components/sider/index.ts | 1 - src/renderer/src/components/sider/override-card.tsx | 4 ++-- src/renderer/src/components/sider/sysproxy-switcher.tsx | 6 +++--- src/renderer/src/components/sider/tun-switcher.tsx | 5 +++-- 5 files changed, 12 insertions(+), 12 deletions(-) rename src/renderer/src/components/{sider/sider-swtich.tsx => base/border-swtich.tsx} (60%) delete mode 100644 src/renderer/src/components/sider/index.ts diff --git a/src/renderer/src/components/sider/sider-swtich.tsx b/src/renderer/src/components/base/border-swtich.tsx similarity index 60% rename from src/renderer/src/components/sider/sider-swtich.tsx rename to src/renderer/src/components/base/border-swtich.tsx index 77c28bd..521791b 100644 --- a/src/renderer/src/components/sider/sider-swtich.tsx +++ b/src/renderer/src/components/base/border-swtich.tsx @@ -5,8 +5,8 @@ interface SiderSwitchProps extends SwitchProps { isShowBorder?: boolean } -const SiderSwitch: React.FC = (props) => { - const { isShowBorder = false, isSelected, classNames, ...switchProps } = props +const BorderSwitch: React.FC = (props) => { + const { isShowBorder = false, classNames, ...switchProps } = props return ( = (props) => { wrapper: cn('border-2', { 'border-transparent': !isShowBorder }), - thumb: cn('absolute z-4', { 'transform -translate-x-[2px]': isSelected }), + thumb: cn('absolute z-4', 'transform -translate-x-[2px]'), ...classNames }} size="sm" @@ -23,4 +23,4 @@ const SiderSwitch: React.FC = (props) => { ) } -export default SiderSwitch +export default BorderSwitch diff --git a/src/renderer/src/components/sider/index.ts b/src/renderer/src/components/sider/index.ts deleted file mode 100644 index 8f13d65..0000000 --- a/src/renderer/src/components/sider/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as SiderSwitch } from './sider-swtich' diff --git a/src/renderer/src/components/sider/override-card.tsx b/src/renderer/src/components/sider/override-card.tsx index 0c79dad..ac6e286 100644 --- a/src/renderer/src/components/sider/override-card.tsx +++ b/src/renderer/src/components/sider/override-card.tsx @@ -1,8 +1,8 @@ import { Button, Card, CardBody, CardFooter } from '@nextui-org/react' +import BorderSwitch from '@renderer/components/base/border-swtich' import React, { useState } from 'react' import { MdFormatOverline } from 'react-icons/md' import { useLocation, useNavigate } from 'react-router-dom' -import { SiderSwitch } from './index' const OverrideCard: React.FC = () => { const navigate = useNavigate() @@ -26,7 +26,7 @@ const OverrideCard: React.FC = () => { > - { const navigate = useNavigate() @@ -35,7 +35,7 @@ const SysproxySwitcher: React.FC = () => { > - { const navigate = useNavigate() @@ -15,6 +15,7 @@ const TunSwitcher: React.FC = () => { const { tun } = controledMihomoConfig || {} const { enable } = tun || {} + console.log('controledMihomoConfig', controledMihomoConfig) const onChange = async (enable: boolean): Promise => { await patchControledMihomoConfig({ tun: { enable } }) await patchMihomoConfig({ tun: { enable } }) @@ -36,7 +37,7 @@ const TunSwitcher: React.FC = () => { > -