From 71620f85b7a550f115d3fd6a158ac1e27d3d3122 Mon Sep 17 00:00:00 2001 From: Pine Date: Wed, 26 Aug 2026 12:42:35 +0800 Subject: [PATCH] =?UTF-8?q?refactor(admin):=20=E7=A7=BB=E9=99=A4=E5=A4=9A?= =?UTF-8?q?=E8=BA=AB=E4=BB=BD=E7=BB=91=E5=AE=9A=E4=B8=8E=E5=88=87=E6=8D=A2?= =?UTF-8?q?=20=E2=80=94=E2=80=94=20=E5=8F=AA=E5=89=A9=E8=BF=90=E8=90=A5?= =?UTF-8?q?=E7=AB=AF/=E5=9B=AD=E5=8C=BA=E7=AB=AF=E5=8D=95=E4=B8=80?= =?UTF-8?q?=E8=BA=AB=E4=BB=BD=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 登录后直接以运营端进入(不再多身份选择弹窗/端口身份过滤) - 移除顶栏「切换身份」(IdentitySwitcher); 侧边/路由仍按 operator 域 - 园区端(园区账密)登录保持不变 --- src/components/layout/AppShell.tsx | 44 ++------------------------- src/pages/login/index.tsx | 48 ++++-------------------------- 2 files changed, 7 insertions(+), 85 deletions(-) diff --git a/src/components/layout/AppShell.tsx b/src/components/layout/AppShell.tsx index b01241c..7e2f288 100644 --- a/src/components/layout/AppShell.tsx +++ b/src/components/layout/AppShell.tsx @@ -16,12 +16,11 @@ import { DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; -import { hasPermission } from "@/lib/rbac"; export function AppShell() { - const { role, user, identities, currentIdentity, selectIdentity, logout } = useAuth(); + const { role, user, logout } = useAuth(); const groups = navForRole(role); - const roleLabel = currentIdentity?.name || role || "未选择"; + const roleLabel = role || "运营"; return (
@@ -77,7 +76,6 @@ export function AppShell() { 当前身份: {roleLabel}
-
@@ -121,41 +119,3 @@ function UserMenu({ ); } - -function IdentitySwitcher({ - identities, - current, - onSelect, -}: { - identities: { id: string; name?: string; role: string }[]; - current: { id: string } | null; - onSelect: (id: string) => void; -}) { - if (!identities || identities.length <= 1) return null; - return ( - - - - - - 选择端口身份 - - {identities.map((i) => ( - onSelect(i.id)} - > - - {i.name || i.role} - ({i.role}) - - - ))} - - - ); -} diff --git a/src/pages/login/index.tsx b/src/pages/login/index.tsx index 2767c38..f4ae01a 100644 --- a/src/pages/login/index.tsx +++ b/src/pages/login/index.tsx @@ -10,7 +10,7 @@ import { Label } from "@/components/ui/label"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { QRCodeSVG } from "@rc-component/qrcode"; import { Loader2, ShieldCheck, Lock, Smartphone, QrCode } from "lucide-react"; -import type { Identity, LoginResponse } from "@/types"; +import type { LoginResponse } from "@/types"; /** 二维码轮询登录(微信扫码 / 小程序扫码共用) */ function PollingQr({ @@ -91,7 +91,7 @@ function PollingQr({ } export default function LoginPage() { - const { isAuthed, login, loginWithResponse, selectIdentity } = useAuth(); + const { isAuthed, login, loginWithResponse } = useAuth(); const navigate = useNavigate(); const [mode, setMode] = React.useState<"platform" | "park">("platform"); const [pmode, setPmode] = React.useState<"account" | "sms" | "miniprogram">("account"); @@ -101,20 +101,17 @@ export default function LoginPage() { const [smsCode, setSmsCode] = React.useState(""); const [smsCountdown, setSmsCountdown] = React.useState(0); const [smsStub, setSmsStub] = React.useState(""); - const [pendingIds, setPendingIds] = React.useState([]); const [error, setError] = React.useState(null); const [loading, setLoading] = React.useState(false); - if (isAuthed && pendingIds.length === 0) return ; + if (isAuthed) return ; if (isParkUser()) return ; - /** 平台登录结果统一处理:只保留运营(operator)角色身份 */ + /** 平台登录结果:登录即以运营端进入(单一身份,无需选择/切换身份) */ async function applyPlatformResult(res: LoginResponse | null) { if (!res) return; clearParkAuth(); - const operatorIds = (res?.identities ?? []).filter((i) => i.role === "operator"); - if (operatorIds.length > 1) setPendingIds(operatorIds); - else navigate("/", { replace: true }); + navigate("/", { replace: true }); } async function onAccountSubmit(e: React.FormEvent) { @@ -168,41 +165,6 @@ export default function LoginPage() { } finally { setLoading(false); } } - async function onPick(id: string) { - setLoading(true); - try { - await selectIdentity(id); - navigate("/", { replace: true }); - } catch (err) { - setError(err instanceof Error ? err.message : "切换身份失败"); - } finally { - setLoading(false); - } - } - - if (pendingIds.length > 0) { - return ( - - - - 选择登录身份 - 该账号拥有多个端口身份,请选择进入 - - - {pendingIds.map((i) => ( - - ))} - - - - ); - } - return (