2026-06-28 03:37:07 +08:00
|
|
|
import { useCallback } from "react";
|
|
|
|
|
import { useConfigStore } from "@/stores/configStore";
|
2026-07-26 06:42:41 +08:00
|
|
|
import { Switch, Input } from "@heroui/react";
|
2026-06-20 12:46:08 +08:00
|
|
|
import { ShieldCheck } from "lucide-react";
|
2026-07-26 06:42:41 +08:00
|
|
|
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 (
|
2026-06-20 03:49:58 +08:00
|
|
|
<div>
|
2026-07-26 06:42:41 +08:00
|
|
|
<PageHeader title="安全识别服务" desc="管理账户安全验证、设备识别与登录保护" />
|
2026-06-20 12:46:08 +08:00
|
|
|
|
|
|
|
|
<div className="space-y-6">
|
|
|
|
|
<div>
|
2026-07-26 06:42:41 +08:00
|
|
|
<SectionTitle>认证服务</SectionTitle>
|
2026-06-20 12:46:08 +08:00
|
|
|
<div className="space-y-3">
|
2026-07-26 06:42:41 +08:00
|
|
|
<SettingCard>
|
2026-06-20 12:46:08 +08:00
|
|
|
<SettingRow
|
|
|
|
|
label="启用第三方认证"
|
|
|
|
|
desc="使用自定义认证服务器替代 Microsoft 认证(适用于离线服务器)"
|
|
|
|
|
>
|
2026-07-26 06:42:41 +08:00
|
|
|
<Switch isSelected={enabled} onValueChange={handleToggle}>
|
|
|
|
|
<Switch.Control>
|
|
|
|
|
<Switch.Thumb />
|
|
|
|
|
</Switch.Control>
|
|
|
|
|
</Switch>
|
2026-06-20 12:46:08 +08:00
|
|
|
</SettingRow>
|
2026-07-26 06:42:41 +08:00
|
|
|
</SettingCard>
|
2026-06-20 12:46:08 +08:00
|
|
|
|
|
|
|
|
{enabled && (
|
2026-07-26 06:42:41 +08:00
|
|
|
<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" />
|
2026-07-26 06:42:41 +08:00
|
|
|
<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"
|
2026-07-26 06:42:41 +08:00
|
|
|
fullWidth
|
2026-06-20 12:46:08 +08:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-07-26 06:42:41 +08:00
|
|
|
</SettingCard>
|
2026-06-20 12:46:08 +08:00
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-06-20 03:49:58 +08:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|