Files
37duAutomation/desktop/controlplane/frontend/src/views/OverviewView.vue
T
puddy 84d3e103ec refactor: 整体迁移控制面至MySQL + 替换UI框架为Element Plus
1. 移除naive-ui依赖,迁移前端至Element Plus
2. 重构后端数据库层,切换为MySQL替代SQLite
3. 调整项目部署架构,停止exe打包改为源码部署
4. 新增设备上报接口与相关数据库模型
5. 优化配置路径与SQL语法,替换为MySQL占位符格式
6. 调整站点名称与文案,统一为「37du 插件管理平台」
7. 新增SQLite到MySQL迁移脚本
2026-09-16 15:58:45 +08:00

103 lines
4.6 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="page">
<div class="page-head cp-rise">
<div>
<h3>概览 <span class="badge">Dashboard</span></h3>
<p>中心机 · 插件分发与账号权限 · 当前账号 <b class="who">{{ store.nickname || store.current }}</b></p>
</div>
<el-button :loading="overviewBusy" :icon="Refresh" @click="refresh">刷新</el-button>
</div>
<div class="stat-grid" v-if="ov">
<div class="stat-card cp-card cp-rise" v-for="(s, i) in stats" :key="s.label" :class="{ wide: s.wide }" :style="{ animationDelay: i * 60 + 'ms' }">
<div class="stat-ic" :style="{ background: s.bg, color: s.color }">
<el-icon :size="20"><component :is="s.icon" /></el-icon>
</div>
<div class="stat-meta">
<div class="stat-num mono" :class="{ sm: s.small }">{{ s.value }}</div>
<div class="stat-label">{{ s.label }}</div>
</div>
<span class="stat-glow" :style="{ background: s.color }"></span>
</div>
</div>
<el-skeleton v-else-if="overviewBusy" animated :rows="3" style="margin-top: 20px" />
<div class="tip-card cp-card cp-rise">
<div class="tip-ic"><el-icon :size="18"><InfoFilled /></el-icon></div>
<div class="tip-body">
<b>使用说明</b>
<p>「插件管理」上传与发布插件包(每插件保留最近 3 个版本);「账号管理」建号与账号维护;「权限授权」按账号勾选可用的插件与平台。部署机(webhost)仅在启动与手动刷新时拉取插件,授权变更后需在部署机刷新生效。</p>
</div>
</div>
</div>
</template>
<script setup>
import { computed, onMounted } from 'vue'
import { Refresh, InfoFilled, Box, Collection, User, UserFilled, UploadFilled } from '@element-plus/icons-vue'
import { ElMessage as message } from 'element-plus'
import { store, overview, overviewBusy, loadOverview } from '../store'
import { fmtTime } from '../format'
const ov = computed(() => overview.value)
const stats = computed(() => {
const plugins = ov.value?.plugins || []
return [
{ label: '插件', value: plugins.length, icon: Box, color: '#2f5cf0', bg: 'linear-gradient(135deg,#e8edfe,#d7e1fd)' },
{ label: '版本总数', value: plugins.reduce((n, p) => n + (p.versions?.length || 0), 0), icon: Collection, color: '#7c5cf6', bg: 'linear-gradient(135deg,#f0ebfe,#e4dcfd)' },
{ label: '账号', value: (ov.value?.accounts || []).length, icon: User, color: '#0f9f9b', bg: 'linear-gradient(135deg,#e4f6f5,#d2efee)' },
{ label: '管理员', value: (ov.value?.admins || []).length, icon: UserFilled, color: '#1d9d5c', bg: 'linear-gradient(135deg,#e5f6ed,#d2efe0)' },
{ label: '最近上传', value: latest(), icon: UploadFilled, color: '#d97706', bg: 'linear-gradient(135deg,#fbf0df,#f6e4c8)', small: true, wide: true },
]
})
function latest() {
const all = (ov.value?.plugins || []).flatMap(p => p.versions || []).map(v => v.uploaded_at).filter(Boolean)
if (!all.length) return '—'
return fmtTime(all.sort().at(-1))
}
async function refresh() {
try { await loadOverview(true) } catch (e) { message.error('读取失败:' + (e.message || e)) }
}
onMounted(refresh)
</script>
<style scoped>
.stat-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(236px, 1fr));
gap: 18px;
}
.stat-card {
display: flex; align-items: center; gap: 16px;
padding: 20px;
overflow: hidden;
}
.stat-card.wide { grid-column: span 2; }
.stat-ic {
width: 48px; height: 48px; border-radius: 14px; flex-shrink: 0;
display: grid; place-items: center;
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .7);
}
.stat-meta { min-width: 0; }
.stat-num { font-size: 27px; font-weight: 800; letter-spacing: .3px; line-height: 1.15; color: var(--cp-ink-1); }
.stat-num.sm { font-size: 18px; font-weight: 700; white-space: nowrap; line-height: 1.4; }
.stat-label { font-size: 12px; color: var(--cp-ink-3); margin-top: 4px; letter-spacing: .3px; }
.stat-glow { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; border-radius: 0 6px 6px 0; opacity: .9; }
.tip-card {
margin-top: 20px;
display: flex; gap: 14px;
padding: 20px 22px;
background: linear-gradient(135deg, rgba(47, 92, 240, .05), rgba(15, 159, 155, .04)), var(--cp-panel);
}
.tip-ic {
width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
display: grid; place-items: center;
background: linear-gradient(135deg, var(--cp-blue), var(--cp-teal));
color: #fff;
box-shadow: 0 8px 16px -8px rgba(47, 92, 240, .6);
}
.tip-body b { display: block; font-size: 14px; color: var(--cp-ink-1); margin-bottom: 5px; }
.tip-body p { margin: 0; font-size: 12.5px; line-height: 1.8; color: var(--cp-ink-2); }
</style>