Skip to content

Commit 25eb3c5

Browse files
author
pompurin404
committed
refactor border switch
1 parent ba72269 commit 25eb3c5

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

src/renderer/src/components/sider/sider-swtich.tsx src/renderer/src/components/base/border-swtich.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ interface SiderSwitchProps extends SwitchProps {
55
isShowBorder?: boolean
66
}
77

8-
const SiderSwitch: React.FC<SiderSwitchProps> = (props) => {
9-
const { isShowBorder = false, isSelected, classNames, ...switchProps } = props
8+
const BorderSwitch: React.FC<SiderSwitchProps> = (props) => {
9+
const { isShowBorder = false, classNames, ...switchProps } = props
1010

1111
return (
1212
<Switch
1313
classNames={{
1414
wrapper: cn('border-2', {
1515
'border-transparent': !isShowBorder
1616
}),
17-
thumb: cn('absolute z-4', { 'transform -translate-x-[2px]': isSelected }),
17+
thumb: cn('absolute z-4', 'transform -translate-x-[2px]'),
1818
...classNames
1919
}}
2020
size="sm"
@@ -23,4 +23,4 @@ const SiderSwitch: React.FC<SiderSwitchProps> = (props) => {
2323
)
2424
}
2525

26-
export default SiderSwitch
26+
export default BorderSwitch

src/renderer/src/components/sider/index.ts

-1
This file was deleted.

src/renderer/src/components/sider/override-card.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Button, Card, CardBody, CardFooter } from '@nextui-org/react'
2+
import BorderSwitch from '@renderer/components/base/border-swtich'
23
import React, { useState } from 'react'
34
import { MdFormatOverline } from 'react-icons/md'
45
import { useLocation, useNavigate } from 'react-router-dom'
5-
import { SiderSwitch } from './index'
66

77
const OverrideCard: React.FC = () => {
88
const navigate = useNavigate()
@@ -26,7 +26,7 @@ const OverrideCard: React.FC = () => {
2626
>
2727
<MdFormatOverline color="default" className="text-[24px]" />
2828
</Button>
29-
<SiderSwitch
29+
<BorderSwitch
3030
isShowBorder={match && enable}
3131
isSelected={enable}
3232
onValueChange={setEnable}

src/renderer/src/components/sider/sysproxy-switcher.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Button, Card, CardBody, CardFooter } from '@nextui-org/react'
2+
import BorderSwitch from '@renderer/components/base/border-swtich'
23
import { useLocation, useNavigate } from 'react-router-dom'
34
import { useAppConfig } from '@renderer/hooks/use-config'
5+
import { triggerSysProxy } from '@renderer/utils/ipc'
46
import { AiOutlineGlobal } from 'react-icons/ai'
57
import React from 'react'
6-
import { triggerSysProxy } from '@renderer/utils/ipc'
7-
import { SiderSwitch } from './index'
88

99
const SysproxySwitcher: React.FC = () => {
1010
const navigate = useNavigate()
@@ -35,7 +35,7 @@ const SysproxySwitcher: React.FC = () => {
3535
>
3636
<AiOutlineGlobal color="default" className="text-[24px]" />
3737
</Button>
38-
<SiderSwitch
38+
<BorderSwitch
3939
isShowBorder={match && enable}
4040
isSelected={enable}
4141
onValueChange={onChange}

src/renderer/src/components/sider/tun-switcher.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Button, Card, CardBody, CardFooter } from '@nextui-org/react'
22
import { useControledMihomoConfig } from '@renderer/hooks/use-controled-mihomo-config'
3+
import BorderSwitch from '@renderer/components/base/border-swtich'
34
import { TbDeviceIpadHorizontalBolt } from 'react-icons/tb'
45
import { useLocation, useNavigate } from 'react-router-dom'
56
import { patchMihomoConfig } from '@renderer/utils/ipc'
67
import React from 'react'
7-
import { SiderSwitch } from './index'
88

99
const TunSwitcher: React.FC = () => {
1010
const navigate = useNavigate()
@@ -15,6 +15,7 @@ const TunSwitcher: React.FC = () => {
1515
const { tun } = controledMihomoConfig || {}
1616
const { enable } = tun || {}
1717

18+
console.log('controledMihomoConfig', controledMihomoConfig)
1819
const onChange = async (enable: boolean): Promise<void> => {
1920
await patchControledMihomoConfig({ tun: { enable } })
2021
await patchMihomoConfig({ tun: { enable } })
@@ -36,7 +37,7 @@ const TunSwitcher: React.FC = () => {
3637
>
3738
<TbDeviceIpadHorizontalBolt color="default" className="text-[24px] font-bold" />
3839
</Button>
39-
<SiderSwitch
40+
<BorderSwitch
4041
isShowBorder={match && enable}
4142
isSelected={enable}
4243
onValueChange={onChange}

0 commit comments

Comments
 (0)