feat: 初始化 yx-nav 网址导航项目
- 技术栈: Vue3+TS+Vite + Express+SQLite - 前台: 分类导航页、搜索、访问统计 - 后台: 仪表盘、网址CRUD、分类管理、站点配置 - 默认账号: admin / admin123
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
<template>
|
||||
<div class="dashboard">
|
||||
<el-row :gutter="20" class="stat-cards">
|
||||
<el-col :span="6">
|
||||
<el-card shadow="hover">
|
||||
<div class="stat-item">
|
||||
<span class="num">{{ stats.linkCount }}</span>
|
||||
<span class="label">网址总数</span>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-card shadow="hover">
|
||||
<div class="stat-item">
|
||||
<span class="num">{{ stats.catCount }}</span>
|
||||
<span class="label">分类数</span>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-card shadow="hover">
|
||||
<div class="stat-item">
|
||||
<span class="num">{{ stats.totalViews }}</span>
|
||||
<span class="label">总访问</span>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-card shadow="hover">
|
||||
<div class="stat-item">
|
||||
<span class="num">{{ settings.site_name }}</span>
|
||||
<span class="label">站点名称</span>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-card style="margin-top:24px">
|
||||
<template #header>
|
||||
<span>快捷操作</span>
|
||||
</template>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="6">
|
||||
<el-button type="primary" block @click="$router.push('/admin/links')">
|
||||
<el-icon><Plus /></el-icon> 管理网址
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-button type="success" block @click="$router.push('/admin/categories')">
|
||||
<el-icon><FolderAdd /></el-icon> 管理分类
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-button type="warning" block @click="$router.push('/admin/settings')">
|
||||
<el-icon><Setting /></el-icon> 站点配置
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-button block @click="() => window.open('/', '_blank')">
|
||||
<el-icon><View /></el-icon> 预览前台
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-card>
|
||||
|
||||
<el-card style="margin-top:24px">
|
||||
<template #header><span>分类概览</span></template>
|
||||
<el-table :data="categories" style="width:100%">
|
||||
<el-table-column prop="name" label="分类" />
|
||||
<el-table-column prop="linkCount" label="网址数" width="100" />
|
||||
<el-table-column prop="icon" label="图标" width="80" />
|
||||
</el-table>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { Plus, FolderAdd, Setting, View } from '@element-plus/icons-vue'
|
||||
import { adminApi } from '@/api'
|
||||
|
||||
const stats = ref({ linkCount: 0, catCount: 0, totalViews: 0 })
|
||||
const settings = ref({})
|
||||
const categories = ref([])
|
||||
|
||||
onMounted(async () => {
|
||||
const [statsRes, setRes] = await Promise.all([
|
||||
adminApi.getCategories(),
|
||||
adminApi.getSettings()
|
||||
])
|
||||
categories.value = statsRes.result.data
|
||||
settings.value = setRes.result.data
|
||||
stats.value = {
|
||||
catCount: categories.value.length,
|
||||
linkCount: categories.value.reduce((s: number, c: any) => s + (c.linkCount || 0), 0),
|
||||
totalViews: 0,
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.stat-cards { margin-bottom: 8px; }
|
||||
.stat-item { text-align: center; }
|
||||
.stat-item .num { display: block; font-size: 36px; font-weight: 700; color: #6366f1; margin-bottom: 8px; }
|
||||
.stat-item .label { color: #888; font-size: 14px; }
|
||||
</style>
|
||||
Reference in New Issue
Block a user