@ploykit/ui 0.6.0 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AppProviders.js +2 -2
- package/dist/components/ConfirmDialog.js +1 -1
- package/dist/components/CronInput.js +3 -3
- package/dist/components/DataTable.js +4 -4
- package/dist/components/FormField.js +1 -1
- package/dist/components/ImpersonationBanner.js +1 -1
- package/dist/components/NotificationBell.js +1 -1
- package/dist/components/OnboardingChecklist.js +3 -3
- package/dist/components/Page.js +2 -2
- package/dist/components/ReauthDialog.js +4 -4
- package/dist/components/SecretModal.js +2 -2
- package/dist/components/SettingsCard.js +2 -2
- package/dist/components/SiteBanner.js +1 -1
- package/dist/components/SiteBannerLayer.js +1 -1
- package/dist/components/StatusBadge.js +1 -1
- package/dist/components/UserMenu.js +3 -3
- package/dist/components/WorkspaceSwitcher.js +7 -7
- package/dist/components/ui/alert-dialog.js +2 -2
- package/dist/components/ui/avatar.js +1 -1
- package/dist/components/ui/badge.js +1 -1
- package/dist/components/ui/breadcrumb.js +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/card.js +1 -1
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/dialog.js +2 -2
- package/dist/components/ui/dropdown-menu.js +1 -1
- package/dist/components/ui/empty.js +1 -1
- package/dist/components/ui/field.js +3 -3
- package/dist/components/ui/input.js +1 -1
- package/dist/components/ui/label.js +1 -1
- package/dist/components/ui/popover.js +1 -1
- package/dist/components/ui/progress.js +1 -1
- package/dist/components/ui/select.js +1 -1
- package/dist/components/ui/separator.js +1 -1
- package/dist/components/ui/sheet.js +2 -2
- package/dist/components/ui/sidebar.js +8 -8
- package/dist/components/ui/skeleton.js +1 -1
- package/dist/components/ui/switch.js +1 -1
- package/dist/components/ui/tabs.js +1 -1
- package/dist/components/ui/textarea.js +1 -1
- package/dist/components/ui/tooltip.js +1 -1
- package/dist/index.js +78 -78
- package/dist/layouts/AppShell.js +4 -4
- package/dist/layouts/SettingsShell.js +4 -4
- package/dist/pages/LoginPage.js +5 -5
- package/dist/pages/account/NotificationPreferencesPage.js +3 -3
- package/dist/pages/account/ProfileSettingsPage.js +9 -9
- package/dist/pages/account/SecuritySettingsPage.js +13 -13
- package/dist/pages/account/TokensPage.js +12 -12
- package/dist/pages/admin/AdminSettingsPage.js +11 -11
- package/dist/pages/admin/AdminShell.js +3 -3
- package/dist/pages/admin/AuditPage.js +8 -8
- package/dist/pages/admin/OrdersPage.js +12 -12
- package/dist/pages/admin/OverviewPage.js +13 -13
- package/dist/pages/admin/SSOPage.js +6 -6
- package/dist/pages/admin/UserDetailPage.js +13 -13
- package/dist/pages/admin/UsersPage.js +13 -13
- package/dist/pages/admin/WebhookDeliveriesPage.js +9 -9
- package/dist/pages/admin/WorkspaceDetailPage.js +14 -14
- package/dist/pages/admin/WorkspacesPage.js +9 -9
- package/dist/pages/admin/shared.js +1 -1
- package/dist/pages/auth/ForgotPasswordPage.js +4 -4
- package/dist/pages/auth/InviteAcceptPage.js +6 -6
- package/dist/pages/auth/RegisterPage.js +7 -7
- package/dist/pages/auth/ResetPasswordPage.js +5 -5
- package/dist/pages/auth/VerifyEmailPage.js +3 -3
- package/dist/pages/workspace/BillingPage.js +11 -11
- package/dist/pages/workspace/BillingSuccessPage.js +2 -2
- package/dist/pages/workspace/MembersPage.js +15 -15
- package/dist/pages/workspace/RolePermissionsPage.js +9 -9
- package/dist/pages/workspace/SchedulesPage.js +12 -12
- package/dist/pages/workspace/UsagePage.js +6 -6
- package/dist/pages/workspace/WebhooksPage.js +16 -16
- package/dist/pages/workspace/WorkspaceAuditPage.js +7 -7
- package/dist/pages/workspace/WorkspaceGeneralPage.js +9 -9
- package/package.json +6 -5
- package/src/AppProviders.tsx +29 -0
- package/src/components/ConfirmDialog.tsx +77 -0
- package/src/components/CronInput.tsx +195 -0
- package/src/components/DataTable.tsx +152 -0
- package/src/components/ErrorBoundary.tsx +46 -0
- package/src/components/FormField.tsx +56 -0
- package/src/components/ImpersonationBanner.tsx +23 -0
- package/src/components/NotificationBell.tsx +135 -0
- package/src/components/OnboardingChecklist.tsx +114 -0
- package/src/components/Page.tsx +67 -0
- package/src/components/ReauthDialog.tsx +94 -0
- package/src/components/SecretModal.tsx +147 -0
- package/src/components/SettingsCard.tsx +39 -0
- package/src/components/SiteBanner.tsx +32 -0
- package/src/components/SiteBannerLayer.tsx +29 -0
- package/src/components/StatusBadge.tsx +12 -0
- package/src/components/UserMenu.tsx +103 -0
- package/src/components/WorkspaceSwitcher.tsx +159 -0
- package/src/components/__tests__/AppProviders.test.tsx +111 -0
- package/src/components/__tests__/CronInput.test.tsx +180 -0
- package/src/components/__tests__/DataTable.test.tsx +208 -0
- package/src/components/__tests__/ErrorBoundary.test.tsx +61 -0
- package/src/components/__tests__/ImpersonationBanner.test.tsx +59 -0
- package/src/components/__tests__/NotificationBell.test.tsx +207 -0
- package/src/components/__tests__/OnboardingChecklist.test.tsx +97 -0
- package/src/components/__tests__/SecretModal.test.tsx +112 -0
- package/src/components/__tests__/SiteBannerLayer.test.tsx +44 -0
- package/src/components/__tests__/UserMenu.test.tsx +98 -0
- package/src/components/__tests__/WorkspaceSwitcher.test.tsx +162 -0
- package/src/components/__tests__/form.test.tsx +133 -0
- package/src/components/__tests__/semantic-tokens.test.ts +41 -0
- package/src/components/__tests__/smoke.test.tsx +11 -0
- package/src/components/__tests__/toast.test.tsx +27 -0
- package/src/components/toast.tsx +23 -0
- package/src/components/ui/__tests__/alert-dialog.test.tsx +66 -0
- package/src/components/ui/__tests__/avatar.test.tsx +30 -0
- package/src/components/ui/__tests__/checkbox.test.tsx +18 -0
- package/src/components/ui/__tests__/dropdown-menu.test.tsx +33 -0
- package/src/components/ui/__tests__/field.test.tsx +43 -0
- package/src/components/ui/__tests__/overlay-size.test.tsx +84 -0
- package/src/components/ui/__tests__/popover.test.tsx +32 -0
- package/src/components/ui/__tests__/progress.test.tsx +24 -0
- package/src/components/ui/__tests__/select-callback.test.tsx +72 -0
- package/src/components/ui/__tests__/select.test.tsx +48 -0
- package/src/components/ui/__tests__/sidebar.test.tsx +121 -0
- package/src/components/ui/__tests__/stock-mirror.test.ts +39 -0
- package/src/components/ui/__tests__/subpath.test.tsx +38 -0
- package/src/components/ui/__tests__/switch.test.tsx +24 -0
- package/src/components/ui/__tests__/tabs.test.tsx +24 -0
- package/src/components/ui/__tests__/textarea.test.tsx +41 -0
- package/src/components/ui/alert-dialog.tsx +187 -0
- package/src/components/ui/avatar.tsx +108 -0
- package/src/components/ui/badge.tsx +51 -0
- package/src/components/ui/breadcrumb.tsx +124 -0
- package/src/components/ui/button.tsx +57 -0
- package/src/components/ui/card.tsx +102 -0
- package/src/components/ui/checkbox.tsx +28 -0
- package/src/components/ui/dialog.tsx +166 -0
- package/src/components/ui/dropdown-menu.tsx +265 -0
- package/src/components/ui/empty.tsx +103 -0
- package/src/components/ui/field.tsx +238 -0
- package/src/components/ui/input.tsx +19 -0
- package/src/components/ui/label.tsx +17 -0
- package/src/components/ui/popover.tsx +89 -0
- package/src/components/ui/progress.tsx +82 -0
- package/src/components/ui/select.tsx +235 -0
- package/src/components/ui/separator.tsx +24 -0
- package/src/components/ui/sheet.tsx +146 -0
- package/src/components/ui/sidebar.tsx +723 -0
- package/src/components/ui/skeleton.tsx +13 -0
- package/src/components/ui/switch.tsx +29 -0
- package/src/components/ui/tabs.tsx +79 -0
- package/src/components/ui/textarea.tsx +26 -0
- package/src/components/ui/tooltip.tsx +63 -0
- package/src/dev.css +1 -0
- package/src/hooks/use-mobile.ts +19 -0
- package/src/index.ts +150 -0
- package/src/layouts/AppShell.tsx +163 -0
- package/src/layouts/AuthShell.tsx +24 -0
- package/src/layouts/SettingsShell.tsx +129 -0
- package/src/layouts/__tests__/AppShell.test.tsx +163 -0
- package/src/layouts/__tests__/SettingsShell.test.tsx +146 -0
- package/src/lib/__tests__/api-error.test.ts +163 -0
- package/src/lib/__tests__/utils.test.ts +21 -0
- package/src/lib/api-error.ts +98 -0
- package/src/lib/utils.ts +109 -0
- package/src/pages/LandingPage.tsx +88 -0
- package/src/pages/LoginPage.tsx +291 -0
- package/src/pages/__tests__/LandingPage.test.tsx +58 -0
- package/src/pages/__tests__/LoginPage.test.tsx +229 -0
- package/src/pages/__tests__/RegisterPage.test.tsx +138 -0
- package/src/pages/__tests__/ssr-smoke.test.tsx +99 -0
- package/src/pages/account/NotificationPreferencesPage.tsx +138 -0
- package/src/pages/account/ProfileSettingsPage.tsx +189 -0
- package/src/pages/account/SecuritySettingsPage.tsx +214 -0
- package/src/pages/account/TokensPage.tsx +211 -0
- package/src/pages/account/__tests__/NotificationPreferencesPage.test.tsx +150 -0
- package/src/pages/account/__tests__/ProfileSettingsPage.test.tsx +173 -0
- package/src/pages/account/__tests__/SecuritySettingsPage.test.tsx +212 -0
- package/src/pages/account/__tests__/TokensPage.test.tsx +180 -0
- package/src/pages/admin/AdminSettingsPage.tsx +564 -0
- package/src/pages/admin/AdminShell.tsx +199 -0
- package/src/pages/admin/AuditPage.tsx +338 -0
- package/src/pages/admin/OrdersPage.tsx +642 -0
- package/src/pages/admin/OverviewPage.tsx +559 -0
- package/src/pages/admin/SSOPage.tsx +166 -0
- package/src/pages/admin/UserDetailPage.tsx +641 -0
- package/src/pages/admin/UsersPage.tsx +462 -0
- package/src/pages/admin/WebhookDeliveriesPage.tsx +318 -0
- package/src/pages/admin/WorkspaceDetailPage.tsx +551 -0
- package/src/pages/admin/WorkspacesPage.tsx +299 -0
- package/src/pages/admin/__tests__/AdminSettingsPage.test.tsx +260 -0
- package/src/pages/admin/__tests__/OrdersPageMarkPaid.test.tsx +207 -0
- package/src/pages/admin/__tests__/OverviewPageActivity.test.tsx +213 -0
- package/src/pages/admin/__tests__/SSOPage.test.tsx +128 -0
- package/src/pages/admin/__tests__/UsersPageActions.test.tsx +188 -0
- package/src/pages/admin/__tests__/WorkspaceDetailPageTransfer.test.tsx +170 -0
- package/src/pages/admin/__tests__/WorkspacesPagePlans.test.tsx +138 -0
- package/src/pages/admin/shared.ts +42 -0
- package/src/pages/auth/ForgotPasswordPage.tsx +83 -0
- package/src/pages/auth/InviteAcceptPage.tsx +105 -0
- package/src/pages/auth/RegisterPage.tsx +204 -0
- package/src/pages/auth/ResetPasswordPage.tsx +150 -0
- package/src/pages/auth/VerifyEmailPage.tsx +76 -0
- package/src/pages/auth/__tests__/ForgotPasswordPage.test.tsx +67 -0
- package/src/pages/auth/__tests__/InviteAcceptPage.test.tsx +86 -0
- package/src/pages/auth/__tests__/ResetPasswordPage.test.tsx +115 -0
- package/src/pages/auth/__tests__/VerifyEmailPage.test.tsx +74 -0
- package/src/pages/workspace/BillingPage.tsx +361 -0
- package/src/pages/workspace/BillingSuccessPage.tsx +115 -0
- package/src/pages/workspace/MembersPage.tsx +568 -0
- package/src/pages/workspace/RolePermissionsPage.tsx +202 -0
- package/src/pages/workspace/SchedulesPage.tsx +387 -0
- package/src/pages/workspace/UsagePage.tsx +207 -0
- package/src/pages/workspace/WebhooksPage.tsx +506 -0
- package/src/pages/workspace/WorkspaceAuditPage.tsx +229 -0
- package/src/pages/workspace/WorkspaceGeneralPage.tsx +184 -0
- package/src/pages/workspace/__tests__/BillingPage.test.tsx +302 -0
- package/src/pages/workspace/__tests__/BillingSuccessPage.test.tsx +134 -0
- package/src/pages/workspace/__tests__/MembersPage.test.tsx +347 -0
- package/src/pages/workspace/__tests__/RolePermissionsPage.test.tsx +138 -0
- package/src/pages/workspace/__tests__/SchedulesPage.test.tsx +239 -0
- package/src/pages/workspace/__tests__/UsagePage.test.tsx +223 -0
- package/src/pages/workspace/__tests__/WebhooksPage.test.tsx +309 -0
- package/src/pages/workspace/__tests__/WorkspaceAuditPage.test.tsx +112 -0
- package/src/pages/workspace/__tests__/WorkspaceGeneralPage.test.tsx +164 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
|
|
2
|
+
import { Link } from 'react-router'
|
|
3
|
+
import { PageHeader, PageLoading, PageError, PageEmpty } from '../../components/Page'
|
|
4
|
+
import { Badge } from '../../components/ui/badge'
|
|
5
|
+
import { Card, CardHeader, CardTitle, CardAction, CardContent } from '../../components/ui/card'
|
|
6
|
+
import {
|
|
7
|
+
Progress, ProgressLabel, ProgressValue,
|
|
8
|
+
} from '../../components/ui/progress'
|
|
9
|
+
import { DataTable, type Column } from '../../components/DataTable'
|
|
10
|
+
import { useUsage, type PKUsageItem } from '@ploykit/hooks'
|
|
11
|
+
import { apiErrorMessage } from '../../lib/api-error'
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
const NEAR_FULL_PCT = 80
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
const DIM_LABEL: Record<string, string> = {
|
|
18
|
+
tasks_monthly: '任务数(本月)',
|
|
19
|
+
workspaces: '工作区数',
|
|
20
|
+
seats: '成员席位',
|
|
21
|
+
webhooks: 'Webhook 订阅数',
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function dimLabel(key: string): string {
|
|
25
|
+
return DIM_LABEL[key] ?? key
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
function fmtNum(n: number): string {
|
|
30
|
+
return n.toLocaleString('zh-CN')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
interface ReservationDetail {
|
|
35
|
+
id: string
|
|
36
|
+
amount: number
|
|
37
|
+
status: string
|
|
38
|
+
expires_at: string
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
export type UsageItem = PKUsageItem & { reserved?: number; reservations?: ReservationDetail[] }
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
const RESERVATION_STATUS_LABEL: Record<string, string> = {
|
|
46
|
+
reserved: '预留中',
|
|
47
|
+
settled: '已结算',
|
|
48
|
+
released: '已释放',
|
|
49
|
+
expired: '已过期',
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function reservationStatusLabel(status: string): string {
|
|
53
|
+
return RESERVATION_STATUS_LABEL[status] ?? status
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
function formatExpires(iso: string): string {
|
|
58
|
+
return iso.slice(0, 16).replace('T', ' ')
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
function SegmentedProgress({ item, reserved, total }: { item: UsageItem; reserved: number; total: number }) {
|
|
63
|
+
const base = Math.max(total, 1)
|
|
64
|
+
const usedPct = Math.min(100, Math.round(((item.used + item.granted) / base) * 100))
|
|
65
|
+
const reservedPct = Math.min(100 - usedPct, Math.round((reserved / base) * 100))
|
|
66
|
+
const now = item.used + item.granted + reserved
|
|
67
|
+
return (
|
|
68
|
+
<div
|
|
69
|
+
data-slot="progress"
|
|
70
|
+
role="progressbar"
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
aria-label={`${dimLabel(item.key)} 用量`}
|
|
75
|
+
aria-valuemin={0}
|
|
76
|
+
aria-valuemax={Math.max(total, now)}
|
|
77
|
+
aria-valuenow={now}
|
|
78
|
+
aria-valuetext={`已用 ${fmtNum(item.used)}${item.granted > 0 ? `(另获赠 ${fmtNum(item.granted)})` : ''},预留中 ${fmtNum(reserved)},上限 ${fmtNum(total)}`}
|
|
79
|
+
className="flex flex-wrap gap-3"
|
|
80
|
+
>
|
|
81
|
+
<div className="relative h-1.5 w-full overflow-hidden rounded-full bg-muted">
|
|
82
|
+
<div data-testid="progress-indicator-used" data-slot="progress-indicator-used" className="absolute inset-y-0 left-0 bg-primary transition-all" style={{ width: `${usedPct}%` }} />
|
|
83
|
+
<div data-testid="progress-indicator-reserved" data-slot="progress-indicator-reserved" className="absolute inset-y-0 bg-primary/40 transition-all" style={{ width: `${reservedPct}%`, left: `${usedPct}%` }} />
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
const RESERVATION_COLUMNS: Column<ReservationDetail>[] = [
|
|
91
|
+
{ key: 'amount', header: '数量' },
|
|
92
|
+
{ key: 'status', header: '状态', render: (r) => reservationStatusLabel(r.status) },
|
|
93
|
+
{ key: 'expires_at', header: '到期时间', render: (r) => formatExpires(r.expires_at) },
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
function UsageCard({ item }: { item: UsageItem }) {
|
|
97
|
+
const unlimited = item.limit < 0
|
|
98
|
+
|
|
99
|
+
const reserved = item.reserved ?? 0
|
|
100
|
+
const hasReserved = reserved > 0
|
|
101
|
+
const total = unlimited ? Math.max(item.used + reserved, 1) : item.limit
|
|
102
|
+
const pct = unlimited
|
|
103
|
+
? Math.min(100, Math.round(((item.used + reserved) / Math.max(total, 10)) * 100))
|
|
104
|
+
: Math.min(100, Math.round(((item.used + item.granted + reserved) / Math.max(total, 1)) * 100))
|
|
105
|
+
|
|
106
|
+
const committed = item.used + item.granted + reserved
|
|
107
|
+
const full = !unlimited && committed >= item.limit
|
|
108
|
+
const nearFull = !unlimited && !full && pct >= NEAR_FULL_PCT
|
|
109
|
+
|
|
110
|
+
const valueText = `${fmtNum(item.used)}${item.granted > 0 ? ` (+${fmtNum(item.granted)})` : ''} / ${unlimited ? '∞' : fmtNum(total)}`
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<Card size="sm">
|
|
114
|
+
<CardHeader>
|
|
115
|
+
{/* B2:卡题中文标签,原始 API 键(tasks_monthly 等)仅留 title 悬停辅助,不再入正文。 */}
|
|
116
|
+
<CardTitle title={DIM_LABEL[item.key] ? item.key : undefined}>{dimLabel(item.key)}</CardTitle>
|
|
117
|
+
{unlimited && <CardAction><Badge variant="secondary">不限量</Badge></CardAction>}
|
|
118
|
+
{!unlimited && full && <CardAction><Badge variant="destructive">已用尽</Badge></CardAction>}
|
|
119
|
+
</CardHeader>
|
|
120
|
+
<CardContent>
|
|
121
|
+
{hasReserved ? (
|
|
122
|
+
<>
|
|
123
|
+
<SegmentedProgress item={item} reserved={reserved} total={total} />
|
|
124
|
+
<p className="mt-1.5 text-sm text-muted-foreground">
|
|
125
|
+
已用 <span className="font-medium text-foreground tabular-nums">{fmtNum(item.used)}{item.granted > 0 ? ` (+${fmtNum(item.granted)})` : ''}</span>
|
|
126
|
+
{' · 预留中 '}<span className="font-medium text-foreground tabular-nums">{fmtNum(reserved)}</span>
|
|
127
|
+
{` / ${unlimited ? '∞' : fmtNum(total)}`}
|
|
128
|
+
</p>
|
|
129
|
+
</>
|
|
130
|
+
) : (
|
|
131
|
+
<Progress value={pct}>
|
|
132
|
+
<ProgressLabel>{dimLabel(item.key)}</ProgressLabel>
|
|
133
|
+
<ProgressValue>{() => valueText}</ProgressValue>
|
|
134
|
+
</Progress>
|
|
135
|
+
)}
|
|
136
|
+
{!unlimited && (full || nearFull) && (
|
|
137
|
+
<p className="mt-2 text-xs text-muted-foreground">
|
|
138
|
+
{/* G5 后文案:不写"超额操作将被拒绝"的硬承诺(账号级维度的硬闸在
|
|
139
|
+
装配方策略,工作区桶维度才是 402 直拒),统一引导升级。 */}
|
|
140
|
+
{full ? `该维度配额已用尽${hasReserved ? '(含预留中)' : ''},可升级套餐提高上限。` : '该维度配额即将用尽。'}
|
|
141
|
+
<Link
|
|
142
|
+
to="/settings/workspace/billing"
|
|
143
|
+
className="ml-1 inline-flex items-center py-1.5 -my-1.5 text-primary underline-offset-2 hover:underline"
|
|
144
|
+
>
|
|
145
|
+
升级套餐
|
|
146
|
+
</Link>
|
|
147
|
+
</p>
|
|
148
|
+
)}
|
|
149
|
+
{hasReserved && (item.reservations?.length ?? 0) > 0 && (
|
|
150
|
+
<details className="mt-3 group" data-testid="reservation-details">
|
|
151
|
+
<summary className="cursor-pointer select-none text-xs text-muted-foreground hover:text-foreground">
|
|
152
|
+
预留明细({item.reservations!.length} 笔)
|
|
153
|
+
</summary>
|
|
154
|
+
<div className="mt-2">
|
|
155
|
+
<DataTable
|
|
156
|
+
columns={RESERVATION_COLUMNS}
|
|
157
|
+
rows={item.reservations!}
|
|
158
|
+
rowKey={(r) => r.id}
|
|
159
|
+
/>
|
|
160
|
+
</div>
|
|
161
|
+
</details>
|
|
162
|
+
)}
|
|
163
|
+
</CardContent>
|
|
164
|
+
</Card>
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface UsagePageProps {}
|
|
169
|
+
|
|
170
|
+
export function UsagePage(_props: UsagePageProps = {}) {
|
|
171
|
+
const { wsId, usage, loading, error, refetch } = useUsage()
|
|
172
|
+
|
|
173
|
+
if (!wsId) {
|
|
174
|
+
return (
|
|
175
|
+
<div>
|
|
176
|
+
<PageHeader title="用量" />
|
|
177
|
+
<PageEmpty label="请先创建并选择一个工作区" />
|
|
178
|
+
</div>
|
|
179
|
+
)
|
|
180
|
+
}
|
|
181
|
+
if (loading) return <PageLoading label="加载用量数据…" />
|
|
182
|
+
if (error) {
|
|
183
|
+
return <PageError message={apiErrorMessage(error, '用量数据加载失败')} onRetry={() => refetch()} />
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return (
|
|
187
|
+
<div>
|
|
188
|
+
<PageHeader
|
|
189
|
+
title="用量"
|
|
190
|
+
description={
|
|
191
|
+
usage
|
|
192
|
+
? `当前套餐 ${usage.plan_code} · 计费周期 ${usage.period}(周期内累计,超限将按套餐规则限制或计费)`
|
|
193
|
+
: undefined
|
|
194
|
+
}
|
|
195
|
+
/>
|
|
196
|
+
{usage && usage.items.length > 0 ? (
|
|
197
|
+
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
|
|
198
|
+
{usage.items.map((item) => (
|
|
199
|
+
<UsageCard key={item.key} item={item} />
|
|
200
|
+
))}
|
|
201
|
+
</div>
|
|
202
|
+
) : (
|
|
203
|
+
<PageEmpty label="当前套餐没有计量维度" />
|
|
204
|
+
)}
|
|
205
|
+
</div>
|
|
206
|
+
)
|
|
207
|
+
}
|