Files
word-market/frontend/src/layouts/AdminLayout.vue
T
voidandClaude Sonnet 4.6 4e68ba3890 feat(admin): 实现只读词库管理后台
- 新增 Spring Boot 3 后端:JWT 认证、六个业务模块查询接口、Caffeine 聚合缓存与只读事务约束
- 新增 Vue 3 管理前端:登录、概览、词书、词条、词根词族、近反义词与数据质量
- 补充前后端 README、环境变量示例与本地构建部署说明
- 同步 OpenSpec 变更文档与任务进度(64/65,只读数据库账号待确认)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-11-08 22:55:15 +08:00

215 lines
4.3 KiB
Vue

<script setup lang="ts">
import { computed } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import {
Collection,
Connection,
DataAnalysis,
Reading,
Switch,
Warning
} from '@element-plus/icons-vue'
import { useAuthStore } from '@/stores/auth'
const route = useRoute()
const router = useRouter()
const auth = useAuthStore()
const activeMenu = computed(() => {
if (route.path === '/') return '/'
return `/${route.path.split('/')[1]}`
})
const pageTitle = computed(() => String(route.meta.title ?? '概览'))
const initials = computed(() => (auth.username || 'AD').slice(0, 2).toUpperCase())
function logout(): void {
auth.logout()
void router.replace({ name: 'login' })
}
</script>
<template>
<div class="admin-shell">
<aside class="sidebar">
<div class="brand">
<div class="brand-mark">W</div>
<div>
<div class="brand-name">Word Market</div>
<div class="brand-sub">词库管理后台</div>
</div>
</div>
<el-menu :default-active="activeMenu" router class="nav">
<el-menu-item index="/">
<el-icon><DataAnalysis /></el-icon>
<span>概览</span>
</el-menu-item>
<el-menu-item index="/books">
<el-icon><Reading /></el-icon>
<span>词书管理</span>
</el-menu-item>
<el-menu-item index="/entries">
<el-icon><Collection /></el-icon>
<span>词条词典</span>
</el-menu-item>
<el-menu-item index="/morphology">
<el-icon><Connection /></el-icon>
<span>词根词族</span>
</el-menu-item>
<el-menu-item index="/synonyms">
<el-icon><Switch /></el-icon>
<span>近反义词</span>
</el-menu-item>
<el-menu-item index="/quality">
<el-icon><Warning /></el-icon>
<span>数据质量</span>
</el-menu-item>
</el-menu>
<div class="side-foot">只读模式 · 数据快照 2026-11-08</div>
</aside>
<main class="main">
<header class="topbar">
<div class="crumb">后台 / <b>{{ pageTitle }}</b></div>
<div class="top-actions">
<el-tag type="info" effect="plain" round>只读模式</el-tag>
<span class="user-name">{{ auth.username || 'admin' }}</span>
<div class="avatar">{{ initials }}</div>
<el-button link type="primary" size="small" @click="logout">退出</el-button>
</div>
</header>
<router-view />
</main>
</div>
</template>
<style scoped>
.admin-shell {
display: grid;
grid-template-columns: 228px minmax(0, 1fr);
min-height: 100vh;
background: #f3f5f8;
}
.sidebar {
position: sticky;
top: 0;
align-self: start;
height: 100vh;
display: flex;
flex-direction: column;
padding: 22px 16px;
background: #fff;
border-right: 1px solid #e5e7eb;
overflow-y: auto;
}
.brand {
display: flex;
align-items: center;
gap: 10px;
padding: 0 6px 22px;
}
.brand-mark {
width: 34px;
height: 34px;
border-radius: 9px;
background: linear-gradient(135deg, #2563eb, #7c3aed);
color: #fff;
display: grid;
place-items: center;
font-weight: 700;
}
.brand-name {
font-size: 15px;
font-weight: 700;
}
.brand-sub {
font-size: 11px;
color: #9ca3af;
}
.nav {
border-right: 0;
}
.nav :deep(.el-menu-item) {
height: 40px;
line-height: 40px;
margin: 2px 0;
border-radius: 8px;
color: #4b5563;
font-size: 13.5px;
}
.nav :deep(.el-menu-item.is-active) {
background: #eef2ff;
color: #4338ca;
font-weight: 600;
}
.nav :deep(.el-menu-item:hover) {
background: #f5f7fa;
}
.side-foot {
margin-top: auto;
border-top: 1px solid #eef0f3;
padding-top: 14px;
font-size: 12px;
color: #9ca3af;
}
.main {
min-width: 0;
padding: 0 26px 60px;
}
.topbar {
height: 62px;
display: flex;
align-items: center;
justify-content: space-between;
border-bottom: 1px solid #e5e7eb;
margin-bottom: 22px;
}
.crumb {
font-size: 13px;
color: #6b7280;
}
.crumb b {
color: #111827;
}
.top-actions {
display: flex;
align-items: center;
gap: 10px;
}
.avatar {
width: 32px;
height: 32px;
border-radius: 50%;
background: #e0e7ff;
color: #4338ca;
display: grid;
place-items: center;
font-size: 12px;
font-weight: 700;
}
.user-name {
font-size: 12.5px;
color: #4b5563;
}
</style>