"use client"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { isNativeBossApp, persistNativeSessionSnapshot, } from "@/lib/boss-app-client"; type LoginResult = { ok: boolean; message: string; account?: string; displayName?: string; sessionExpiresAt?: string; restoreToken?: string; }; function resolvePostLoginPath() { return window.location.hostname === "admin.boss.hyzq.net" ? "/" : "/conversations"; } async function waitForLoginSessionReady(nativeClient: boolean) { for (let attempt = 0; attempt < 5; attempt += 1) { const response = await fetch("/api/auth/session", { cache: "no-store", headers: nativeClient ? { "x-boss-native-app": "1" } : undefined, }).catch(() => null); if (response?.ok) return true; await new Promise((resolve) => window.setTimeout(resolve, 120)); } return false; } export function EnterpriseAdminLoginShell() { const router = useRouter(); const [account, setAccount] = useState(""); const [password, setPassword] = useState(""); const [remember, setRemember] = useState(true); const [message, setMessage] = useState(""); const [submitting, setSubmitting] = useState(false); async function submit() { if (!account.trim() || !password) { setMessage("请填写账号和密码。"); return; } setSubmitting(true); setMessage(""); const nativeClient = await isNativeBossApp(); try { const response = await fetch("/api/auth/login", { method: "POST", headers: { "Content-Type": "application/json", ...(nativeClient ? { "x-boss-native-app": "1" } : {}), }, body: JSON.stringify({ account, password, method: "password", }), }); const result = (await response.json()) as LoginResult; if (!result.ok) { setMessage(result.message); return; } if ( nativeClient && result.restoreToken && result.account && result.displayName && result.sessionExpiresAt ) { await persistNativeSessionSnapshot({ restoreToken: result.restoreToken, account: result.account, displayName: result.displayName, expiresAt: result.sessionExpiresAt, lastSyncedAt: new Date().toISOString(), }).catch(() => undefined); } await waitForLoginSessionReady(nativeClient); const targetPath = resolvePostLoginPath(); router.replace(targetPath, { scroll: false }); router.refresh(); window.setTimeout(() => { if (window.location.pathname !== targetPath) { window.location.replace(targetPath); } }, 180); } catch { setMessage("登录链路发生异常,请重试。"); } finally { setSubmitting(false); } } return (
B
Boss 企业管理后台
统一管理企业账号、电脑节点、Skill 与风险
平台级权限 · 企业账号 · 设备治理 · 风险审计

企业级电脑与 Agent 统一治理入口

面向 To B 交付场景,集中完成企业开通、账号授权、设备接入、Skill 分发与风险处置。

{["企业开通", "设备授权", "风险治理"].map((item) => (
{item}
))}
仅限授权管理员访问。所有登录行为会进入审计链路,用于企业安全、客户成功和异常追踪。
B

Boss 企业管理后台

统一管理企业账号、电脑节点、Skill 与风险

登录企业后台

仅限授权管理员访问

{ event.preventDefault(); void submit(); }} >
HTTPS 安全会话
{message ? (
{message}
) : null}
登录代表你正在访问企业级管理后台。请确认账号权限来自企业或平台管理员授权。
); }