feat: 优化代理后台页面布局

- 所有页面统一使用 BasicPage 组件

- 添加面包屑导航支持

- 统一页面标题和描述样式

- 移除控制台页面的应用管理快捷链接

- 优化卡密管理、用户管理、财务管理页面布局
This commit is contained in:
2026-05-09 04:53:12 +08:00
parent d7e479b5fa
commit 9d580a6bb7
5 changed files with 114 additions and 194 deletions
+27 -35
View File
@@ -5,6 +5,7 @@ import { useI18n } from 'vue-i18n'
import { useRoute, useRouter } from 'vue-router'
import { toast } from 'vue-sonner'
import { BasicPage } from '@/components/global-layout'
import api from '@/services/api'
const { t } = useI18n()
@@ -21,10 +22,6 @@ const form = ref({
quantity: 1,
})
const _selectedApp = computed(() => {
return apps.value.find(a => a.id === Number(form.value.app_id))
})
const availableCardTypes = computed(() => {
return cardTypes.value.filter(ct => ct.app_id === Number(form.value.app_id))
})
@@ -51,15 +48,15 @@ onMounted(async () => {
async function handleGenerate() {
if (!form.value.app_id) {
toast.error(t('agent.cards.create.selectApp'))
toast.error('请选择应用')
return
}
if (!form.value.card_type_id) {
toast.error(t('agent.cards.create.selectCardType'))
toast.error('请选择卡类')
return
}
if (form.value.quantity < 1 || form.value.quantity > 100) {
toast.error(t('agent.cards.create.quantityRange'))
toast.error('数量必须在1-100之间')
return
}
@@ -71,17 +68,17 @@ async function handleGenerate() {
quantity: form.value.quantity,
})
toast.success(t('agent.cards.create.generateSuccess', { count: data.codes.length }))
toast.success(`成功生成 ${data.codes.length} 张卡密`)
const codesText = data.codes.join('\n')
await navigator.clipboard.writeText(codesText)
toast.success(t('agent.cards.create.copiedToClipboard'))
toast.success('卡密已复制到剪贴板')
router.push('/agent/cards')
}
catch (error: any) {
console.error('Generate cards failed:', error)
toast.error(error.message || t('agent.cards.create.generateFailed'))
toast.error(error.message || '生成卡密失败')
}
finally {
loading.value = false
@@ -90,29 +87,24 @@ async function handleGenerate() {
</script>
<template>
<div class="space-y-6">
<div>
<h1 class="text-2xl font-bold">
{{ t('agent.cards.create.title') }}
</h1>
<p class="text-muted-foreground">
{{ t('agent.cards.create.description') }}
</p>
</div>
<UiCard class="max-w-xl">
<BasicPage
title="生成卡密"
description="批量生成卡密"
sticky
>
<UiCard class="max-w-2xl">
<UiCardHeader>
<UiCardTitle>{{ t('agent.cards.create.generateSettings') }}</UiCardTitle>
<UiCardTitle>生成设置</UiCardTitle>
<UiCardDescription>
{{ t('agent.cards.create.settingsDesc') }}
选择应用和卡类设置生成数量
</UiCardDescription>
</UiCardHeader>
<UiCardContent class="space-y-6">
<div class="space-y-2">
<UiLabel>{{ t('agent.cards.create.selectAppLabel') }}</UiLabel>
<UiLabel>选择应用 <span class="text-destructive">*</span></UiLabel>
<UiSelect v-model="form.app_id">
<UiSelectTrigger>
<UiSelectValue :placeholder="t('agent.cards.create.selectAppPlaceholder')" />
<UiSelectValue placeholder="请选择应用" />
</UiSelectTrigger>
<UiSelectContent>
<UiSelectItem v-for="app in apps" :key="app.id" :value="String(app.id)">
@@ -123,36 +115,36 @@ async function handleGenerate() {
</div>
<div v-if="form.app_id" class="space-y-2">
<UiLabel>{{ t('agent.cards.create.selectCardTypeLabel') }}</UiLabel>
<UiLabel>选择卡类 <span class="text-destructive">*</span></UiLabel>
<UiSelect v-model="form.card_type_id">
<UiSelectTrigger>
<UiSelectValue :placeholder="t('agent.cards.create.selectCardTypePlaceholder')" />
<UiSelectValue placeholder="请选择卡类" />
</UiSelectTrigger>
<UiSelectContent>
<UiSelectItem v-for="ct in availableCardTypes" :key="ct.id" :value="String(ct.id)">
{{ ct.name }} - {{ ct.duration_days }}{{ t('agent.apps.detail.days') }} - ¥{{ ct.price }}
{{ ct.name }} - {{ ct.duration_days }} - ¥{{ ct.price }}
</UiSelectItem>
</UiSelectContent>
</UiSelect>
</div>
<div class="space-y-2">
<UiLabel>{{ t('agent.cards.create.quantity') }}</UiLabel>
<UiLabel>生成数量 <span class="text-destructive">*</span></UiLabel>
<UiInput
v-model.number="form.quantity"
type="number"
:min="1"
:max="100"
:placeholder="t('agent.cards.create.quantityPlaceholder')"
placeholder="请输入生成数量"
/>
<p class="text-xs text-muted-foreground">
{{ t('agent.cards.create.quantityHint') }}
单次最多生成100张卡密
</p>
</div>
<div v-if="totalPrice > 0" class="p-4 rounded-lg bg-muted/50">
<div class="flex items-center justify-between">
<span class="text-muted-foreground">{{ t('agent.cards.create.estimatedCost') }}</span>
<span class="text-muted-foreground">预计费用</span>
<span class="text-xl font-bold">¥{{ totalPrice.toFixed(2) }}</span>
</div>
</div>
@@ -160,7 +152,7 @@ async function handleGenerate() {
<div class="flex gap-3">
<UiButton variant="outline" as-child>
<router-link to="/agent/cards">
{{ t('agent.cards.create.cancel') }}
取消
</router-link>
</UiButton>
<UiButton
@@ -168,10 +160,10 @@ async function handleGenerate() {
@click="handleGenerate"
>
<Loader2 v-if="loading" class="mr-2 h-4 w-4 animate-spin" />
{{ loading ? t('agent.cards.create.generating') : t('agent.cards.create.generateBtn') }}
{{ loading ? '生成中...' : '生成卡密' }}
</UiButton>
</div>
</UiCardContent>
</UiCard>
</div>
</BasicPage>
</template>
+18 -21
View File
@@ -3,6 +3,7 @@ import { Key, Loader2, Plus } from 'lucide-vue-next'
import { onMounted, ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { BasicPage } from '@/components/global-layout'
import api from '@/services/api'
const { t } = useI18n()
@@ -51,23 +52,19 @@ function getStatusBadge(status: string) {
</script>
<template>
<div class="space-y-6">
<div class="flex items-center justify-between">
<div>
<h1 class="text-2xl font-bold">
{{ t('agent.cards.title') }}
</h1>
<p class="text-muted-foreground">
{{ t('agent.cards.description') }}
</p>
</div>
<BasicPage
:title="t('nav.cards')"
description="管理生成的卡密"
sticky
>
<template #actions>
<UiButton as-child>
<router-link to="/agent/cards/create">
<Plus class="mr-2 h-4 w-4" />
{{ t('agent.cards.generateCards') }}
生成卡密
</router-link>
</UiButton>
</div>
</template>
<UiCard>
<UiCardContent class="p-0">
@@ -77,10 +74,10 @@ function getStatusBadge(status: string) {
<div v-else-if="cards.length === 0" class="text-center py-12 text-muted-foreground">
<Key class="size-16 mx-auto mb-4 opacity-30" />
<p>{{ t('agent.cards.noCards') }}</p>
<p>暂无卡密</p>
<UiButton class="mt-4" as-child>
<router-link to="/agent/cards/create">
{{ t('agent.cards.generateCards') }}
生成卡密
</router-link>
</UiButton>
</div>
@@ -90,22 +87,22 @@ function getStatusBadge(status: string) {
<thead class="bg-muted/50">
<tr>
<th class="px-4 py-3 text-left text-sm font-medium">
{{ t('agent.cards.cardCode') }}
卡号
</th>
<th class="px-4 py-3 text-left text-sm font-medium">
{{ t('agent.cards.app') }}
应用
</th>
<th class="px-4 py-3 text-left text-sm font-medium">
{{ t('agent.cards.cardType') }}
卡类
</th>
<th class="px-4 py-3 text-left text-sm font-medium">
{{ t('agent.cards.status') }}
状态
</th>
<th class="px-4 py-3 text-left text-sm font-medium">
{{ t('agent.cards.createTime') }}
创建时间
</th>
<th class="px-4 py-3 text-left text-sm font-medium">
{{ t('agent.cards.useTime') }}
使用时间
</th>
</tr>
</thead>
@@ -137,5 +134,5 @@ function getStatusBadge(status: string) {
</div>
</UiCardContent>
</UiCard>
</div>
</BasicPage>
</template>