fix(accounts): show email and add usage refresh button for OpenAI OAuth

- AccountsView: display email under account name by checking extra.email
  and credentials.email in addition to extra.email_address; OpenAI OAuth
  stores email under the 'email' key while Anthropic uses 'email_address'
- AccountUsageCell: add per-account refresh button to the OpenAI OAuth
  usage section, identical to the existing Anthropic OAuth pattern;
  reuses loadActiveUsage, activeQueryLoading, and the activeQuery i18n key
This commit is contained in:
chenjian 2026-05-19 15:43:13 +08:00
parent f5bd25bea0
commit 6db02f0069
2 changed files with 28 additions and 4 deletions

View File

@ -126,6 +126,30 @@
:show-now-when-idle="true"
color="emerald"
/>
<div class="flex items-center gap-1.5 mt-0.5">
<button
type="button"
class="inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[9px] font-medium text-blue-600 hover:bg-blue-50 dark:text-blue-400 dark:hover:bg-blue-900/30 transition-colors"
:disabled="activeQueryLoading"
@click="loadActiveUsage"
>
<svg
class="h-2.5 w-2.5"
:class="{ 'animate-spin': activeQueryLoading }"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
/>
</svg>
{{ t('admin.accounts.usageWindow.activeQuery') }}
</button>
</div>
</div>
<div v-else-if="loading" class="space-y-1.5">
<div class="flex items-center gap-1">
@ -1070,7 +1094,7 @@ const attachVisibilityObserver = () => {
const loadActiveUsage = async () => {
activeQueryLoading.value = true
try {
usageInfo.value = await adminAPI.accounts.getUsage(props.account.id, 'active')
usageInfo.value = await adminAPI.accounts.getUsage(props.account.id, 'active', true)
} catch (e: any) {
console.error('Failed to load active usage:', e)
} finally {

View File

@ -214,11 +214,11 @@
<div class="flex flex-col">
<span class="font-medium text-gray-900 dark:text-white">{{ value }}</span>
<span
v-if="row.extra?.email_address"
v-if="row.extra?.email_address || row.extra?.email || row.credentials?.email"
class="text-xs text-gray-500 dark:text-gray-400 truncate max-w-[200px]"
:title="row.extra.email_address"
:title="String(row.extra?.email_address || row.extra?.email || row.credentials?.email)"
>
{{ row.extra.email_address }}
{{ row.extra?.email_address || row.extra?.email || row.credentials?.email }}
</span>
</div>
</template>