SxIdentityUserBar UI 设计规范

自动生成时间: 2026-02-04 组件路径: src/NextUI.Blazor/Components/Identity/SxIdentityUserBar.razor

1. 组件概述

  • 组件包含 15 个参数,0 个回调,1 个公开方法。
  • 内部组合组件:SxLoginButton, SxMenuItem, SxUserBar, SxUserSwitcher。
  • 依赖注入: NavigationManager Nav。
  • 实现接口: IDisposable。

2. 组件模式

模式 条件 说明
条件渲染 !User.IsAuthenticated 影响局部渲染块
条件渲染 ShowSwitchUser && IsMockMode 影响局部渲染块
条件渲染 ShowAdminEntry && IsAdmin 影响局部渲染块
条件渲染 IsMockMode 影响局部渲染块

3. 表单字段

字段组件 绑定
- -

4. 操作按钮

外观 动作/链接 禁用条件
- - -

5. 验证规则

未检测到显式验证标记。

6. 状态与流程

内部状态字段: 未检测到明确状态字段。

7. 公共 API

7.1 Parameters

参数 类型 默认值 说明
LoginButtonAppearance ButtonAppearance ButtonAppearance.Accent Appearance of the login button.
LoginButtonSize ControlSize ControlSize.Medium Size of the login button.
ShowSwitchUser bool true Whether to show the "Switch User" menu item (only in Mock mode).
SwitchUserText string "Switch User" Text for the "Switch User" menu item.
ShowAdminEntry bool true Whether to show the "Admin" menu item (only for users with admin role).
AdminText string "Admin Console" Text for the "Admin" menu item.
AdminRoute string "/admin" Route to navigate to for admin console.
AdminRole string "admin" Role required to see the admin entry.
ShowSettings bool true Whether to show the settings menu item.
ShowQuickSettings bool true Whether to show quick settings (theme/language).
ShowLogout bool true Whether to show the logout menu item.
UseGlassEffect bool true Whether to use glass effect styling.
AvatarSize ControlSize ControlSize.Medium Size of the avatar.
Placement MenuPlacement MenuPlacement.Top Menu placement.
Presence AvatarPresence AvatarPresence.Online User presence indicator.

7.2 Public Methods

  • Dispose: void

7.3 Events/Callbacks

无回调事件。

8. 典型使用场景 (Use Cases)

8.1 UC-1: 基础渲染

  1. 组件渲染默认状态
  2. 关键区域可见
  3. 无异常

9. 状态不变性测试 (State Invariants)

  • 同一参数重复设置不应触发非必要 UI 改变
  • 与表单字段无关的操作不应影响字段值

10. 测试检查点

  • 条件 !User.IsAuthenticated 下渲染正确
  • 条件 ShowSwitchUser && IsMockMode 下渲染正确
  • 条件 ShowAdminEntry && IsAdmin 下渲染正确
  • 条件 IsMockMode 下渲染正确

11. Fluent UI 对齐

未在官方 Fluent UI Blazor 组件目录中找到直接对应项(以官方 demo/docs 目录为准)。

12. 参考文档摘要

  • docs/IDENTITY-DESIGN.md: NextUI 用户身份与认证设计方案 ## 一、问题分析
  • docs/plans/2026-02-03-workbench-restructure-implementation.md: NextUI Workbench 重构实施计划 > For Claude: REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.

13. 规范合规检查

  • 未检测到明显硬编码颜色/px。

14. 变更历史

  • 2026-02-04: 深度分析填充规范。