From 786cb60ac1bb9294700829abc50e18ff8c29c714 Mon Sep 17 00:00:00 2001 From: Ahao Date: Sat, 26 Jul 2025 12:53:35 +0800 Subject: [PATCH] Revert "add home page control buttons" This reverts commit e184843855932905facd55bae9847cf0b4e0bd46. --- src/pages/home.tsx | 243 ++++++++------------------------------------- 1 file changed, 41 insertions(+), 202 deletions(-) diff --git a/src/pages/home.tsx b/src/pages/home.tsx index 924a6364..1d9fbaa8 100644 --- a/src/pages/home.tsx +++ b/src/pages/home.tsx @@ -1,49 +1,45 @@ -import { BasePage } from "@/components/base"; -import { ClashInfoCard } from "@/components/home/clash-info-card"; -import { ClashModeCard } from "@/components/home/clash-mode-card"; -import { CurrentProxyCard } from "@/components/home/current-proxy-card"; -import { EnhancedCard } from "@/components/home/enhanced-card"; -import { EnhancedTrafficStats } from "@/components/home/enhanced-traffic-stats"; -import { HomeProfileCard } from "@/components/home/home-profile-card"; -import { IpInfoCard } from "@/components/home/ip-info-card"; -import { ProxyTunCard } from "@/components/home/proxy-tun-card"; -import { SystemInfoCard } from "@/components/home/system-info-card"; -import { TestCard } from "@/components/home/test-card"; -import { useProfiles } from "@/hooks/use-profiles"; -import { useVerge } from "@/hooks/use-verge"; -import { entry_lightweight_mode, openWebUrl } from "@/services/cmds"; -import { - DnsOutlined, - HelpOutlineRounded, - HistoryEduOutlined, - RouterOutlined, - SettingsOutlined, - SpeedOutlined, - VisibilityOutlined, - VisibilityOffOutlined, -} from "@mui/icons-material"; +import { useTranslation } from "react-i18next"; import { Box, Button, - Checkbox, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - FormControlLabel, - FormGroup, - Grid, IconButton, - keyframes, - Popover, - Tooltip, - Typography, useTheme, + keyframes, + Dialog, + DialogTitle, + DialogContent, + DialogActions, + FormGroup, + FormControlLabel, + Checkbox, + Tooltip, + Grid, } from "@mui/material"; -import { useLockFn } from "ahooks"; -import { useState } from "react"; -import { useTranslation } from "react-i18next"; +import { useVerge } from "@/hooks/use-verge"; +import { useProfiles } from "@/hooks/use-profiles"; +import { + RouterOutlined, + SettingsOutlined, + DnsOutlined, + SpeedOutlined, + HelpOutlineRounded, + HistoryEduOutlined, +} from "@mui/icons-material"; import { useNavigate } from "react-router-dom"; +import { ProxyTunCard } from "@/components/home/proxy-tun-card"; +import { ClashModeCard } from "@/components/home/clash-mode-card"; +import { EnhancedTrafficStats } from "@/components/home/enhanced-traffic-stats"; +import { useState } from "react"; +import { HomeProfileCard } from "@/components/home/home-profile-card"; +import { EnhancedCard } from "@/components/home/enhanced-card"; +import { CurrentProxyCard } from "@/components/home/current-proxy-card"; +import { BasePage } from "@/components/base"; +import { ClashInfoCard } from "@/components/home/clash-info-card"; +import { SystemInfoCard } from "@/components/home/system-info-card"; +import { useLockFn } from "ahooks"; +import { entry_lightweight_mode, openWebUrl } from "@/services/cmds"; +import { TestCard } from "@/components/home/test-card"; +import { IpInfoCard } from "@/components/home/ip-info-card"; // 定义旋转动画 const round = keyframes` @@ -73,156 +69,6 @@ interface HomeCardsSettings { [key: string]: boolean; } -// 首页设置对话框组件接口 -interface HomeCardsControlProps { - homeCards: HomeCardsSettings; - onToggle: (key: string) => void; -} - -// 首页卡片显示控制组件 -const HomeCardsControl = ({ homeCards, onToggle }: HomeCardsControlProps) => { - const { t } = useTranslation(); - const [anchorEl, setAnchorEl] = useState(null); - - const handleClick = (event: React.MouseEvent) => { - setAnchorEl(event.currentTarget); - }; - - const handleClose = () => { - setAnchorEl(null); - }; - - const open = Boolean(anchorEl); - const id = open ? "card-control-popover" : undefined; - - return ( - <> - - - {Object.values(homeCards).every((v) => v) ? ( - - ) : Object.values(homeCards).every((v) => !v) ? ( - - ) : ( - - )} - - - - - - - {t("Card Visibility")} - - - onToggle("profile")} - /> - } - label={t("Profiles")} - /> - onToggle("proxy")} - /> - } - label={t("Current Node")} - /> - onToggle("network")} - /> - } - label={t("Network Settings")} - /> - onToggle("mode")} - /> - } - label={t("Proxy Mode")} - /> - onToggle("traffic")} - /> - } - label={t("Traffic Stats")} - /> - onToggle("test")} - /> - } - label={t("Website Tests")} - /> - onToggle("ip")} - /> - } - label={t("IP Information")} - /> - onToggle("clashinfo")} - /> - } - label={t("Clash Info")} - /> - onToggle("systeminfo")} - /> - } - label={t("System Info")} - /> - - - - - ); -}; - // 首页设置对话框组件接口 interface HomeSettingsDialogProps { open: boolean; @@ -355,7 +201,7 @@ const HomeSettingsDialog = ({ export const HomePage = () => { const { t } = useTranslation(); - const { verge, patchVerge } = useVerge(); + const { verge } = useVerge(); const { current, mutateProfiles } = useProfiles(); const navigate = useNavigate(); const theme = useTheme(); @@ -374,17 +220,9 @@ export const HomePage = () => { systeminfo: true, test: true, ip: true, - info: true, }, ); - // 处理卡片显示切换 - const handleCardToggle = useLockFn(async (key: string) => { - const newCards = { ...homeCards, [key]: !homeCards[key] }; - setHomeCards(newCards); - await patchVerge({ home_cards: newCards }); - }); - // 导航到订阅页面 const goToProfiles = () => { navigate("/profile"); @@ -412,7 +250,11 @@ export const HomePage = () => { // 新增:保存设置时用requestIdleCallback/setTimeout const handleSaveSettings = (newCards: HomeCardsSettings) => { - setHomeCards(newCards); + if (window.requestIdleCallback) { + window.requestIdleCallback(() => setHomeCards(newCards)); + } else { + setTimeout(() => setHomeCards(newCards), 0); + } }; return ( @@ -430,9 +272,6 @@ export const HomePage = () => { - - -