Files
koring-launcher/src/pages/setting/network/security-id.tsx
T

64 lines
2.4 KiB
TypeScript
Raw Normal View History

2026-06-28 03:37:07 +08:00
import { useCallback } from "react";
import { useConfigStore } from "@/stores/configStore";
import { Switch, Input } from "@heroui/react";
2026-06-20 12:46:08 +08:00
import { ShieldCheck } from "lucide-react";
import { SettingCard, SettingRow, PageHeader, SectionTitle } from "@/components/setting";
2026-06-20 12:46:08 +08:00
export function SecurityIdSetting() {
2026-06-28 03:37:07 +08:00
const enabled = useConfigStore((s) => s.config.network.securityId.enabled);
const authUrl = useConfigStore((s) => s.config.network.securityId.authUrl);
const setNetwork = useConfigStore((s) => s.setNetwork);
const handleToggle = useCallback((v: boolean) => {
setNetwork({ securityId: { enabled: v, authUrl: "" } });
}, [setNetwork]);
const handleUrlChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
setNetwork({ securityId: { enabled: true, authUrl: e.target.value } });
}, [setNetwork]);
2026-06-20 12:46:08 +08:00
return (
<div>
<PageHeader title="安全识别服务" desc="管理账户安全验证、设备识别与登录保护" />
2026-06-20 12:46:08 +08:00
<div className="space-y-6">
<div>
<SectionTitle>认证服务</SectionTitle>
2026-06-20 12:46:08 +08:00
<div className="space-y-3">
<SettingCard>
2026-06-20 12:46:08 +08:00
<SettingRow
label="启用第三方认证"
desc="使用自定义认证服务器替代 Microsoft 认证(适用于离线服务器)"
>
<Switch isSelected={enabled} onValueChange={handleToggle}>
<Switch.Control>
<Switch.Thumb />
</Switch.Control>
</Switch>
2026-06-20 12:46:08 +08:00
</SettingRow>
</SettingCard>
2026-06-20 12:46:08 +08:00
{enabled && (
<SettingCard>
2026-06-20 12:46:08 +08:00
<div className="space-y-2">
<p className="text-sm font-medium text-foreground">认证服务器 URL</p>
<p className="text-[13px] text-muted-foreground">输入第三方认证服务的地址</p>
<div className="flex items-center gap-2">
<ShieldCheck className="w-4 h-4 text-muted-foreground shrink-0" />
<Input
2026-06-20 12:46:08 +08:00
value={authUrl}
2026-06-28 03:37:07 +08:00
onChange={handleUrlChange}
2026-06-20 12:46:08 +08:00
placeholder="https://auth.example.com"
fullWidth
2026-06-20 12:46:08 +08:00
/>
</div>
</div>
</SettingCard>
2026-06-20 12:46:08 +08:00
)}
</div>
</div>
</div>
</div>
);
}