115 lines
3.4 KiB
Vue
115 lines
3.4 KiB
Vue
/**
|
|
* features/admin/modules/dashboard/DashboardPage.vue
|
|
* 用途:管理后台仪表盘,四张可点击的统计卡。
|
|
* 依赖:useDashboardAdmin、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 { ChatDotRound, DataAnalysis, Monitor, User } from '@element-plus/icons-vue';
|
|
import { ElCard, 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 { useDashboardAdmin } from './composables/useDashboardAdmin';
|
|
|
|
const vLoading = ElLoading.directive;
|
|
const { t } = useI18n();
|
|
const router = useRouter();
|
|
|
|
const {
|
|
agentCount,
|
|
userCount,
|
|
totalConversations,
|
|
avgScore,
|
|
isLoading,
|
|
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 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>
|
|
<ElStatistic :title="t('admin.dash.activeAgents')" :value="agentCount" />
|
|
</ElCard>
|
|
|
|
<ElCard shadow="hover" class="admin-dash__card" @click="openAdmin('AdminPermissions')">
|
|
<div class="admin-dash__row">
|
|
<ElIcon :size="22"><User /></ElIcon>
|
|
</div>
|
|
<ElStatistic :title="t('admin.dash.totalUsers')" :value="userCount" />
|
|
</ElCard>
|
|
|
|
<ElCard shadow="hover" class="admin-dash__card" @click="openAdmin('AdminReports', 'chat_logs')">
|
|
<div class="admin-dash__row">
|
|
<ElIcon :size="22"><ChatDotRound /></ElIcon>
|
|
</div>
|
|
<ElStatistic :title="t('admin.dash.totalConversations')" :value="totalConversations" />
|
|
</ElCard>
|
|
|
|
<ElCard shadow="hover" class="admin-dash__card" @click="openAdmin('AdminReports', 'feedbacks')">
|
|
<div class="admin-dash__row">
|
|
<ElIcon :size="22"><DataAnalysis /></ElIcon>
|
|
</div>
|
|
<ElStatistic :title="t('admin.dash.avgRating')" :value="avgScore" :precision="1" />
|
|
</ElCard>
|
|
</div>
|
|
</section>
|
|
</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>
|