first-update
This commit is contained in:
397
frontend/src/views/DataSquareView.vue
Normal file
397
frontend/src/views/DataSquareView.vue
Normal file
@@ -0,0 +1,397 @@
|
||||
<template>
|
||||
<div class="data-square">
|
||||
<!-- Header -->
|
||||
<header class="header">
|
||||
<div class="header-content">
|
||||
<div class="header-left" @click="goHome">
|
||||
<el-icon><ArrowLeft /></el-icon>
|
||||
<span>返回</span>
|
||||
</div>
|
||||
<div class="header-title">
|
||||
<h1>数据集广场</h1>
|
||||
<p>发现和分享高质量数据集</p>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Main -->
|
||||
<main class="main">
|
||||
<!-- Filters -->
|
||||
<div class="filters">
|
||||
<div class="search-box">
|
||||
<el-icon class="search-icon"><Search /></el-icon>
|
||||
<el-input v-model="searchQuery" placeholder="搜索数据集..." clearable class="search-input" />
|
||||
</div>
|
||||
<el-select v-model="filterType" placeholder="类型" clearable class="type-select">
|
||||
<el-option label="全部类型" value="" />
|
||||
<el-option label="问答对" value="qa" />
|
||||
<el-option label="多轮对话" value="conversation" />
|
||||
<el-option label="指令跟随" value="instruction" />
|
||||
</el-select>
|
||||
</div>
|
||||
|
||||
<!-- Stats Bar -->
|
||||
<div class="stats-bar">
|
||||
<span class="stat">
|
||||
<strong>{{ datasets.length }}</strong> 个数据集可用
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- Grid -->
|
||||
<div class="dataset-grid" v-loading="loading">
|
||||
<div v-if="!loading && datasets.length === 0" class="empty-state">
|
||||
<el-icon size="56"><Collection /></el-icon>
|
||||
<h3>未找到数据集</h3>
|
||||
<p>请尝试调整搜索条件或筛选器</p>
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
v-for="(dataset, index) in datasets"
|
||||
:key="dataset.id"
|
||||
class="dataset-card"
|
||||
:style="{ '--delay': index * 0.08 + 's' }"
|
||||
>
|
||||
<div class="card-cover">
|
||||
<div class="cover-gradient"></div>
|
||||
<div class="cover-pattern"></div>
|
||||
<el-icon size="40" class="cover-icon"><Collection /></el-icon>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">{{ dataset.name }}</h3>
|
||||
<el-tag size="small" effect="dark">{{ dataset.type || '问答' }}</el-tag>
|
||||
</div>
|
||||
<p class="card-desc">{{ dataset.description }}</p>
|
||||
<div class="card-stats">
|
||||
<div class="stat-item">
|
||||
<el-icon><Document /></el-icon>
|
||||
<span>{{ dataset.question_count }} 条</span>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<el-icon><User /></el-icon>
|
||||
<span>{{ dataset.author }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-tags">
|
||||
<el-tag v-for="tag in dataset.tags" :key="tag" size="small" effect="plain">{{ tag }}</el-tag>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<span class="card-date">{{ formatDate(dataset.created_at) }}</span>
|
||||
<div class="card-actions">
|
||||
<el-button type="primary" size="small" @click="viewDataset(dataset)">
|
||||
<el-icon><View /></el-icon>
|
||||
查看
|
||||
</el-button>
|
||||
<el-button size="small" @click="downloadDataset(dataset)">
|
||||
<el-icon><Download /></el-icon>
|
||||
下载
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
const router = useRouter()
|
||||
const loading = ref(false)
|
||||
const searchQuery = ref('')
|
||||
const filterType = ref('')
|
||||
const datasets = ref([])
|
||||
|
||||
const goHome = () => router.push('/')
|
||||
|
||||
const fetchDatasets = async () => {
|
||||
loading.value = true
|
||||
setTimeout(() => {
|
||||
datasets.value = [
|
||||
{ id: '1', name: '通用知识问答', description: '涵盖科学、历史和地理的综合问答数据集', question_count: 10000, author: '数据集团队', created_at: '2024-01-15', tags: ['知识', '通用'], type: '问答' },
|
||||
{ id: '2', name: '代码理解', description: '多语言代码理解和解释数据集', question_count: 5000, author: 'Code AI', created_at: '2024-02-20', tags: ['代码', '编程'], type: '指令' },
|
||||
{ id: '3', name: '数学推理', description: '包含详细步骤解答的数学问题集', question_count: 8000, author: '数学实验室', created_at: '2024-03-10', tags: ['数学', '推理'], type: '问答' },
|
||||
{ id: '4', name: '医学知识问答', description: '专业医学领域问答数据集', question_count: 3500, author: '医学 AI', created_at: '2024-04-05', tags: ['医学', '专业'], type: '问答' }
|
||||
]
|
||||
loading.value = false
|
||||
}, 500)
|
||||
}
|
||||
|
||||
const viewDataset = (d) => ElMessage.info('查看中: ' + d.name)
|
||||
const downloadDataset = (d) => ElMessage.success('下载中: ' + d.name)
|
||||
const formatDate = (d) => d ? d.split('-').slice(1).join('/') : ''
|
||||
|
||||
onMounted(() => fetchDatasets())
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.data-square { min-height: 100vh; }
|
||||
|
||||
/* Header */
|
||||
.header {
|
||||
background: var(--bg-secondary);
|
||||
border-bottom: 1px solid var(--border-subtle);
|
||||
padding: 20px 24px;
|
||||
}
|
||||
|
||||
.header-content {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.header-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
cursor: pointer;
|
||||
padding: 8px 14px;
|
||||
border-radius: var(--radius-md);
|
||||
color: var(--text-secondary);
|
||||
transition: all var(--transition-fast);
|
||||
}
|
||||
|
||||
.header-left:hover {
|
||||
background: var(--bg-hover);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.header-title h1 {
|
||||
font-size: 22px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.header-title p {
|
||||
font-size: 14px;
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
/* Main */
|
||||
.main {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 28px 24px;
|
||||
}
|
||||
|
||||
/* Filters */
|
||||
.filters {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.search-box {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
.search-icon {
|
||||
position: absolute;
|
||||
left: 14px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
color: var(--text-muted);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.search-input :deep(.el-input__wrapper) {
|
||||
padding-left: 40px;
|
||||
}
|
||||
|
||||
.type-select {
|
||||
width: 160px;
|
||||
}
|
||||
|
||||
/* Stats Bar */
|
||||
.stats-bar {
|
||||
margin-bottom: 24px;
|
||||
font-size: 14px;
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
.stats-bar strong {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
/* Dataset Grid */
|
||||
.dataset-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.dataset-card {
|
||||
background: var(--bg-secondary);
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-lg);
|
||||
overflow: hidden;
|
||||
transition: all var(--transition-base);
|
||||
animation: cardIn 0.5s ease backwards;
|
||||
animation-delay: var(--delay);
|
||||
}
|
||||
|
||||
@keyframes cardIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(20px) scale(0.95);
|
||||
}
|
||||
}
|
||||
|
||||
.dataset-card:hover {
|
||||
border-color: var(--accent-primary);
|
||||
transform: translateY(-4px);
|
||||
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.card-cover {
|
||||
height: 120px;
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.cover-gradient {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: linear-gradient(135deg, #22d3ee 0%, #7c3aed 50%, #06b6d4 100%);
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.cover-pattern {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background-image: radial-gradient(circle at 25% 25%, rgba(255,255,255,0.1) 1px, transparent 1px);
|
||||
background-size: 20px 20px;
|
||||
}
|
||||
|
||||
.cover-icon {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
color: white;
|
||||
filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
|
||||
}
|
||||
|
||||
.card-body {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.card-desc {
|
||||
font-size: 13px;
|
||||
color: var(--text-tertiary);
|
||||
line-height: 1.5;
|
||||
margin-bottom: 14px;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.card-stats {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.card-tags {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.card-footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding-top: 14px;
|
||||
border-top: 1px solid var(--border-subtle);
|
||||
}
|
||||
|
||||
.card-date {
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.card-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
/* Empty State */
|
||||
.empty-state {
|
||||
grid-column: 1 / -1;
|
||||
text-align: center;
|
||||
padding: 80px 0;
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
.empty-state .el-icon {
|
||||
margin-bottom: 16px;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.empty-state h3 {
|
||||
font-size: 18px;
|
||||
margin-bottom: 8px;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.empty-state p {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
/* Responsive */
|
||||
@media (max-width: 768px) {
|
||||
.filters {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.search-box {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.type-select {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.dataset-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user