feat: 后台管理系统(Admin Backend + 全量 CMS)

- 内容迁入数据库:articles/works 表(中英双语 + 内容块),
  server/utils/seed.ts 灌入现有 6 动态 + 6 作品,站点初始内容不变
- 前台内容 API:/api/news、/api/work(列表/详情,仅已发布),
  页面/首页组件改为 useFetch 拉取并按 locale 选 zh/en 字段
- 后台管理 /admin(admin 中间件守卫):
  - Dashboard 统计、动态/作品增删改(块编辑器、图片上传 /api/admin/upload)
  - 用户管理(角色切换/删除)、评论审核、联系/订阅管理(导出 CSV)
- 预置管理员:NUXT_ADMIN_INITIAL_PASSWORD 首次初始化创建 admin 账号
- 图片自托管:上传存 PVC /data/uploads,/uploads/[...] 路由服务
- sitemap 改查 DB;i18n 移除内容键(305 键对齐);删除 app/data 冗余模块
- 角色以数据库为准(后台可切换);admin 中间件 + 客户端会话恢复插件
This commit is contained in:
2026-08-06 16:15:14 +08:00
parent 5c3f3bca63
commit d67849a311
67 changed files with 4909 additions and 754 deletions
+68
View File
@@ -0,0 +1,68 @@
<script setup lang="ts">
/**
* 后台左侧导航栏(Dashboard / 动态 / 作品 / 用户 / 评论 / 联系 / 订阅 / 返回前台)。
* 高亮当前路由;点击任意导航项时向父级发出 navigate 事件(移动端关闭侧栏)。
*/
import { useRoute } from '#app'
import { siteConfig } from '~/config/site'
const route = useRoute()
const emit = defineEmits<{ navigate: [] }>()
const items = [
{ to: '/admin', label: 'Dashboard', icon: 'ph:gauge' },
{ to: '/admin/news', label: '动态管理', icon: 'ph:newspaper' },
{ to: '/admin/work', label: '作品管理', icon: 'ph:image-square' },
{ to: '/admin/users', label: '用户管理', icon: 'ph:users-three' },
{ to: '/admin/comments', label: '评论管理', icon: 'ph:chat-circle-text' },
{ to: '/admin/contacts', label: '联系留言', icon: 'ph:envelope-simple' },
{ to: '/admin/subscribers', label: '订阅管理', icon: 'ph:paper-plane-tilt' },
]
const isActive = (to: string) => route.path === to
</script>
<template>
<div class="flex flex-col h-full bg-black text-white">
<NuxtLink
to="/admin"
class="flex items-center gap-3 px-5 h-16 border-b border-white/10 shrink-0"
@click="emit('navigate')"
>
<div
class="w-8 h-8 rounded-full bg-white text-black flex items-center justify-center font-bold text-sm"
>
A
</div>
<div class="leading-tight">
<p class="text-sm font-bold">{{ siteConfig.brandZh }}</p>
<p class="text-[11px] text-white/50">后台管理</p>
</div>
</NuxtLink>
<nav class="flex-1 py-4 px-3 space-y-1 overflow-y-auto">
<NuxtLink
v-for="item in items"
:key="item.to"
:to="item.to"
class="flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm font-medium transition-colors"
:class="isActive(item.to) ? 'bg-white text-black' : 'text-white/70 hover:bg-white/10 hover:text-white'"
@click="emit('navigate')"
>
<Icon :name="item.icon" class="w-[18px] h-[18px]" />
{{ item.label }}
</NuxtLink>
</nav>
<div class="p-3 border-t border-white/10 shrink-0">
<NuxtLink
to="/"
class="flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm font-medium text-white/70 hover:bg-white/10 hover:text-white transition-colors"
@click="emit('navigate')"
>
<Icon name="ph:arrow-left" class="w-[18px] h-[18px]" />
返回前台
</NuxtLink>
</div>
</div>
</template>