feat(admin): 新增后台商品管理与审核视图
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
import type { StatusMeta } from '@/features/admin/labels'
|
||||
|
||||
export const listingStatusMap: Record<string, StatusMeta> = {
|
||||
draft: { label: '草稿', tone: 'default' },
|
||||
published: { label: '已上架', tone: 'success' },
|
||||
rented: { label: '租用中', tone: 'cyan' },
|
||||
offline: { label: '已下架', tone: 'default' },
|
||||
completed: { label: '已完成', tone: 'success' },
|
||||
abnormal: { label: '异常', tone: 'red' },
|
||||
sealed: { label: '已封存', tone: 'purple' },
|
||||
}
|
||||
|
||||
export const listingReviewStatusMap: Record<string, StatusMeta> = {
|
||||
none: { label: '未提交', tone: 'default' },
|
||||
pending: { label: '待审核', tone: 'gold' },
|
||||
approved: { label: '已通过', tone: 'success' },
|
||||
rejected: { label: '已拒绝', tone: 'red' },
|
||||
}
|
||||
|
||||
export const listingStatusOptions = Object.entries(listingStatusMap).map(([value, meta]) => ({
|
||||
value,
|
||||
label: meta.label,
|
||||
}))
|
||||
|
||||
export const listingReviewStatusOptions = Object.entries(listingReviewStatusMap).map(
|
||||
([value, meta]) => ({ value, label: meta.label })
|
||||
)
|
||||
|
||||
export function listingStatusMeta(value?: string | null): StatusMeta {
|
||||
if (!value) return { label: '—', tone: 'default' }
|
||||
return listingStatusMap[value] ?? { label: value, tone: 'default' }
|
||||
}
|
||||
|
||||
export function listingReviewStatusMeta(value?: string | null): StatusMeta {
|
||||
if (!value) return { label: '—', tone: 'default' }
|
||||
return listingReviewStatusMap[value] ?? { label: value, tone: 'default' }
|
||||
}
|
||||
|
||||
const assetFieldLabels: Record<string, string> = {
|
||||
season_insurance: '赛季保险',
|
||||
stamina_level: '体力等级',
|
||||
load_level: '负重等级',
|
||||
awm_bullets: 'AWM 子弹',
|
||||
level6_helmets: '六级头盔',
|
||||
level6_armor: '六级护甲',
|
||||
skin_group: '皮肤系列',
|
||||
skin_names: '皮肤名称',
|
||||
online_time: '在线时间',
|
||||
online_time_text: '在线时间',
|
||||
rank_level: '段位',
|
||||
haf_coin_amount: '哈夫币',
|
||||
}
|
||||
|
||||
export function assetFieldLabel(key: string) {
|
||||
return assetFieldLabels[key] ?? key
|
||||
}
|
||||
|
||||
function formatOnlineTime(value: unknown) {
|
||||
if (!value || typeof value !== 'object') return ''
|
||||
const item = value as { start?: unknown; end?: unknown }
|
||||
const start = typeof item.start === 'string' ? item.start : ''
|
||||
const end = typeof item.end === 'string' ? item.end : ''
|
||||
if (!start && !end) return ''
|
||||
return `${start || '—'} 至 ${end || '—'}`
|
||||
}
|
||||
|
||||
export function formatAssetValue(key: string, value: unknown): string {
|
||||
if (value == null || value === '') return '—'
|
||||
if (key === 'online_time') {
|
||||
const text = formatOnlineTime(value)
|
||||
if (text) return text
|
||||
}
|
||||
if (Array.isArray(value)) {
|
||||
return value.map(item => (typeof item === 'object' ? JSON.stringify(item) : String(item))).join('、')
|
||||
}
|
||||
if (typeof value === 'object') {
|
||||
const text = formatOnlineTime(value)
|
||||
if (text) return text
|
||||
return JSON.stringify(value)
|
||||
}
|
||||
return String(value)
|
||||
}
|
||||
Reference in New Issue
Block a user