feat: add proxy auto scroll toggle setting (#3674)

* feat: add proxy auto scroll toggle setting

* refactor: rename enable_proxy_auto_scroll to enable_hover_jump_navigator

* 参考 Unified Delay 调整式样
This commit is contained in:
rebecca554owen
2025-06-11 13:21:24 +08:00
committed by GitHub
Unverified
parent 22eac1a832
commit 4f474e1098
7 changed files with 52 additions and 5 deletions

View File

@@ -200,6 +200,9 @@ pub struct IVerge {
/// 自动进入轻量模式的延迟(分钟)
pub auto_light_weight_minutes: Option<u64>,
/// 启用代理页面自动滚动
pub enable_hover_jump_navigator: Option<bool>,
/// 服务状态跟踪
pub service_state: Option<crate::core::service::ServiceState>,
}
@@ -275,6 +278,7 @@ impl IVerge {
tun_tray_icon: Some(false),
enable_auto_launch: Some(false),
enable_silent_start: Some(false),
enable_hover_jump_navigator: Some(true),
enable_system_proxy: Some(false),
proxy_auto_config: Some(false),
pac_file_content: Some(DEFAULT_PAC.into()),
@@ -351,6 +355,7 @@ impl IVerge {
patch!(enable_tun_mode);
patch!(enable_auto_launch);
patch!(enable_silent_start);
patch!(enable_hover_jump_navigator);
patch!(enable_random_port);
#[cfg(not(target_os = "windows"))]
patch!(verge_redir_port);
@@ -492,6 +497,7 @@ pub struct IVergeResponse {
pub auto_light_weight_minutes: Option<u64>,
pub enable_dns_settings: Option<bool>,
pub home_cards: Option<serde_json::Value>,
pub enable_hover_jump_navigator: Option<bool>,
pub service_state: Option<crate::core::service::ServiceState>,
}
@@ -561,6 +567,7 @@ impl From<IVerge> for IVergeResponse {
auto_light_weight_minutes: verge.auto_light_weight_minutes,
enable_dns_settings: verge.enable_dns_settings,
home_cards: verge.home_cards,
enable_hover_jump_navigator: verge.enable_hover_jump_navigator,
service_state: verge.service_state,
}
}

View File

@@ -106,10 +106,12 @@ const LetterItem = memo(
name,
onClick,
getFirstChar,
enableAutoScroll = true,
}: {
name: string;
onClick: (name: string) => void;
getFirstChar: (str: string) => string;
enableAutoScroll?: boolean;
}) => {
const [showTooltip, setShowTooltip] = useState(false);
const letterRef = useRef<HTMLDivElement>(null);
@@ -136,11 +138,14 @@ const LetterItem = memo(
const handleMouseEnter = useCallback(() => {
setShowTooltip(true);
// 添加 200ms 的延迟,避免鼠标快速划过时触发滚动
hoverTimeoutRef.current = setTimeout(() => {
onClick(name);
}, 100);
}, [name, onClick]);
// 只有在启用自动滚动时才触发滚动
if (enableAutoScroll) {
// 添加 100ms 的延迟,避免鼠标快速划过时触发滚动
hoverTimeoutRef.current = setTimeout(() => {
onClick(name);
}, 100);
}
}, [name, onClick, enableAutoScroll]);
const handleMouseLeave = useCallback(() => {
setShowTooltip(false);
@@ -198,6 +203,9 @@ export const ProxyGroups = (props: Props) => {
const { verge } = useVerge();
const { current, patchCurrent } = useProfiles();
// 获取自动滚动开关状态,默认为 true
const enableAutoScroll = verge?.enable_hover_jump_navigator ?? true;
const timeout = verge?.default_latency_timeout || 10000;
const virtuosoRef = useRef<VirtuosoHandle>(null);
@@ -541,6 +549,7 @@ export const ProxyGroups = (props: Props) => {
name={name}
onClick={handleLetterClick}
getFirstChar={getFirstChar}
enableAutoScroll={enableAutoScroll}
/>
))}
</div>

View File

@@ -12,6 +12,7 @@ import {
} from "@mui/material";
import { useVerge } from "@/hooks/use-verge";
import { BaseDialog, DialogRef, Switch } from "@/components/base";
import { TooltipIcon } from "@/components/base/base-tooltip-icon";
import { GuardState } from "./guard-state";
import { open as openDialog } from "@tauri-apps/plugin-dialog";
import { convertFileSrc } from "@tauri-apps/api/core";
@@ -147,6 +148,30 @@ export const LayoutViewer = forwardRef<DialogRef>((props, ref) => {
</GuardState>
</Item>
<Item>
<ListItemText
primary={
<Box sx={{ display: "flex", alignItems: "center", gap: 0.5 }}>
<span>{t("Hover Jump Navigator")}</span>
<TooltipIcon
title={t("Hover Jump Navigator Info")}
sx={{ opacity: "0.7" }}
/>
</Box>
}
/>
<GuardState
value={verge?.enable_hover_jump_navigator ?? true}
valueProps="checked"
onCatch={onError}
onFormat={onSwitchFormat}
onChange={(e) => onChangeData({ enable_hover_jump_navigator: e })}
onGuard={(e) => patchVerge({ enable_hover_jump_navigator: e })}
>
<Switch edge="end" />
</GuardState>
</Item>
<Item>
<ListItemText primary={t("Nav Icon")} />
<GuardState

View File

@@ -58,6 +58,7 @@ const SettingSystem = ({ onError }: Props) => {
enable_silent_start,
enable_system_proxy,
proxy_auto_config,
enable_hover_jump_navigator,
} = verge ?? {};
const onSwitchFormat = (_e: any, value: boolean) => value;

View File

@@ -261,6 +261,8 @@
"Administrator mode may not support auto launch": "Administrator mode may not support auto launch",
"Silent Start": "Silent Start",
"Silent Start Info": "Start the program in background mode without displaying the panel",
"Hover Jump Navigator": "Hover Jump Navigator",
"Hover Jump Navigator Info": "Automatically scroll to the corresponding proxy group when hovering over alphabet letters",
"TG Channel": "Telegram Channel",
"Manual": "Manual",
"Github Repo": "Github Repo",

View File

@@ -261,6 +261,8 @@
"Administrator mode may not support auto launch": "管理员模式可能不支持开机自启",
"Silent Start": "静默启动",
"Silent Start Info": "程序启动时以后台模式运行,不显示程序面板",
"Hover Jump Navigator": "悬浮跳转导航",
"Hover Jump Navigator Info": "鼠标悬停在字母上时自动滚动到对应代理组",
"TG Channel": "Telegram 频道",
"Manual": "使用手册",
"Github Repo": "GitHub 项目地址",

View File

@@ -792,6 +792,7 @@ interface IVergeConfig {
webdav_username?: string;
webdav_password?: string;
home_cards?: Record<string, boolean>;
enable_hover_jump_navigator?: boolean;
}
interface IWebDavFile {