菜单配置

菜单在 console/src/config/menu.ts 中配置。

数据结构

interface MenuItem {
  index: string          // 路由路径
  title: string          // 显示名称
  icon: LucideIcon       // 图标(Lucide React)
  userRoles?: string[]   // 系统角色过滤(可选)
  tenantRoles?: string[] // 组织角色过滤(可选)
}

interface MenuGroup {
  title: string          // 分组标题
  children: MenuItem[]
}

配置示例

export const menuConfig: MenuGroup[] = [
  {
    title: "Dashboard",
    children: [
      { index: "/", title: "Overview", icon: LayoutDashboard },
    ],
  },
  {
    title: "Organization",
    children: [
      { index: "/subscription", title: "Subscription", icon: CreditCard },
      { index: "/credits", title: "Credits", icon: Coins },
      { index: "/invoices", title: "Invoices", icon: FileText },
      { index: "/org/settings", title: "Settings", icon: Settings },
    ],
  },
  {
    title: "Management",
    children: [
      { index: "/admin/users", title: "Users", icon: Users, userRoles: ["owner"] },
    ],
  },
]

角色过滤

配置效果
不设置所有人可见
userRoles: ["owner"]仅系统管理员(users.role = owner
tenantRoles: ["owner"]仅组织所有者(tenant_members.role = owner
两者都设同时满足才可见

动态过滤

菜单还会根据 website 配置动态过滤:

图标

使用 Lucide React 图标库,在文件顶部导入:

import { LayoutDashboard, Blocks, Users } from "lucide-react"