feat: 为安全页面的资源权限添加彩色图标

This commit is contained in:
monster committed 2026-12-01 17:16:16 +08:00
1 parent 63e5485a9d
commit e386d5fa19
1 file changed
+23 -2
+23 -2
View File
@@ -1,3 +1,5 @@
import { BanIcon, CheckmarkCircle02Icon, CircleQuestionMarkIcon } from "@hugeicons/core-free-icons"
import { HugeiconsIcon } from "@hugeicons/react"
import { createContext, useContext, useEffect, useRef, useState } from "react"
import { useTranslation } from "react-i18next"
import { Navigate } from "react-router-dom"
@@ -40,6 +42,23 @@ import { api } from "@/lib/api"
import { Button } from "@/components/ui/button"
type MemberPolicy = "allow" | "approval" | "deny"
const policyIcons = {
allow: { icon: CheckmarkCircle02Icon, color: "!text-green-700 dark:!text-green-400" },
approval: { icon: CircleQuestionMarkIcon, color: "!text-yellow-700 dark:!text-yellow-400" },
deny: { icon: BanIcon, color: "!text-red-700 dark:!text-red-400" },
} as const
function MemberPolicyLabel({ policy, label }: { policy: MemberPolicy; label: string }) {
const { icon, color } = policyIcons[policy]
return (
<span className="inline-flex items-center gap-1.5">
<HugeiconsIcon aria-hidden="true" icon={icon} strokeWidth={2} className={color} />
{label}
</span>
)
}
type MemberResource =
"models" | "knowledgeBases" | "skills" | "experts" | "mcp" | "rules"
@@ -116,7 +135,9 @@ function MemberPolicyOption({
className="min-w-28"
aria-label={label}
>
<SelectValue />
<SelectValue>
<MemberPolicyLabel policy={policy} label={t(`${policyLabels}.${policy}`)} />
</SelectValue>
</SelectTrigger>
<SelectContent
align="end"
@@ -126,7 +147,7 @@ function MemberPolicyOption({
<SelectGroup>
{items.map((item) => (
<SelectItem key={item.value} value={item.value}>
{item.label}
<MemberPolicyLabel policy={item.value} label={item.label} />
</SelectItem>
))}
</SelectGroup>