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:
+52
-18
@@ -14,7 +14,7 @@
|
||||
<!-- Hero 大图 -->
|
||||
<section class="relative h-[60vh] md:h-[70vh] overflow-hidden">
|
||||
<img
|
||||
:src="project.image"
|
||||
:src="project.image || ''"
|
||||
:alt="title"
|
||||
class="w-full h-full object-cover"
|
||||
/>
|
||||
@@ -34,7 +34,7 @@
|
||||
{{ title }}
|
||||
</h1>
|
||||
<p class="text-lg md:text-xl text-white/80 max-w-2xl">
|
||||
{{ t(`work.items.${slug}.description`) }}
|
||||
{{ description }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -48,26 +48,26 @@
|
||||
<div>
|
||||
<h2 class="text-2xl md:text-3xl font-bold text-black mb-6">{{ t('work.detail.overview') }}</h2>
|
||||
<p class="text-gray-700 text-base md:text-lg leading-relaxed">
|
||||
{{ t(`work.detail.items.${slug}.overview`) }}
|
||||
{{ locText(project.overviewZh, project.overviewEn) }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2 class="text-2xl md:text-3xl font-bold text-black mb-6">{{ t('work.detail.challenge') }}</h2>
|
||||
<p class="text-gray-700 text-base md:text-lg leading-relaxed">
|
||||
{{ t(`work.detail.items.${slug}.challenge`) }}
|
||||
{{ locText(project.challengeZh, project.challengeEn) }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2 class="text-2xl md:text-3xl font-bold text-black mb-6">{{ t('work.detail.solution') }}</h2>
|
||||
<p class="text-gray-700 text-base md:text-lg leading-relaxed">
|
||||
{{ t(`work.detail.items.${slug}.solution`) }}
|
||||
{{ locText(project.solutionZh, project.solutionEn) }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- 项目截图 -->
|
||||
<div class="space-y-6">
|
||||
<div v-if="project.gallery.length" class="space-y-6">
|
||||
<h2 class="text-2xl md:text-3xl font-bold text-black">{{ t('work.detail.gallery') }}</h2>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div
|
||||
@@ -89,7 +89,7 @@
|
||||
<div class="space-y-5">
|
||||
<div>
|
||||
<p class="text-sm text-gray-500 mb-1">{{ t('work.detail.client') }}</p>
|
||||
<p class="text-base font-semibold text-black">{{ t(`work.detail.items.${slug}.client`) }}</p>
|
||||
<p class="text-base font-semibold text-black">{{ locText(project.clientZh, project.clientEn) }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-sm text-gray-500 mb-1">{{ t('work.detail.year') }}</p>
|
||||
@@ -97,7 +97,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-sm text-gray-500 mb-1">{{ t('work.detail.duration') }}</p>
|
||||
<p class="text-base font-semibold text-black">{{ t(`work.detail.items.${slug}.duration`) }}</p>
|
||||
<p class="text-base font-semibold text-black">{{ locText(project.durationZh, project.durationEn) }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-sm text-gray-500 mb-1">{{ t('work.detail.services') }}</p>
|
||||
@@ -146,11 +146,11 @@
|
||||
class="group block rounded-2xl overflow-hidden bg-white shadow-lg hover:shadow-xl transition-all duration-300 hover:-translate-y-1"
|
||||
>
|
||||
<div class="relative aspect-[4/3] overflow-hidden">
|
||||
<img :src="related.image" :alt="t(`work.items.${related.slug}.title`)" class="w-full h-full object-cover transition-transform duration-500 group-hover:scale-105" />
|
||||
<img :src="related.image || ''" :alt="locText(related.titleZh, related.titleEn)" class="w-full h-full object-cover transition-transform duration-500 group-hover:scale-105" />
|
||||
</div>
|
||||
<div class="p-5">
|
||||
<h3 class="text-lg font-bold text-black group-hover:text-gray-600 transition-colors">{{ t(`work.items.${related.slug}.title`) }}</h3>
|
||||
<p class="text-sm text-gray-500 mt-1">{{ related.tags[0] }}</p>
|
||||
<h3 class="text-lg font-bold text-black group-hover:text-gray-600 transition-colors">{{ locText(related.titleZh, related.titleEn) }}</h3>
|
||||
<p class="text-sm text-gray-500 mt-1">{{ related.tags?.[0] }}</p>
|
||||
</div>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
@@ -164,24 +164,58 @@ import { computed } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useSeoMeta, createError } from '#imports'
|
||||
import { workBySlug, workItems } from '~/data/work'
|
||||
|
||||
const { t } = useI18n()
|
||||
const { t, locale } = useI18n()
|
||||
const route = useRoute()
|
||||
const slug = route.params.slug as string
|
||||
|
||||
const project = workBySlug[slug]
|
||||
interface WorkItem {
|
||||
slug: string
|
||||
category: 'webDesign' | 'branding' | 'development'
|
||||
titleZh: string
|
||||
titleEn: string
|
||||
descriptionZh: string
|
||||
descriptionEn: string
|
||||
overviewZh: string
|
||||
overviewEn: string
|
||||
challengeZh: string
|
||||
challengeEn: string
|
||||
solutionZh: string
|
||||
solutionEn: string
|
||||
clientZh: string
|
||||
clientEn: string
|
||||
durationZh: string
|
||||
durationEn: string
|
||||
year: string
|
||||
tags: string[]
|
||||
image: string | null
|
||||
gallery: string[]
|
||||
url: string | null
|
||||
}
|
||||
|
||||
if (!project) {
|
||||
const [{ data, error }, { data: listData }] = await Promise.all([
|
||||
useFetch<{ work: WorkItem }>(`/api/work/${slug}`),
|
||||
useFetch<{ works: WorkItem[] }>('/api/work'),
|
||||
])
|
||||
|
||||
// 未发布 / 不存在 → 404
|
||||
if (error.value || !data.value?.work) {
|
||||
throw createError({ statusCode: 404, statusMessage: 'Project not found' })
|
||||
}
|
||||
|
||||
const title = computed(() => t(`work.items.${slug}.title`))
|
||||
const project = computed<WorkItem>(() => data.value!.work)
|
||||
|
||||
const relatedProjects = workItems.filter((p) => p.slug !== slug).slice(0, 3)
|
||||
const locText = (zh: string, en: string) => (locale.value === 'zh' ? zh : en)
|
||||
|
||||
const title = computed(() => locText(project.value.titleZh, project.value.titleEn))
|
||||
const description = computed(() => locText(project.value.descriptionZh, project.value.descriptionEn))
|
||||
|
||||
const relatedProjects = computed(() =>
|
||||
(listData.value?.works ?? []).filter((p) => p.slug !== slug).slice(0, 3),
|
||||
)
|
||||
|
||||
useSeoMeta({
|
||||
title: () => `${title.value} - ${t('work.title')}`,
|
||||
description: () => t(`work.items.${slug}.description`),
|
||||
description: () => description.value,
|
||||
})
|
||||
</script>
|
||||
|
||||
+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