fix(admin): 管理控制台界面使用element plus
This commit is contained in:
1 parent
6c47d0639c
commit
cdc8610ec1
45 files changed
+6258
-4639
No files matched your search
@@ -1,16 +1,25 @@
|
||||
/**
|
||||
* features/admin/modules/dashboard/DashboardPage.vue
|
||||
* 管理后台仪表盘。路由:/admin/dashboard
|
||||
* 用途:管理后台仪表盘,四张可点击的统计卡。
|
||||
* 依赖:useDashboardAdmin、useElementProvider、element-plus。
|
||||
* 逻辑:路由 /admin/dashboard。统计来自 useDashboardAdmin。点击分别进入应用配置、应用权限和数据报表。本页不是列表,不用 AdminListPage。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { BarChart2, Bot, MessageSquare, Users } from 'lucide-vue-next';
|
||||
import { ChatDotRound, DataAnalysis, Monitor, User } from '@element-plus/icons-vue';
|
||||
import { ElCard, ElConfigProvider, ElIcon, ElLoading, ElStatistic, ElTag } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import { useDashboardAdmin } from './composables/useDashboardAdmin';
|
||||
|
||||
const vLoading = ElLoading.directive;
|
||||
const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
const { elementLocale } = useElementProvider();
|
||||
|
||||
const {
|
||||
agentCount,
|
||||
@@ -21,74 +30,89 @@ const {
|
||||
loadAll,
|
||||
} = useDashboardAdmin();
|
||||
|
||||
/**
|
||||
* 进入指定管理页。
|
||||
* @param name - 路由名
|
||||
* @param table - 数据报表表名;其它页面不传
|
||||
*/
|
||||
function openAdmin(name: string, table?: string): void {
|
||||
if (table) {
|
||||
void router.push({ name, params: { table } });
|
||||
return;
|
||||
}
|
||||
void router.push({ name });
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void loadAll();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section>
|
||||
<div v-if="isLoading" class="flex items-center justify-center py-20">
|
||||
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
|
||||
</div>
|
||||
|
||||
<div v-else class="grid grid-cols-1 sm:grid-cols-2 gap-6 animate-fade-in">
|
||||
<div
|
||||
class="card card-ds-interactive p-6 group cursor-pointer"
|
||||
@click="router.push({ name: 'AdminAgents' })"
|
||||
>
|
||||
<div class="flex justify-between items-start mb-4">
|
||||
<div class="p-3 bg-brand-50 rounded-xl group-hover:bg-brand-100 transition-colors">
|
||||
<Bot class="w-6 h-6 text-brand-600" />
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<section v-loading="isLoading" class="admin-dash">
|
||||
<h2 class="section-title">{{ t('admin.nav.dashboard') }}</h2>
|
||||
<div v-if="!isLoading" class="admin-dash__grid">
|
||||
<ElCard shadow="hover" class="admin-dash__card" @click="openAdmin('AdminAgents')">
|
||||
<div class="admin-dash__row">
|
||||
<ElIcon :size="22"><Monitor /></ElIcon>
|
||||
<ElTag type="success" effect="light">+2 {{ t('admin.dash.new') }}</ElTag>
|
||||
</div>
|
||||
<span class="text-xs font-medium text-green-600 bg-green-50 px-2 py-1 rounded-full">
|
||||
+2 {{ t('admin.dash.new') }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="text-3xl font-bold text-primary mb-1">{{ agentCount }}</div>
|
||||
<div class="text-sm text-muted font-medium">{{ t('admin.dash.activeAgents') }}</div>
|
||||
</div>
|
||||
<ElStatistic :title="t('admin.dash.activeAgents')" :value="agentCount" />
|
||||
</ElCard>
|
||||
|
||||
<div
|
||||
class="card card-ds-interactive p-6 group cursor-pointer"
|
||||
@click="router.push({ name: 'AdminPermissions' })"
|
||||
>
|
||||
<div class="flex justify-between items-start mb-4">
|
||||
<div class="p-3 bg-purple-50 rounded-xl group-hover:bg-purple-100 transition-colors">
|
||||
<Users class="w-6 h-6 text-purple-600" />
|
||||
<ElCard shadow="hover" class="admin-dash__card" @click="openAdmin('AdminPermissions')">
|
||||
<div class="admin-dash__row">
|
||||
<ElIcon :size="22"><User /></ElIcon>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-3xl font-bold text-primary mb-1">{{ userCount }}</div>
|
||||
<div class="text-sm text-muted font-medium">{{ t('admin.dash.totalUsers') }}</div>
|
||||
</div>
|
||||
<ElStatistic :title="t('admin.dash.totalUsers')" :value="userCount" />
|
||||
</ElCard>
|
||||
|
||||
<div
|
||||
class="card card-ds-interactive p-6 group cursor-pointer"
|
||||
@click="router.push({ name: 'AdminReports', params: { table: 'chat_logs' } })"
|
||||
>
|
||||
<div class="flex justify-between items-start mb-4">
|
||||
<div class="p-3 bg-indigo-50 rounded-xl group-hover:bg-indigo-100 transition-colors">
|
||||
<MessageSquare class="w-6 h-6 text-indigo-600" />
|
||||
<ElCard shadow="hover" class="admin-dash__card" @click="openAdmin('AdminReports', 'chat_logs')">
|
||||
<div class="admin-dash__row">
|
||||
<ElIcon :size="22"><ChatDotRound /></ElIcon>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-3xl font-bold text-primary mb-1">{{ totalConversations }}</div>
|
||||
<div class="text-sm text-muted font-medium">{{ t('admin.dash.totalConversations') }}</div>
|
||||
</div>
|
||||
<ElStatistic :title="t('admin.dash.totalConversations')" :value="totalConversations" />
|
||||
</ElCard>
|
||||
|
||||
<div
|
||||
class="card card-ds-interactive p-6 group cursor-pointer"
|
||||
@click="router.push({ name: 'AdminReports', params: { table: 'feedbacks' } })"
|
||||
>
|
||||
<div class="flex justify-between items-start mb-4">
|
||||
<div class="p-3 bg-orange-50 rounded-xl group-hover:bg-orange-100 transition-colors">
|
||||
<BarChart2 class="w-6 h-6 text-orange-600" />
|
||||
<ElCard shadow="hover" class="admin-dash__card" @click="openAdmin('AdminReports', 'feedbacks')">
|
||||
<div class="admin-dash__row">
|
||||
<ElIcon :size="22"><DataAnalysis /></ElIcon>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-3xl font-bold text-primary mb-1">
|
||||
{{ avgScore.toFixed(1) }}
|
||||
</div>
|
||||
<div class="text-sm text-muted font-medium">{{ t('admin.dash.avgRating') }}</div>
|
||||
<ElStatistic :title="t('admin.dash.avgRating')" :value="avgScore" :precision="1" />
|
||||
</ElCard>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.admin-dash {
|
||||
min-height: 16rem;
|
||||
}
|
||||
|
||||
.admin-dash__grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 16px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.admin-dash__card {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.admin-dash__row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 12px;
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.admin-dash__grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user