task-262(admin.html观感对齐): 店铺密钥页对齐(三态白名单药丸+悬停详情/修改时间列/编辑令牌留空沿用/删除文案)
This commit is contained in:
@@ -24,6 +24,26 @@ export function normalizeIpWhitelistStatus(value: unknown): IpWhitelistStatus {
|
||||
return (IP_WHITELIST_VALUES.includes(textValue) ? textValue : 'UNKNOWN') as IpWhitelistStatus
|
||||
}
|
||||
|
||||
export interface WhitelistStatusMeta {
|
||||
/** 展示文案(对齐 admin:正常/未加白名单/未检测)。 */
|
||||
label: string
|
||||
/** Element tag 语义色。 */
|
||||
tag: 'success' | 'danger' | 'info'
|
||||
}
|
||||
|
||||
/** admin 三态文案:ALLOWED→正常、BLOCKED→未加白名单、UNKNOWN→未检测。 */
|
||||
const SHOP_KEY_STATUS_META: Record<IpWhitelistStatus, WhitelistStatusMeta> = {
|
||||
ALLOWED: { label: '正常', tag: 'success' },
|
||||
BLOCKED: { label: '未加白名单', tag: 'danger' },
|
||||
UNKNOWN: { label: '未检测', tag: 'info' },
|
||||
}
|
||||
|
||||
/** 白名单状态 → 展示元数据;未知回「未检测」。 */
|
||||
export function whitelistStatusMeta(status: IpWhitelistStatus | null | undefined): WhitelistStatusMeta {
|
||||
const key = normalizeIpWhitelistStatus(status)
|
||||
return SHOP_KEY_STATUS_META[key] || SHOP_KEY_STATUS_META.UNKNOWN
|
||||
}
|
||||
|
||||
/** 解析单条店铺密钥行;缺 id 视为无效。 */
|
||||
export function toShopKeyItem(raw: unknown): ShopKeyItem | null {
|
||||
if (!raw || typeof raw !== 'object') return null
|
||||
|
||||
Reference in New Issue
Block a user