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:
+28
-10
@@ -58,8 +58,8 @@
|
||||
>
|
||||
<div class="relative aspect-[4/3] overflow-hidden bg-gray-100">
|
||||
<img
|
||||
:src="project.image"
|
||||
:alt="t(`work.items.${project.slug}.title`)"
|
||||
:src="project.image || ''"
|
||||
:alt="locText(project.titleZh, project.titleEn)"
|
||||
:loading="'lazy'"
|
||||
class="w-full h-full object-cover transition-transform duration-700 group-hover:scale-110"
|
||||
/>
|
||||
@@ -69,13 +69,13 @@
|
||||
<div class="p-6 md:p-8 bg-white">
|
||||
<div class="flex items-start justify-between mb-3">
|
||||
<h3 class="text-xl md:text-2xl font-bold text-black group-hover:text-gray-700 transition-colors duration-300">
|
||||
{{ t(`work.items.${project.slug}.title`) }}
|
||||
{{ locText(project.titleZh, project.titleEn) }}
|
||||
</h3>
|
||||
<div class="w-9 h-9 md:w-10 md:h-10 rounded-full flex items-center justify-center bg-gray-50 text-gray-400 group-hover:bg-black group-hover:text-white transition-all duration-300 flex-shrink-0 ml-3">
|
||||
<Icon name="ph:arrow-up-right" class="w-4 h-4 md:w-5 md:h-5" />
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-sm md:text-base text-gray-600 mb-4">{{ t(`work.items.${project.slug}.description`) }}</p>
|
||||
<p class="text-sm md:text-base text-gray-600 mb-4">{{ locText(project.descriptionZh, project.descriptionEn) }}</p>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<span
|
||||
v-for="tag in project.tags"
|
||||
@@ -111,11 +111,29 @@ import { useI18n } from 'vue-i18n'
|
||||
import { useSeoMeta } from '#imports'
|
||||
import gsap from 'gsap'
|
||||
import { useAppStore } from '~/stores/app'
|
||||
import { workItems, getWorkCategories } from '~/data/work'
|
||||
|
||||
const { t } = useI18n()
|
||||
const { t, locale } = useI18n()
|
||||
const appStore = useAppStore()
|
||||
|
||||
interface WorkItem {
|
||||
slug: string
|
||||
category: 'webDesign' | 'branding' | 'development'
|
||||
titleZh: string
|
||||
titleEn: string
|
||||
descriptionZh: string
|
||||
descriptionEn: string
|
||||
year: string
|
||||
tags: string[]
|
||||
image: string | null
|
||||
}
|
||||
|
||||
// 内容 API(仅已发布)
|
||||
const { data } = await useFetch<{ works: WorkItem[] }>('/api/work')
|
||||
const works = computed(() => data.value?.works ?? [])
|
||||
|
||||
// 双语选择:切换语言即时生效
|
||||
const locText = (zh: string, en: string) => (locale.value === 'zh' ? zh : en)
|
||||
|
||||
const headerWrapRef = ref<HTMLElement | null>(null)
|
||||
const titleRef = ref<HTMLElement | null>(null)
|
||||
const descRef = ref<HTMLElement | null>(null)
|
||||
@@ -128,16 +146,16 @@ const visibleCount = ref(0)
|
||||
|
||||
const PAGE_SIZE = 4
|
||||
|
||||
const categories = ['all', ...getWorkCategories()]
|
||||
const categories = ['all', 'webDesign', 'branding', 'development']
|
||||
|
||||
// 分类 + 搜索过滤(标题/描述按当前语言文案匹配)
|
||||
const filteredWork = computed(() => {
|
||||
const kw = keyword.value.trim().toLowerCase()
|
||||
return workItems.filter((item) => {
|
||||
return works.value.filter((item) => {
|
||||
if (activeCategory.value !== 'all' && item.category !== activeCategory.value) return false
|
||||
if (!kw) return true
|
||||
const title = t(`work.items.${item.slug}.title`).toLowerCase()
|
||||
const desc = t(`work.items.${item.slug}.description`).toLowerCase()
|
||||
const title = locText(item.titleZh, item.titleEn).toLowerCase()
|
||||
const desc = locText(item.descriptionZh, item.descriptionEn).toLowerCase()
|
||||
return title.includes(kw) || desc.includes(kw)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user