fix(dashboard): show notes below API key accounts (#545)

* fix(dashboard): show notes below API key accounts

Co-authored-by: Codex <noreply@openai.com>

* fix(frontend): complete dashboard theme preview account notes

Co-authored-by: Codex <noreply@openai.com>

---------

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
蓝芷怡
2026-10-28 18:55:57 +08:00
committed by GitHub
co-authored by Codex
parent 7cd17aff42
commit e03851e23f
12 changed files with 21 additions and 2 deletions
@@ -653,6 +653,7 @@ pub struct DashboardAccountUsage {
pub authentication_kind: String,
pub name: String,
pub email: Option<String>,
pub notes: Option<String>,
pub plan_type: Option<String>,
/// Admin 按 Provider 补齐的套餐展示名称
pub plan_type_display: Option<String>,
@@ -1000,6 +1000,7 @@ async fn dashboard_should_preserve_provider_plan_names() {
authentication_kind: "oauth".to_owned(),
name: (*plan).to_owned(),
email: None,
notes: None,
plan_type: Some((*plan).to_owned()),
plan_type_display: None,
request_count: 0,
@@ -926,6 +926,7 @@ pub(crate) fn dashboard_view(
.email
.clone()
.unwrap_or_else(|| credential.name.clone()),
notes: credential.notes,
plan_type: credential.plan_type.clone(),
plan_type_display: credential
.plan_type_display
@@ -406,6 +406,7 @@ pub struct DashboardAccountUsageView {
pub provider: String,
pub authentication_kind: String,
pub email: String,
pub notes: Option<String>,
pub plan_type: Option<String>,
pub plan_type_display: String,
pub tokens: String,
@@ -1607,6 +1607,7 @@ async fn dashboard_summary_should_identify_metrics_without_localized_labels() {
authentication_kind: "oauth".to_owned(),
name: account_id.clone(),
email: None,
notes: None,
plan_type: None,
plan_type_display: None,
request_count: 10,
@@ -1805,6 +1806,7 @@ async fn dashboard_relative_time_preserves_server_anchor_boundaries_and_deployme
authentication_kind: "oauth".to_owned(),
name: "Relative time fixture".to_owned(),
email: None,
notes: None,
plan_type: None,
plan_type_display: None,
request_count: 1,
@@ -138,6 +138,7 @@ pub(crate) fn admin_dashboard_account_usage(
authentication_kind: usage.authentication_kind,
name: usage.name,
email: usage.email,
notes: usage.notes,
plan_type: usage.plan_type,
plan_type_display: None,
request_count: usage.request_count,
@@ -227,6 +227,7 @@ pub struct ProviderAccountUsageObservation {
pub authentication_kind: String,
pub name: String,
pub email: Option<String>,
pub notes: Option<String>,
pub plan_type: Option<String>,
pub request_count: u64,
pub success_count: u64,
@@ -87,6 +87,7 @@ pub(crate) async fn provider_account_usage(
authentication_kind: get(&row, "authentication_kind")?,
name: get(&row, "name")?,
email: get(&row, "email")?,
notes: get(&row, "notes")?,
plan_type: get(&row, "plan_type")?,
request_count: state.count("completed_request_count"),
success_count: state.count("completed_request_count"),
+2
View File
@@ -2148,6 +2148,8 @@ Dashboard 的 `accountUsage[]` 返回稳定指标 `metric=requests|tokens`、可
`requests` 使用代表性额度窗口的本地请求数,`tokens` 使用今日 Token;未知数值为 `null`,零值保留 `0`。
`metricLabel`、`metricValue` 和 `lastUsed` 保留给兼容调用方,当前管理端不解析或显示这些字段
`accountUsage[].notes` 为账号当前备注,无备注时为 `null`
`usageWindow` 复用账号额度窗口合同,缺失额度事实时为 `null`;窗口标签、百分比、触顶状态、重置时间
和本地用量由 Provider/Admin 投影。套餐缺失不表示免费套餐,显示时舍入的百分比不用于判断触顶
+1
View File
@@ -145,6 +145,7 @@ export interface DashboardAccountUsage {
provider: string
authenticationKind: string
email: string
notes: string | null
planType: string | null
planTypeDisplay: string
tokens: string
@@ -19,6 +19,9 @@ type DashboardAccount = DashboardSnapshot['accountUsage'][number]
const email = computed(() => props.account.email?.trim() || String(props.account.id))
const displayTitle = computed(() => email.value.split('@')[0] || email.value)
const secondaryText = computed(() => props.account.authenticationKind === 'api_key'
? props.account.notes
: email.value)
const normalizedProvider = computed(() => props.account.provider?.trim().toLowerCase() || '')
const providerIconComponent = computed(() => normalizedProvider.value
? providerIcon(normalizedProvider.value)
@@ -64,10 +67,11 @@ const avatarToneClass = computed(() =>
<AccountPlanBadge :authentication-kind="account.authenticationKind" :plan-type="account.planType" :plan-type-display="account.planTypeDisplay" size="xs" />
</span>
<span
v-if="secondaryText"
class="mt-0.5 block min-w-0 truncate font-mono text-cp-xs font-emphasis text-cp-text-quaternary"
:title="email"
:title="secondaryText"
>
{{ email }}
{{ secondaryText }}
</span>
</span>
</div>
@@ -341,6 +341,7 @@ export const themeDashboardSummary = computed<DashboardSummaryResponse>(() => ({
provider: 'openai',
authenticationKind: 'oauth',
email: 'relay@example.com',
notes: null,
planType: 'team',
planTypeDisplay: 'Business',
tokens: '926K',
@@ -374,6 +375,7 @@ export const themeDashboardSummary = computed<DashboardSummaryResponse>(() => ({
provider: 'xai',
authenticationKind: 'oauth',
email: 'gateway@example.com',
notes: null,
planType: 'free',
planTypeDisplay: 'Free',
tokens: '684K',
@@ -428,6 +430,7 @@ export const themeDashboardSummary = computed<DashboardSummaryResponse>(() => ({
provider: 'openai',
authenticationKind: 'oauth',
email: 'control@example.com',
notes: null,
planType: 'pro',
planTypeDisplay: 'Pro',
tokens: '512K',