disable dnd scale

This commit is contained in:
pompurin404 2024-08-14 10:54:05 +08:00
parent ab54e7ad6b
commit de18ae367e
No known key found for this signature in database
14 changed files with 126 additions and 19 deletions

View File

@ -62,9 +62,17 @@ const OverrideItem: React.FC<Props> = (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 => {

View File

@ -53,9 +53,17 @@ const ProfileItem: React.FC<Props> = (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(() => {

View File

@ -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)

View File

@ -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<void> => {
await patchControledMihomoConfig({ dns: { enable } })
await patchMihomoConfig({ dns: { enable } })

View File

@ -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 (
<div
style={{

View File

@ -13,10 +13,17 @@ const MihomoCoreCard: React.FC = () => {
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(() => {

View File

@ -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 (
<div
style={{

View File

@ -23,9 +23,17 @@ const ProfileCard: React.FC = () => {
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',

View File

@ -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])

View File

@ -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 (
<div
style={{

View File

@ -13,10 +13,17 @@ const RuleCard: React.FC = () => {
const { data: rules } = useSWR<IMihomoRulesInfo>('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 (
<div
style={{

View File

@ -14,10 +14,17 @@ const SniffCard: React.FC = () => {
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<void> => {
await patchControledMihomoConfig({ sniffer: { enable } })
await patchMihomoConfig({ sniffer: { enable } })

View File

@ -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<void> => {
await triggerSysProxy(enable)
await patchAppConfig({ sysProxy: { enable } })

View File

@ -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<void> => {
if (enable && platform !== 'win32') {
const encryptionAvailable = await isEncryptionAvailable()