chore: 项目基线(基于 WeKnora 定制版,整理文件忽略规则)
This commit is contained in:
commit
9097ee699d
5769 files changed
+1446466
No files matched your search
@@ -0,0 +1,387 @@
|
||||
<template>
|
||||
<div class="overview_page">
|
||||
<div class="overview_header">
|
||||
<div>
|
||||
<h2 class="overview_title">{{ t('overview.title') }}</h2>
|
||||
<p class="overview_subtitle">{{ t('overview.subtitle') }}</p>
|
||||
</div>
|
||||
<t-button theme="primary" @click="router.push('/platform/creatChat')">
|
||||
<template #icon><t-icon name="chat" /></template>
|
||||
{{ t('overview.newChat') }}
|
||||
</t-button>
|
||||
</div>
|
||||
|
||||
<!-- 统计卡片 -->
|
||||
<div class="overview_stats">
|
||||
<div v-for="card in statCards" :key="card.key" class="overview_stat_card"
|
||||
:class="[`overview_stat_card--${card.key}`, { 'is-clickable': !!card.path }]"
|
||||
@click="card.path && router.push(card.path)">
|
||||
<div class="overview_stat_icon">
|
||||
<t-icon :name="card.icon" size="22px" />
|
||||
</div>
|
||||
<div class="overview_stat_body">
|
||||
<div class="overview_stat_value">
|
||||
<span v-if="!card.loading">{{ card.value }}</span>
|
||||
<t-loading v-else size="small" />
|
||||
</div>
|
||||
<div class="overview_stat_label">{{ card.label }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="overview_columns">
|
||||
<!-- 最近对话 -->
|
||||
<div class="overview_panel">
|
||||
<div class="overview_panel_header">
|
||||
<span class="overview_panel_title">{{ t('overview.recentSessions') }}</span>
|
||||
<t-button variant="text" theme="primary" size="small" @click="router.push('/platform/creatChat')">
|
||||
{{ t('overview.more') }}
|
||||
</t-button>
|
||||
</div>
|
||||
<div v-if="recentLoading" class="overview_panel_empty">
|
||||
<t-loading size="small" />
|
||||
</div>
|
||||
<div v-else-if="!recentSessions.length" class="overview_panel_empty">
|
||||
{{ t('overview.noSessions') }}
|
||||
</div>
|
||||
<div v-else class="overview_session_list">
|
||||
<div v-for="session in recentSessions" :key="session.id" class="overview_session_item"
|
||||
@click="router.push(`/platform/chat/${session.id}`)">
|
||||
<div class="overview_session_title">{{ session.title || t('overview.untitledSession') }}</div>
|
||||
<div class="overview_session_time">{{ formatTime(session.updated_at || session.created_at) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 快捷入口 -->
|
||||
<div class="overview_panel">
|
||||
<div class="overview_panel_header">
|
||||
<span class="overview_panel_title">{{ t('overview.quickEntries') }}</span>
|
||||
</div>
|
||||
<div class="overview_quick_grid">
|
||||
<div v-for="entry in quickEntries" :key="entry.key" class="overview_quick_item"
|
||||
@click="router.push(entry.path)">
|
||||
<t-icon :name="entry.icon" size="20px" />
|
||||
<span>{{ entry.label }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { fmtBeijingTime } from '@/utils/datetime'
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { listKnowledgeBases } from '@/api/knowledge-base';
|
||||
import { listAgents } from '@/api/agent';
|
||||
import { getSessionsList } from '@/api/chat';
|
||||
|
||||
const router = useRouter();
|
||||
const { t, locale } = useI18n();
|
||||
|
||||
const kbCount = ref(0);
|
||||
const agentCount = ref(0);
|
||||
const sessionTotal = ref(0);
|
||||
const kbLoading = ref(true);
|
||||
const agentLoading = ref(true);
|
||||
const recentLoading = ref(true);
|
||||
|
||||
interface RecentSession {
|
||||
id: string;
|
||||
title?: string;
|
||||
updated_at?: string;
|
||||
created_at?: string;
|
||||
}
|
||||
const recentSessions = ref<RecentSession[]>([]);
|
||||
|
||||
const statCards = computed(() => [
|
||||
{
|
||||
key: 'kb',
|
||||
icon: 'folder',
|
||||
label: t('overview.statKb'),
|
||||
value: kbCount.value,
|
||||
loading: kbLoading.value,
|
||||
path: '/platform/knowledge-bases',
|
||||
},
|
||||
{
|
||||
key: 'agents',
|
||||
icon: 'usergroup-add',
|
||||
label: t('overview.statAgents'),
|
||||
value: agentCount.value,
|
||||
loading: agentLoading.value,
|
||||
path: '/platform/agents',
|
||||
},
|
||||
{
|
||||
key: 'sessions',
|
||||
icon: 'chat',
|
||||
label: t('overview.statSessions'),
|
||||
value: sessionTotal.value,
|
||||
loading: false,
|
||||
path: '/platform/creatChat',
|
||||
},
|
||||
]);
|
||||
|
||||
const quickEntries = computed(() => [
|
||||
{ key: 'chat', icon: 'chat', label: t('overview.entryChat'), path: '/platform/creatChat' },
|
||||
{ key: 'kb', icon: 'folder', label: t('overview.entryKb'), path: '/platform/knowledge-bases' },
|
||||
{ key: 'agents', icon: 'usergroup-add', label: t('overview.entryAgents'), path: '/platform/agents' },
|
||||
{ key: 'automations', icon: 'history', label: t('overview.entryAutomations'), path: '/platform/automations' },
|
||||
{ key: 'toolbox', icon: 'tools', label: t('overview.entryToolbox'), path: '/platform/toolbox' },
|
||||
{ key: 'settings', icon: 'setting', label: t('overview.entrySettings'), path: '/platform/settings' },
|
||||
]);
|
||||
|
||||
const formatTime = (value?: string) => {
|
||||
if (!value) return '';
|
||||
const date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) return '';
|
||||
return fmtBeijingTime(date);
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
// 并行拉取概览数据;单项失败不阻塞其余卡片
|
||||
listKnowledgeBases()
|
||||
.then((res: any) => {
|
||||
const rows = res?.data?.data ?? res?.data ?? res ?? [];
|
||||
kbCount.value = Array.isArray(rows) ? rows.length : 0;
|
||||
})
|
||||
.catch(() => { kbCount.value = 0; })
|
||||
.finally(() => { kbLoading.value = false; });
|
||||
|
||||
listAgents()
|
||||
.then((res: any) => {
|
||||
const rows = res?.data?.data ?? res?.data ?? res ?? [];
|
||||
agentCount.value = Array.isArray(rows) ? rows.length : 0;
|
||||
})
|
||||
.catch(() => { agentCount.value = 0; })
|
||||
.finally(() => { agentLoading.value = false; });
|
||||
|
||||
getSessionsList(1, 8)
|
||||
.then((res: any) => {
|
||||
sessionTotal.value = res?.total ?? 0;
|
||||
const rows = res?.data ?? [];
|
||||
recentSessions.value = Array.isArray(rows) ? rows.slice(0, 8) : [];
|
||||
})
|
||||
.catch(() => { recentSessions.value = []; })
|
||||
.finally(() => { recentLoading.value = false; });
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.overview_page {
|
||||
padding: 24px 28px;
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
animation: overview-fade-in 0.3s ease;
|
||||
}
|
||||
|
||||
@keyframes overview-fade-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(6px);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.overview_header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 20px;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.overview_title {
|
||||
margin: 0;
|
||||
font-size: 22px;
|
||||
font-weight: 700;
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
|
||||
.overview_subtitle {
|
||||
margin: 4px 0 0;
|
||||
font-size: 13px;
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
|
||||
.overview_stats {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 16px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.overview_stat_card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
padding: 18px 20px;
|
||||
border-radius: 12px;
|
||||
background: var(--td-bg-color-container);
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
||||
|
||||
&.is-clickable {
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: var(--td-shadow-1);
|
||||
}
|
||||
}
|
||||
|
||||
&--kb .overview_stat_icon {
|
||||
background: rgba(7, 192, 95, 0.12);
|
||||
color: #07c05f;
|
||||
}
|
||||
|
||||
&--agents .overview_stat_icon {
|
||||
background: rgba(59, 130, 246, 0.12);
|
||||
color: #3b82f6;
|
||||
}
|
||||
|
||||
&--sessions .overview_stat_icon {
|
||||
background: rgba(16, 180, 200, 0.12);
|
||||
color: #10b4c8;
|
||||
}
|
||||
}
|
||||
|
||||
.overview_stat_icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border-radius: 10px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.overview_stat_value {
|
||||
font-size: 26px;
|
||||
font-weight: 700;
|
||||
line-height: 1.1;
|
||||
color: var(--td-text-color-primary);
|
||||
min-height: 28px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.overview_stat_label {
|
||||
margin-top: 2px;
|
||||
font-size: 13px;
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
|
||||
.overview_columns {
|
||||
display: grid;
|
||||
grid-template-columns: 3fr 2fr;
|
||||
gap: 16px;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.overview_panel {
|
||||
background: var(--td-bg-color-container);
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
border-radius: 12px;
|
||||
padding: 16px 18px;
|
||||
}
|
||||
|
||||
.overview_panel_header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.overview_panel_title {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
|
||||
.overview_panel_empty {
|
||||
padding: 28px 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--td-text-color-placeholder);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.overview_session_list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.overview_session_item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 10px 8px;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
background: var(--td-bg-color-container-hover);
|
||||
}
|
||||
|
||||
& + .overview_session_item {
|
||||
border-top: 1px solid var(--td-component-stroke);
|
||||
}
|
||||
}
|
||||
|
||||
.overview_session_title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: 14px;
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
|
||||
.overview_session_time {
|
||||
flex-shrink: 0;
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
}
|
||||
|
||||
.overview_quick_grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.overview_quick_item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 12px 14px;
|
||||
border-radius: 10px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-text-color-primary);
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.15s ease, transform 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
background: var(--td-bg-color-container-hover);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.overview_stats,
|
||||
.overview_columns {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user