chore: disable admin mode autolaunch limitation

This commit is contained in:
wonfen 2025-04-19 12:37:01 +08:00
parent 2b1d02f0cc
commit c718ef3058
4 changed files with 10 additions and 13 deletions

View File

@ -106,13 +106,13 @@ export const SystemInfoCard = () => {
// 切换自启动状态 // 切换自启动状态
const toggleAutoLaunch = useCallback(async () => { const toggleAutoLaunch = useCallback(async () => {
if (!verge || isAdminMode) return; if (!verge) return;
try { try {
await patchVerge({ enable_auto_launch: !verge.enable_auto_launch }); await patchVerge({ enable_auto_launch: !verge.enable_auto_launch });
} catch (err) { } catch (err) {
console.error("切换开机自启动状态失败:", err); console.error("切换开机自启动状态失败:", err);
} }
}, [verge, patchVerge, isAdminMode]); }, [verge, patchVerge]);
// 安装系统服务 // 安装系统服务
const onInstallService = useLockFn(async () => { const onInstallService = useLockFn(async () => {
@ -258,7 +258,7 @@ export const SystemInfoCard = () => {
</Typography> </Typography>
<Stack direction="row" spacing={1} alignItems="center"> <Stack direction="row" spacing={1} alignItems="center">
{isAdminMode && ( {isAdminMode && (
<Tooltip title={t("Administrator mode does not support auto launch")}> <Tooltip title={t("Administrator mode may not support auto launch")}>
<WarningOutlined sx={{ color: "warning.main", fontSize: 20 }} /> <WarningOutlined sx={{ color: "warning.main", fontSize: 20 }} />
</Tooltip> </Tooltip>
)} )}
@ -268,8 +268,7 @@ export const SystemInfoCard = () => {
color={autoLaunchEnabled ? "success" : "default"} color={autoLaunchEnabled ? "success" : "default"}
variant={autoLaunchEnabled ? "filled" : "outlined"} variant={autoLaunchEnabled ? "filled" : "outlined"}
onClick={toggleAutoLaunch} onClick={toggleAutoLaunch}
disabled={isAdminMode} sx={{ cursor: "pointer" }}
sx={{ cursor: isAdminMode ? "not-allowed" : "pointer" }}
/> />
</Stack> </Stack>
</Stack> </Stack>

View File

@ -194,7 +194,7 @@ const SettingSystem = ({ onError }: Props) => {
label={t("Auto Launch")} label={t("Auto Launch")}
extra={ extra={
isAdminMode && ( isAdminMode && (
<Tooltip title={t("Administrator mode does not support auto launch")}> <Tooltip title={t("Administrator mode may not support auto launch")}>
<WarningRounded sx={{ color: "warning.main", mr: 1 }} /> <WarningRounded sx={{ color: "warning.main", mr: 1 }} />
</Tooltip> </Tooltip>
) )
@ -206,14 +206,12 @@ const SettingSystem = ({ onError }: Props) => {
onCatch={onError} onCatch={onError}
onFormat={onSwitchFormat} onFormat={onSwitchFormat}
onChange={(e) => { onChange={(e) => {
// 在管理员模式下禁用更改 // 移除管理员模式检查提示
if (isAdminMode) return;
onChangeData({ enable_auto_launch: e }); onChangeData({ enable_auto_launch: e });
}} }}
onGuard={async (e) => { onGuard={async (e) => {
if (isAdminMode) { if (isAdminMode) {
Notice.error(t("Administrator mode does not support auto launch"), 2000); Notice.info(t("Administrator mode may not support auto launch"), 2000);
return Promise.reject(new Error(t("Administrator mode does not support auto launch")));
} }
try { try {
@ -230,7 +228,7 @@ const SettingSystem = ({ onError }: Props) => {
} }
}} }}
> >
<Switch edge="end" disabled={isAdminMode} /> <Switch edge="end" />
</GuardState> </GuardState>
</SettingItem> </SettingItem>

View File

@ -258,7 +258,7 @@
"PAC Script Content": "PAC Script Content", "PAC Script Content": "PAC Script Content",
"PAC URL": "PAC URL: ", "PAC URL": "PAC URL: ",
"Auto Launch": "Auto Launch", "Auto Launch": "Auto Launch",
"Administrator mode does not support auto launch": "Administrator mode does not support auto launch", "Administrator mode may not support auto launch": "Administrator mode may not support auto launch",
"Silent Start": "Silent Start", "Silent Start": "Silent Start",
"Silent Start Info": "Start the program in background mode without displaying the panel", "Silent Start Info": "Start the program in background mode without displaying the panel",
"TG Channel": "Telegram Channel", "TG Channel": "Telegram Channel",

View File

@ -258,7 +258,7 @@
"PAC Script Content": "PAC 脚本内容", "PAC Script Content": "PAC 脚本内容",
"PAC URL": "PAC 地址:", "PAC URL": "PAC 地址:",
"Auto Launch": "开机自启", "Auto Launch": "开机自启",
"Administrator mode does not support auto launch": "管理员模式不支持开机自启", "Administrator mode may not support auto launch": "管理员模式可能不支持开机自启",
"Silent Start": "静默启动", "Silent Start": "静默启动",
"Silent Start Info": "程序启动时以后台模式运行,不显示程序面板", "Silent Start Info": "程序启动时以后台模式运行,不显示程序面板",
"TG Channel": "Telegram 频道", "TG Channel": "Telegram 频道",