feat: 全量落地后端与功能闭环

- 真实后端(server/):SQLite 存储 + scrypt 会话鉴权 + SMTP 邮件
  - auth 注册/登录/登出/me/资料更新
  - contact 联系表单(落库+邮件)、newsletter 订阅(去重)
  - favorites 作品收藏、comments 新闻评论、account 管理收件箱
- 用户系统 UI:个人中心 /account(资料/收藏/评论/管理员面板)、
  收藏按钮、评论组件、登录/注册弹窗接真实 API(useApiError 错误映射)
- 内容单点事实源:app/data/news|work 消除三处重复,页面全部引用
- 修复断链:首页动态/作品卡可点击、分享按钮真实动作、移除 # 死链、
  语言切换器、社交链接统一 siteConfig
- SEO:动态 sitemap/robots、JSON-LD、脚本生成真实 og-image.png
- 列表增强:搜索 + 加载更多
- 部署自动化:build-and-push.sh 支持 git tag 版本化镜像;
  deploy.sh 一条命令构建推送+注入 Secret/ConfigMap+kubectl 滚动升级;
  deployment 挂 PVC 持久化;Dockerfile 支持 better-sqlite3 原生编译
- 组件注册去目录前缀,修复 AppLoader/AnimatedButton 等未渲染问题
This commit is contained in:
2026-08-06 15:00:56 +08:00
parent 6192ae0a38
commit 5c3f3bca63
61 changed files with 3408 additions and 1318 deletions
+308
View File
@@ -0,0 +1,308 @@
<template>
<main class="page-container min-h-screen pt-32 pb-20 px-4 md:px-8 mx-auto max-w-[1200px]">
<!-- 未登录 -->
<div
v-if="!userStore.isAuthenticated"
class="max-w-md mx-auto mt-16 p-10 rounded-3xl bg-white border border-gray-100 shadow-xl text-center"
>
<div class="w-16 h-16 mx-auto rounded-full bg-gray-100 flex items-center justify-center mb-6">
<Icon name="ph:user-duotone" class="w-8 h-8 text-gray-400" />
</div>
<h1 class="text-2xl font-bold text-black mb-3">{{ t('account.title') }}</h1>
<p class="text-gray-500 mb-8">{{ t('auth.loginRequired') }}</p>
<button
@click="authModal.openLogin()"
class="px-8 py-3 rounded-full bg-black text-white font-semibold hover:bg-gray-800 transition-colors"
>
{{ t('auth.login') }}
</button>
</div>
<!-- 已登录 -->
<div v-else>
<div class="mb-10 text-center">
<img :src="userStore.avatar" :alt="userStore.user?.username" class="w-20 h-20 rounded-full object-cover mx-auto mb-4" />
<h1 class="text-3xl md:text-4xl font-bold text-black mb-2">{{ userStore.user?.username }}</h1>
<p class="text-gray-500">{{ userStore.user?.email }}</p>
</div>
<!-- 页签 -->
<div class="flex justify-center gap-2 md:gap-3 mb-10 flex-wrap">
<button
v-for="tab in tabs"
:key="tab.key"
@click="switchTab(tab.key)"
class="px-5 py-2 rounded-full text-sm md:text-base font-semibold transition-all duration-300"
:class="activeTab === tab.key ? 'bg-black text-white shadow-lg' : 'bg-gray-100 text-gray-700 hover:bg-gray-200'"
>
{{ tab.label }}
</button>
</div>
<!-- 个人资料 -->
<section v-if="activeTab === 'profile'" class="max-w-lg mx-auto space-y-5">
<div class="p-6 rounded-2xl bg-white border border-gray-100 shadow-sm space-y-5">
<div>
<label class="block text-sm font-semibold text-gray-800 mb-2">{{ t('account.username') }}</label>
<input v-model="profileForm.username" type="text" class="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-black focus:ring-2 focus:ring-black/5 outline-none transition-all" />
</div>
<div>
<label class="block text-sm font-semibold text-gray-800 mb-2">{{ t('account.phone') }}</label>
<input v-model="profileForm.phone" type="tel" class="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-black focus:ring-2 focus:ring-black/5 outline-none transition-all" />
</div>
<div>
<label class="block text-sm font-semibold text-gray-800 mb-2">{{ t('account.email') }}</label>
<input :value="userStore.user?.email" type="email" disabled class="w-full px-4 py-3 rounded-xl border border-gray-200 bg-gray-50 text-gray-500 cursor-not-allowed" />
</div>
<div class="grid grid-cols-2 gap-4 text-sm text-gray-600">
<div>
<p class="text-gray-400 mb-1">{{ t('account.joinedAt') }}</p>
<p class="font-medium text-black">{{ formatDate(userStore.user?.createdAt) }}</p>
</div>
<div>
<p class="text-gray-400 mb-1">{{ t('account.role') }}</p>
<p class="font-medium text-black">
{{ userStore.user?.role === 'admin' ? t('account.roleAdmin') : t('account.roleUser') }}
</p>
</div>
</div>
<p v-if="saveMessage" class="text-sm" :class="saveFailed ? 'text-red-600' : 'text-green-600'">{{ saveMessage }}</p>
<button
@click="saveProfile"
:disabled="saving"
class="w-full py-3 rounded-xl bg-black text-white font-semibold flex items-center justify-center gap-2 transition-colors disabled:opacity-50"
>
<Icon v-if="saving" name="ph:circle-notch" class="w-5 h-5 animate-spin" />
{{ saving ? t('account.saving') : t('account.save') }}
</button>
</div>
</section>
<!-- 我的收藏 -->
<section v-if="activeTab === 'favorites'" class="max-w-3xl mx-auto">
<p v-if="!favorites.length" class="text-center text-gray-500 py-12">{{ t('account.emptyFavorites') }}</p>
<div v-else class="grid grid-cols-1 sm:grid-cols-2 gap-5">
<div
v-for="slug in favorites"
:key="slug"
class="group rounded-2xl overflow-hidden bg-white border border-gray-100 shadow-sm hover:shadow-xl transition-all duration-300"
>
<NuxtLink :to="`/work/${slug}`" class="block relative aspect-[4/3] overflow-hidden">
<img :src="workBySlug[slug]?.image" :alt="t(`work.items.${slug}.title`)" class="w-full h-full object-cover transition-transform duration-500 group-hover:scale-105" />
</NuxtLink>
<div class="p-5 flex items-center justify-between">
<NuxtLink :to="`/work/${slug}`" class="font-bold text-black group-hover:text-gray-600 transition-colors">
{{ t(`work.items.${slug}.title`) }}
</NuxtLink>
<button
@click="removeFavorite(slug)"
class="w-9 h-9 rounded-full bg-gray-50 text-gray-500 hover:bg-red-50 hover:text-red-600 flex items-center justify-center transition-colors"
aria-label="unfavorite"
>
<Icon name="ph:bookmark-simple-fill" class="w-4 h-4" />
</button>
</div>
</div>
</div>
</section>
<!-- 我的评论 -->
<section v-if="activeTab === 'comments'" class="max-w-2xl mx-auto space-y-4">
<p v-if="!myComments.length" class="text-center text-gray-500 py-12">{{ t('account.emptyComments') }}</p>
<div
v-for="comment in myComments"
:key="comment.id"
class="p-5 rounded-2xl bg-white border border-gray-100 shadow-sm"
>
<div class="flex items-center justify-between mb-2">
<NuxtLink :to="`/news/${comment.newsSlug}`" class="text-sm font-semibold text-black hover:text-gray-600">
{{ t(`news.items.${comment.newsSlug}.title`) }}
</NuxtLink>
<span class="text-xs text-gray-400">{{ formatDate(comment.createdAt) }}</span>
</div>
<p class="text-gray-700 text-sm break-words">{{ comment.content }}</p>
</div>
</section>
<!-- 管理面板 -->
<section v-if="activeTab === 'admin'" class="max-w-4xl mx-auto space-y-12">
<div>
<h3 class="text-xl font-bold text-black mb-5">{{ t('account.admin.contacts') }}</h3>
<p v-if="!adminData.contacts.length" class="text-gray-500 text-center py-8">{{ t('account.admin.emptyContacts') }}</p>
<div v-else class="space-y-4">
<div v-for="c in adminData.contacts" :key="c.id" class="p-5 rounded-2xl bg-white border border-gray-100 shadow-sm">
<div class="flex items-center justify-between mb-2">
<div class="flex items-center gap-3">
<span class="font-semibold text-black">{{ c.name }}</span>
<span class="text-sm text-gray-500">{{ c.email }}</span>
</div>
<span class="text-xs px-2 py-1 rounded-full" :class="c.delivered ? 'bg-green-50 text-green-700' : 'bg-amber-50 text-amber-700'">
{{ c.delivered ? t('account.admin.delivered') : t('account.admin.notDelivered') }}
</span>
</div>
<p class="text-sm font-semibold text-gray-700 mb-1">{{ c.subject }}</p>
<p class="text-sm text-gray-600 whitespace-pre-line break-words mb-2">{{ c.message }}</p>
<p class="text-xs text-gray-400">{{ formatDate(c.createdAt) }}</p>
</div>
</div>
</div>
<div>
<h3 class="text-xl font-bold text-black mb-5">{{ t('account.admin.subscribers') }}</h3>
<p v-if="!adminData.subscribers.length" class="text-gray-500 text-center py-8">{{ t('account.admin.emptySubscribers') }}</p>
<div v-else class="rounded-2xl overflow-hidden border border-gray-100 shadow-sm bg-white">
<div v-for="s in adminData.subscribers" :key="s.id" class="flex items-center justify-between px-5 py-3 border-b border-gray-100 last:border-b-0">
<span class="text-sm font-medium text-gray-700">{{ s.email }}</span>
<span class="text-xs text-gray-400">{{ formatDate(s.createdAt) }}</span>
</div>
</div>
</div>
</section>
</div>
</main>
</template>
<script setup lang="ts">
import { nextTick, onBeforeUnmount, onMounted, reactive, ref, computed } from 'vue'
import { useI18n } from 'vue-i18n'
import { useSeoMeta } from '#imports'
import gsap from 'gsap'
import { useUserStore } from '~/stores/user'
import { useAuthModalStore } from '~/stores/authModal'
import { workBySlug } from '~/data/work'
import { useApiError } from '~/composables/useApiError'
const { t, locale } = useI18n()
const userStore = useUserStore()
const authModal = useAuthModalStore()
const apiError = useApiError()
useSeoMeta({
title: () => t('account.title'),
})
const tabs = computed(() => {
const list: Array<{ key: string; label: string }> = [
{ key: 'profile', label: t('account.profile') },
{ key: 'favorites', label: t('account.favorites') },
{ key: 'comments', label: t('account.comments') },
]
if (userStore.user?.role === 'admin') {
list.push({ key: 'admin', label: t('account.adminTitle') })
}
return list
})
const activeTab = ref('profile')
const switchTab = (key: string) => {
activeTab.value = key
if (key === 'favorites') loadFavorites()
if (key === 'comments') loadComments()
if (key === 'admin') loadAdmin()
}
const formatDate = (raw?: string) => {
if (!raw) return ''
const d = new Date(String(raw).replace(' ', 'T') + 'Z')
if (Number.isNaN(d.getTime())) return raw
return new Intl.DateTimeFormat(locale.value === 'zh' ? 'zh-CN' : 'en-US', {
year: 'numeric',
month: 'short',
day: 'numeric',
}).format(d)
}
// ---- 个人资料 ----
const profileForm = reactive({ username: '', phone: '' })
const saving = ref(false)
const saveMessage = ref('')
const saveFailed = ref(false)
const initProfileForm = () => {
profileForm.username = userStore.user?.username ?? ''
profileForm.phone = userStore.user?.phone ?? ''
}
const saveProfile = async () => {
saving.value = true
saveMessage.value = ''
saveFailed.value = false
const result = await userStore.updateProfile({
username: profileForm.username,
phone: profileForm.phone,
})
if (result.success) {
saveMessage.value = t('account.saved')
} else {
saveFailed.value = true
saveMessage.value = apiError({ data: { code: result.code } })
}
saving.value = false
}
// ---- 收藏 ----
const favorites = ref<string[]>([])
const loadFavorites = async () => {
try {
const data = await $fetch<{ slugs: string[] }>('/api/favorites')
favorites.value = data.slugs
} catch (err) {
console.error('load favorites error:', err)
}
}
const removeFavorite = async (slug: string) => {
try {
await $fetch('/api/favorites', { method: 'DELETE', body: { workSlug: slug } })
favorites.value = favorites.value.filter((s) => s !== slug)
} catch (err) {
console.error('remove favorite error:', err)
}
}
// ---- 我的评论 ----
const myComments = ref<Array<{ id: number; newsSlug: string; content: string; createdAt: string }>>([])
const loadComments = async () => {
try {
const data = await $fetch<{ comments: Array<{ id: number; newsSlug: string; content: string; createdAt: string }> }>('/api/account/comments')
myComments.value = data.comments
} catch (err) {
console.error('load comments error:', err)
}
}
// ---- 管理面板 ----
const adminData = reactive<{
contacts: Array<{ id: number; name: string; email: string; subject: string; message: string; delivered: number; createdAt: string }>
subscribers: Array<{ id: number; email: string; createdAt: string }>
}>({ contacts: [], subscribers: [] })
const loadAdmin = async () => {
try {
const data = await $fetch<typeof adminData>('/api/account/admin')
adminData.contacts = data.contacts
adminData.subscribers = data.subscribers
} catch (err) {
console.error('load admin error:', err)
}
}
// ---- 页面进场动画 ----
const mainRef = ref<HTMLElement | null>(null)
let ctx: gsap.Context | null = null
onMounted(async () => {
await nextTick()
initProfileForm()
ctx = gsap.context(() => {
const targets = gsap.utils.toArray<HTMLElement>('[data-animate]', mainRef.value!)
if (targets.length) {
gsap.set(targets, { autoAlpha: 0, y: 24 })
gsap.to(targets, { autoAlpha: 1, y: 0, duration: 0.6, ease: 'power3.out', stagger: 0.08 })
}
}, mainRef.value)
})
onBeforeUnmount(() => {
ctx?.revert()
})
</script>
+10 -36
View File
@@ -139,7 +139,7 @@
</div>
<div>
<h3 class="text-base md:text-lg font-bold text-gray-900 mb-2">Email</h3>
<a href="mailto:chenchun@virtheart.com" class="text-sm md:text-base text-gray-600 hover:text-black transition-colors duration-300">
<a :href="`mailto:${siteConfig.email}`" class="text-sm md:text-base text-gray-600 hover:text-black transition-colors duration-300">
{{ t('contact.info.email') }}
</a>
</div>
@@ -198,6 +198,7 @@ import { useI18n } from 'vue-i18n'
import { useSeoMeta } from '#imports'
import gsap from 'gsap'
import { useAppStore } from '~/stores/app'
import { siteConfig } from '~/config/site'
const { t } = useI18n()
const appStore = useAppStore()
@@ -234,16 +235,8 @@ const handleSubmit = async () => {
statusMessage.value = ''
try {
// 模拟 API 调用 - 你需要替换为真实的邮件服务
// 可选方案:
// 1. 使用 Nuxt server API: await $fetch('/api/contact', { method: 'POST', body: form })
// 2. 使用 Formspree: await fetch('https://formspree.io/f/YOUR_ID', { ... })
// 3. 使用 EmailJS 等第三方服务
await new Promise(resolve => setTimeout(resolve, 1500)) // 模拟网络延迟
// 模拟成功
console.log('Form submitted:', form)
// 真实提交到后端(落库 + 尽力发送邮件)
await $fetch('/api/contact', { method: 'POST', body: { ...form } })
submitStatus.value = 'success'
statusMessage.value = t('contact.form.successMessage') || 'Message sent successfully! We will get back to you soon.'
@@ -253,16 +246,17 @@ const handleSubmit = async () => {
form[key as keyof typeof form] = ''
})
// 3秒后重置状态
// 4秒后重置状态
setTimeout(() => {
submitStatus.value = 'idle'
statusMessage.value = ''
}, 3000)
}, 4000)
} catch (error) {
console.error('Form submission error:', error)
submitStatus.value = 'error'
statusMessage.value = t('contact.form.errorMessage') || 'Failed to send message. Please try again or contact us directly.'
// 如实展示后端错误
statusMessage.value = (error as any)?.data?.message || t('contact.form.errorMessage') || 'Failed to send message. Please try again or contact us directly.'
} finally {
isSubmitting.value = false
}
@@ -362,28 +356,8 @@ interface SocialLink {
url: string
}
const socials: SocialLink[] = [
{
name: 'Twitter',
icon: 'ph:x-logo',
url: 'https://twitter.com'
},
{
name: 'Instagram',
icon: 'ph:instagram-logo',
url: 'https://instagram.com'
},
{
name: 'LinkedIn',
icon: 'ph:linkedin-logo',
url: 'https://linkedin.com'
},
{
name: 'GitHub',
icon: 'ph:github-logo',
url: 'https://github.com'
}
]
// 社交链接统一取自站点配置(单一事实源)
const socials: SocialLink[] = siteConfig.socials
</script>
<style scoped>
+72 -103
View File
@@ -15,7 +15,7 @@
<section class="relative h-[50vh] md:h-[60vh] overflow-hidden">
<img
:src="article.image"
:alt="article.title"
:alt="title"
class="w-full h-full object-cover"
/>
<div class="absolute inset-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent"></div>
@@ -25,19 +25,19 @@
class="inline-block px-3 py-1.5 text-xs md:text-sm font-semibold rounded-full mb-4"
:class="article.badge"
>
{{ article.category }}
{{ t(`news.categories.${article.category}`) }}
</span>
<h1 class="text-3xl md:text-5xl lg:text-6xl font-bold text-white mb-4 tracking-tight">
{{ article.title }}
{{ title }}
</h1>
<div class="flex items-center gap-4 text-white/80 text-sm md:text-base">
<span class="flex items-center gap-1.5">
<Icon name="ph:calendar-blank" class="w-4 h-4" />
{{ article.date }}
{{ formatNewsDate(article.date, locale) }}
</span>
<span class="flex items-center gap-1.5">
<Icon name="ph:clock" class="w-4 h-4" />
{{ article.readTime }}
{{ article.readTime }} {{ t('news.minutes') }}
</span>
<span class="flex items-center gap-1.5">
<Icon name="ph:user" class="w-4 h-4" />
@@ -62,7 +62,6 @@
{{ t(`news.detail.items.${slug}.section1Content`) }}
</p>
<!-- 引用 -->
<blockquote class="border-l-4 border-black pl-6 my-10 italic text-gray-600 text-lg">
"{{ t(`news.detail.items.${slug}.quote`) }}"
</blockquote>
@@ -74,9 +73,8 @@
{{ t(`news.detail.items.${slug}.section2Content`) }}
</p>
<!-- 文章内图片 -->
<div class="my-10 rounded-2xl overflow-hidden">
<img :src="article.image" :alt="article.title" class="w-full h-auto" />
<img :src="article.image" :alt="title" class="w-full h-auto" />
</div>
<h2 class="text-2xl md:text-3xl font-bold text-black mb-6 mt-12">
@@ -87,23 +85,42 @@
</p>
</article>
<!-- 分享按钮 -->
<!-- 分享按钮(真实动作) -->
<div class="mt-16 pt-8 border-t border-gray-200">
<div class="flex items-center justify-between">
<p class="text-sm text-gray-500">{{ t('news.detail.shareArticle') }}</p>
<div class="flex items-center justify-between flex-wrap gap-4">
<p class="text-sm text-gray-500">{{ t('share.article') }}</p>
<div class="flex gap-3">
<button class="w-10 h-10 rounded-full bg-gray-100 hover:bg-black hover:text-white flex items-center justify-center transition-all duration-300">
<button
@click="shareToX"
class="w-10 h-10 rounded-full bg-gray-100 hover:bg-black hover:text-white flex items-center justify-center transition-all duration-300"
:title="'X'"
aria-label="Share on X"
>
<Icon name="ph:x-logo" class="w-5 h-5" />
</button>
<button class="w-10 h-10 rounded-full bg-gray-100 hover:bg-black hover:text-white flex items-center justify-center transition-all duration-300">
<button
@click="shareToLinkedIn"
class="w-10 h-10 rounded-full bg-gray-100 hover:bg-black hover:text-white flex items-center justify-center transition-all duration-300"
:title="'LinkedIn'"
aria-label="Share on LinkedIn"
>
<Icon name="ph:linkedin-logo" class="w-5 h-5" />
</button>
<button class="w-10 h-10 rounded-full bg-gray-100 hover:bg-black hover:text-white flex items-center justify-center transition-all duration-300">
<button
@click="copyLink"
class="w-10 h-10 rounded-full bg-gray-100 hover:bg-black hover:text-white flex items-center justify-center transition-all duration-300"
:title="t('share.copy')"
aria-label="Copy link"
>
<Icon name="ph:link" class="w-5 h-5" />
</button>
</div>
</div>
<p v-if="copyFeedback" class="text-sm mt-3 text-green-600">{{ copyFeedback }}</p>
</div>
<!-- 评论区 -->
<CommentSection :news-slug="slug" />
</section>
<!-- 相关文章 -->
@@ -113,17 +130,17 @@
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
<NuxtLink
v-for="related in relatedArticles"
:key="related.id"
:to="`/news/${related.id}`"
:key="related.slug"
:to="`/news/${related.slug}`"
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-[16/10] overflow-hidden">
<img :src="related.image" :alt="related.title" class="w-full h-full object-cover transition-transform duration-500 group-hover:scale-105" />
<img :src="related.image" :alt="t(`news.items.${related.slug}.title`)" class="w-full h-full object-cover transition-transform duration-500 group-hover:scale-105" />
</div>
<div class="p-5">
<span class="text-xs text-gray-500">{{ related.date }}</span>
<span class="text-xs text-gray-500">{{ formatNewsDate(related.date, locale) }}</span>
<h3 class="text-lg font-bold text-black group-hover:text-gray-600 transition-colors mt-1 line-clamp-2">
{{ related.title }}
{{ t(`news.items.${related.slug}.title`) }}
</h3>
</div>
</NuxtLink>
@@ -134,103 +151,55 @@
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { computed, ref } from 'vue'
import { useRoute } from 'vue-router'
import { useI18n } from 'vue-i18n'
import { useSeoMeta, createError } from '#imports'
import { newsBySlug, newsItems, formatNewsDate } from '~/data/news'
const { t } = useI18n()
const { t, locale } = useI18n()
const route = useRoute()
const slug = route.params.slug as string
interface NewsItem {
id: string
title: string
image: string
category: string
badge: string
date: string
readTime: string
author: string
}
const newsData: Record<string, NewsItem> = {
'design-trends-2026': {
id: 'design-trends-2026',
title: 'Design Trends Shaping 2026',
image: 'https://picsum.photos/id/1/1200/800',
category: 'Insights',
badge: 'bg-purple-100 text-purple-700',
date: 'May 28, 2026',
readTime: '5 min',
author: 'ArcticNewOne Team'
},
'forma-digital-launch': {
id: 'forma-digital-launch',
title: 'Forma Digital Platform Launch',
image: 'https://picsum.photos/id/201/1200/800',
category: 'Projects',
badge: 'bg-blue-100 text-blue-700',
date: 'May 15, 2026',
readTime: '3 min',
author: 'ArcticNewOne Team'
},
'studio-expansion': {
id: 'studio-expansion',
title: 'Studio Expansion Announcement',
image: 'https://picsum.photos/id/164/1200/800',
category: 'Announcements',
badge: 'bg-green-100 text-green-700',
date: 'May 10, 2026',
readTime: '2 min',
author: 'ArcticNewOne Team'
},
'ux-research-methods': {
id: 'ux-research-methods',
title: 'Modern UX Research Methods',
image: 'https://picsum.photos/id/180/1200/800',
category: 'Insights',
badge: 'bg-purple-100 text-purple-700',
date: 'Apr 28, 2026',
readTime: '7 min',
author: 'ArcticNewOne Team'
},
'bold-moves-case-study': {
id: 'bold-moves-case-study',
title: 'Bold Moves: A Case Study',
image: 'https://picsum.photos/id/119/1200/800',
category: 'Projects',
badge: 'bg-blue-100 text-blue-700',
date: 'Apr 20, 2026',
readTime: '6 min',
author: 'ArcticNewOne Team'
},
'new-tools-integration': {
id: 'new-tools-integration',
title: 'New Tools Added to Our Platform',
image: 'https://picsum.photos/id/326/1200/800',
category: 'Announcements',
badge: 'bg-green-100 text-green-700',
date: 'Apr 12, 2026',
readTime: '4 min',
author: 'ArcticNewOne Team'
}
}
const article = newsData[slug]
const article = newsBySlug[slug]
if (!article) {
throw createError({ statusCode: 404, statusMessage: 'Article not found' })
}
const relatedArticles = computed(() => {
return Object.values(newsData)
.filter(a => a.id !== slug)
.slice(0, 3)
})
const title = computed(() => t(`news.items.${slug}.title`))
const relatedArticles = newsItems.filter((a) => a.slug !== slug).slice(0, 3)
useSeoMeta({
title: () => `${article.title} - ${t('news.title')}`,
description: () => article.title,
title: () => `${title.value} - ${t('news.title')}`,
description: () => t(`news.items.${slug}.excerpt`),
})
// ---- 分享(真实动作) ----
const copyFeedback = ref('')
const shareUrl = () => (typeof window !== 'undefined' ? window.location.href : '')
const shareText = () => title.value
const shareToX = () => {
const url = `https://twitter.com/intent/tweet?url=${encodeURIComponent(shareUrl())}&text=${encodeURIComponent(shareText())}`
window.open(url, '_blank', 'noopener,noreferrer,width=600,height=480')
}
const shareToLinkedIn = () => {
const url = `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(shareUrl())}`
window.open(url, '_blank', 'noopener,noreferrer,width=600,height=480')
}
const copyLink = async () => {
try {
await navigator.clipboard.writeText(shareUrl())
copyFeedback.value = t('share.copied')
} catch {
// 剪贴板不可用时回退到 prompt 复制
window.prompt(t('share.copyFailed'), shareUrl())
}
setTimeout(() => (copyFeedback.value = ''), 3000)
}
</script>
+80 -96
View File
@@ -8,6 +8,20 @@
<p ref="descRef" class="text-base md:text-lg text-gray-600 max-w-2xl">{{ t('news.description') }}</p>
</div>
<!-- 搜索框 -->
<div ref="searchWrapRef" class="flex justify-center mb-8">
<div class="relative w-full max-w-md">
<Icon name="ph:magnifying-glass" class="w-5 h-5 text-gray-400 absolute left-4 top-1/2 -translate-y-1/2" />
<input
v-model="keyword"
type="text"
:placeholder="t('search.placeholder')"
class="w-full pl-12 pr-4 py-3 rounded-full border border-gray-200 focus:border-black focus:ring-2 focus:ring-black/5 outline-none transition-all duration-300 text-sm md:text-base"
/>
</div>
</div>
<!-- 分类筛选 -->
<div
ref="filterWrapRef"
class="flex justify-center gap-3 md:gap-4 mb-10 md:mb-14 flex-wrap"
@@ -15,7 +29,7 @@
<button
v-for="category in categories"
:key="category"
@click="activeCategory = category"
@click="setCategory(category)"
class="px-5 md:px-6 py-2 md:py-2.5 rounded-full text-sm md:text-base font-semibold transition-all duration-300"
:class="activeCategory === category
? 'bg-black text-white shadow-lg'
@@ -25,20 +39,28 @@
</button>
</div>
<!-- 空结果 -->
<p v-if="!visibleNews.length" class="text-center text-gray-500 py-16">
{{ t('search.empty') }}
</p>
<!-- 文章列表 -->
<div
v-else
ref="articlesWrapRef"
class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 md:gap-8"
>
<NuxtLink
v-for="article in filteredNewsData"
:key="article.id"
:to="`/news/${article.id}`"
v-for="article in visibleNews"
:key="article.slug"
:to="`/news/${article.slug}`"
class="news-card group relative flex flex-col rounded-2xl md:rounded-3xl overflow-hidden bg-white border border-gray-100 hover:shadow-xl transition-all duration-500 cursor-pointer hover:-translate-y-2"
>
<div class="relative aspect-[16/10] overflow-hidden bg-gray-100">
<img
:src="article.image"
:alt="article.title"
:alt="t(`news.items.${article.slug}.title`)"
:loading="'lazy'"
class="w-full h-full object-cover transition-transform duration-700 group-hover:scale-110"
/>
<div class="absolute top-4 left-4">
@@ -46,7 +68,7 @@
class="px-3 py-1.5 text-xs md:text-sm font-semibold rounded-full shadow-sm"
:class="article.badge"
>
{{ article.category }}
{{ t(`news.categories.${article.category}`) }}
</span>
</div>
</div>
@@ -55,20 +77,20 @@
<div class="flex items-center gap-3 text-xs md:text-sm text-gray-500 mb-3">
<span class="flex items-center gap-1.5">
<Icon name="ph:calendar-blank" class="w-4 h-4" />
{{ article.date }}
{{ formatNewsDate(article.date, locale) }}
</span>
<span class="flex items-center gap-1.5">
<Icon name="ph:clock" class="w-4 h-4" />
{{ article.readTime }}
{{ article.readTime }} {{ t('news.minutes') }}
</span>
</div>
<h3 class="text-lg md:text-xl font-bold text-black mb-3 group-hover:text-gray-700 transition-colors duration-300 line-clamp-2">
{{ article.title }}
{{ t(`news.items.${article.slug}.title`) }}
</h3>
<p class="text-sm md:text-base text-gray-600 mb-4 flex-grow line-clamp-3">
{{ article.excerpt }}
{{ t(`news.items.${article.slug}.excerpt`) }}
</p>
<div class="flex items-center justify-between pt-3 border-t border-gray-100">
@@ -82,6 +104,20 @@
</div>
</NuxtLink>
</div>
<!-- 加载更多 -->
<div v-if="hasMore" class="flex justify-center mt-12">
<button
@click="loadMore"
class="px-8 py-3.5 rounded-full bg-black text-white font-semibold hover:bg-gray-800 transition-all duration-300 flex items-center gap-2"
>
<Icon name="ph:plus" class="w-5 h-5" />
{{ t('pagination.loadMore') }}
</button>
</div>
<p v-else-if="filteredNews.length > PAGE_SIZE" class="text-center text-gray-400 text-sm mt-8">
{{ t('pagination.noMore') }}
</p>
</main>
</template>
@@ -91,26 +127,49 @@ import { useI18n } from 'vue-i18n'
import { useSeoMeta } from '#imports'
import gsap from 'gsap'
import { useAppStore } from '~/stores/app'
import { newsItems, formatNewsDate, getNewsCategories } from '~/data/news'
const { t } = useI18n()
const { t, locale } = useI18n()
const appStore = useAppStore()
const headerWrapRef = ref<HTMLElement | null>(null)
const titleRef = ref<HTMLElement | null>(null)
const descRef = ref<HTMLElement | null>(null)
const searchWrapRef = ref<HTMLElement | null>(null)
const filterWrapRef = ref<HTMLElement | null>(null)
const articlesWrapRef = ref<HTMLElement | null>(null)
const activeCategory = ref('all')
const keyword = ref('')
const visibleCount = ref(0)
const categories = ['all', 'insights', 'projects', 'announcements']
const PAGE_SIZE = 6
const filteredNewsData = computed(() => {
if (activeCategory.value === 'all') {
return newsData
}
return newsData.filter(item => item.category.toLowerCase() === activeCategory.value.toLowerCase())
const categories = ['all', ...getNewsCategories()]
// 分类 + 搜索过滤(标题/摘要按当前语言文案匹配)
const filteredNews = computed(() => {
const kw = keyword.value.trim().toLowerCase()
return newsItems.filter((item) => {
if (activeCategory.value !== 'all' && item.category !== activeCategory.value) return false
if (!kw) return true
const title = t(`news.items.${item.slug}.title`).toLowerCase()
const excerpt = t(`news.items.${item.slug}.excerpt`).toLowerCase()
return title.includes(kw) || excerpt.includes(kw)
})
})
const visibleNews = computed(() => filteredNews.value.slice(0, visibleCount.value))
const hasMore = computed(() => visibleCount.value < filteredNews.value.length)
const setCategory = (category: string) => {
activeCategory.value = category
visibleCount.value = PAGE_SIZE
}
const loadMore = () => {
visibleCount.value = Math.min(visibleCount.value + PAGE_SIZE, filteredNews.value.length)
}
useSeoMeta({
title: () => t('news.title'),
description: () => t('news.description'),
@@ -123,101 +182,26 @@ const playPageIntro = async () => {
const filterButtons = gsap.utils.toArray<HTMLElement>('button', filterWrapRef.value!)
const newsCards = gsap.utils.toArray<HTMLElement>('.news-card', articlesWrapRef.value!)
// 先设置初始状态,防止闪现
gsap.set([titleRef.value, descRef.value, ...filterButtons, ...newsCards], {
autoAlpha: 0, y: 30
gsap.set([titleRef.value, descRef.value, searchWrapRef.value, ...filterButtons, ...newsCards], {
autoAlpha: 0, y: 30,
})
// 然后播放动画
const tl = gsap.timeline({ defaults: { ease: 'power2.out' } })
tl.to(titleRef.value, { autoAlpha: 1, y: 0, duration: 0.5 })
tl.to(descRef.value, { autoAlpha: 1, y: 0, duration: 0.4 }, '-=0.3')
tl.to(searchWrapRef.value, { autoAlpha: 1, y: 0, duration: 0.4 }, '-=0.2')
tl.to(filterButtons, { autoAlpha: 1, y: 0, duration: 0.4, stagger: 0.05 }, '-=0.2')
tl.to(newsCards, { autoAlpha: 1, y: 0, duration: 0.5, stagger: 0.08 }, '-=0.2')
}
onMounted(() => {
visibleCount.value = PAGE_SIZE
if (!appStore.isAppLoading) {
playPageIntro()
} else {
window.addEventListener('app-loading-done', playPageIntro, { once: true })
}
})
interface NewsItem {
id: string
title: string
excerpt: string
image: string
category: string
badge: string
date: string
readTime: string
}
const newsData: NewsItem[] = [
{
id: 'design-trends-2026',
title: 'Design Trends Shaping 2026',
excerpt: 'Explore the emerging design trends that are defining digital experiences this year, from minimalism to bold typography.',
image: 'https://picsum.photos/id/1/800/500',
category: 'Insights',
badge: 'bg-purple-100 text-purple-700',
date: 'May 28, 2026',
readTime: '5 min'
},
{
id: 'forma-digital-launch',
title: 'Forma Digital Platform Launch',
excerpt: 'We are excited to announce the successful launch of Forma Digital, a revolutionary e-commerce experience.',
image: 'https://picsum.photos/id/201/800/500',
category: 'Projects',
badge: 'bg-blue-100 text-blue-700',
date: 'May 15, 2026',
readTime: '3 min'
},
{
id: 'studio-expansion',
title: 'Studio Expansion Announcement',
excerpt: 'ArcticNewOne is growing! We are expanding our team and capabilities to serve you better.',
image: 'https://picsum.photos/id/164/800/500',
category: 'Announcements',
badge: 'bg-green-100 text-green-700',
date: 'May 10, 2026',
readTime: '2 min'
},
{
id: 'ux-research-methods',
title: 'Modern UX Research Methods',
excerpt: 'Dive into the latest user experience research methodologies that inform our design decisions.',
image: 'https://picsum.photos/id/180/800/500',
category: 'Insights',
badge: 'bg-purple-100 text-purple-700',
date: 'Apr 28, 2026',
readTime: '7 min'
},
{
id: 'bold-moves-case-study',
title: 'Bold Moves: A Case Study',
excerpt: 'Behind the scenes of our award-winning architectural visualization project featuring cutting-edge 3D technology.',
image: 'https://picsum.photos/id/119/800/500',
category: 'Projects',
badge: 'bg-blue-100 text-blue-700',
date: 'Apr 20, 2026',
readTime: '6 min'
},
{
id: 'new-tools-integration',
title: 'New Tools Added to Our Platform',
excerpt: 'Check out the latest additions to our toolbox, designed to streamline your workflow and boost productivity.',
image: 'https://picsum.photos/id/326/800/500',
category: 'Announcements',
badge: 'bg-green-100 text-green-700',
date: 'Apr 12, 2026',
readTime: '4 min'
}
]
</script>
<style scoped>
+31 -133
View File
@@ -15,7 +15,7 @@
<section class="relative h-[60vh] md:h-[70vh] overflow-hidden">
<img
:src="project.image"
:alt="project.title"
:alt="title"
class="w-full h-full object-cover"
/>
<div class="absolute inset-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent"></div>
@@ -31,10 +31,10 @@
</span>
</div>
<h1 class="text-4xl md:text-6xl lg:text-7xl font-bold text-white mb-4 tracking-tight">
{{ project.title }}
{{ title }}
</h1>
<p class="text-lg md:text-xl text-white/80 max-w-2xl">
{{ project.description }}
{{ t(`work.items.${slug}.description`) }}
</p>
</div>
</div>
@@ -75,7 +75,7 @@
:key="index"
class="rounded-2xl overflow-hidden shadow-lg hover:shadow-2xl transition-shadow duration-300"
>
<img :src="img" :alt="`${project.title} screenshot ${index + 1}`" class="w-full h-auto" />
<img :src="img" :alt="`${title} screenshot ${index + 1}`" class="w-full h-auto" />
</div>
</div>
</div>
@@ -113,17 +113,22 @@
</div>
</div>
<!-- 访问项目按钮 -->
<a
v-if="project.url"
:href="project.url"
target="_blank"
rel="noopener noreferrer"
class="mt-8 w-full inline-flex items-center justify-center gap-2 px-6 py-3.5 rounded-full bg-black text-white font-semibold hover:bg-gray-800 transition-colors duration-300"
>
{{ t('work.detail.visitProject') }}
<Icon name="ph:arrow-up-right" class="w-5 h-5" />
</a>
<div class="mt-8 space-y-3">
<!-- 访问项目(仅存在真实地址时渲染) -->
<a
v-if="project.url"
:href="project.url"
target="_blank"
rel="noopener noreferrer"
class="w-full inline-flex items-center justify-center gap-2 px-6 py-3.5 rounded-full bg-black text-white font-semibold hover:bg-gray-800 transition-colors duration-300"
>
{{ t('work.detail.visitProject') }}
<Icon name="ph:arrow-up-right" class="w-5 h-5" />
</a>
<!-- 收藏 -->
<FavoriteButton :work-slug="slug" />
</div>
</div>
</div>
</div>
@@ -136,15 +141,15 @@
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
<NuxtLink
v-for="related in relatedProjects"
:key="related.id"
:to="`/work/${related.id}`"
:key="related.slug"
:to="`/work/${related.slug}`"
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="related.title" class="w-full h-full object-cover transition-transform duration-500 group-hover:scale-105" />
<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" />
</div>
<div class="p-5">
<h3 class="text-lg font-bold text-black group-hover:text-gray-600 transition-colors">{{ related.title }}</h3>
<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>
</div>
</NuxtLink>
@@ -159,131 +164,24 @@ 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 route = useRoute()
const slug = route.params.slug as string
interface WorkItem {
id: string
title: string
description: string
image: string
tags: string[]
category: string
year: string
url?: string
gallery: string[]
}
const workData: Record<string, WorkItem> = {
'forma-digital': {
id: 'forma-digital',
title: 'Forma Digital',
description: 'A modern e-commerce platform with seamless user experience and dynamic product showcases.',
image: 'https://picsum.photos/id/201/1200/800',
tags: ['Web Design', 'E-commerce', 'React'],
category: 'webDesign',
year: '2026',
url: '#',
gallery: [
'https://picsum.photos/id/201/800/600',
'https://picsum.photos/id/202/800/600',
'https://picsum.photos/id/203/800/600',
'https://picsum.photos/id/204/800/600',
]
},
'one-step': {
id: 'one-step',
title: 'One Step',
description: 'Brand identity and marketing campaign for a fitness app focused on sustainable habits.',
image: 'https://picsum.photos/id/180/1200/800',
tags: ['Branding', 'Marketing', 'UI/UX'],
category: 'branding',
year: '2024',
gallery: [
'https://picsum.photos/id/180/800/600',
'https://picsum.photos/id/181/800/600',
'https://picsum.photos/id/182/800/600',
'https://picsum.photos/id/183/800/600',
]
},
'nero-vision': {
id: 'nero-vision',
title: 'Nero Vision',
description: 'Full-stack web application for creative professionals to manage their portfolios.',
image: 'https://picsum.photos/id/119/1200/800',
tags: ['Development', 'Vue.js', 'Node.js'],
category: 'development',
year: '2025',
gallery: [
'https://picsum.photos/id/119/800/600',
'https://picsum.photos/id/120/800/600',
'https://picsum.photos/id/121/800/600',
'https://picsum.photos/id/122/800/600',
]
},
'bold-moves': {
id: 'bold-moves',
title: 'Bold Moves',
description: 'Interactive website showcasing innovative architectural designs with 3D visualizations.',
image: 'https://picsum.photos/id/164/1200/800',
tags: ['Web Design', '3D', 'Three.js'],
category: 'webDesign',
year: '2024',
gallery: [
'https://picsum.photos/id/164/800/600',
'https://picsum.photos/id/165/800/600',
'https://picsum.photos/id/166/800/600',
'https://picsum.photos/id/167/800/600',
]
},
'echo-labs': {
id: 'echo-labs',
title: 'Echo Labs',
description: 'Corporate branding and visual identity for a tech startup in the AI space.',
image: 'https://picsum.photos/id/101/1200/800',
tags: ['Branding', 'Visual Identity', 'Corporate'],
category: 'branding',
year: '2025',
gallery: [
'https://picsum.photos/id/101/800/600',
'https://picsum.photos/id/102/800/600',
'https://picsum.photos/id/103/800/600',
'https://picsum.photos/id/104/800/600',
]
},
'flux-api': {
id: 'flux-api',
title: 'Flux API',
description: 'Scalable REST API with comprehensive documentation and developer tools.',
image: 'https://picsum.photos/id/326/1200/800',
tags: ['Development', 'API', 'Python'],
category: 'development',
year: '2025',
gallery: [
'https://picsum.photos/id/326/800/600',
'https://picsum.photos/id/327/800/600',
'https://picsum.photos/id/328/800/600',
'https://picsum.photos/id/329/800/600',
]
}
}
const project = workData[slug]
const project = workBySlug[slug]
if (!project) {
throw createError({ statusCode: 404, statusMessage: 'Project not found' })
}
const relatedProjects = computed(() => {
return Object.values(workData)
.filter(p => p.id !== slug)
.slice(0, 3)
})
const title = computed(() => t(`work.items.${slug}.title`))
const relatedProjects = workItems.filter((p) => p.slug !== slug).slice(0, 3)
useSeoMeta({
title: () => `${project.title} - ${t('work.title')}`,
description: () => project.description,
title: () => `${title.value} - ${t('work.title')}`,
description: () => t(`work.items.${slug}.description`),
})
</script>
+78 -78
View File
@@ -8,6 +8,20 @@
<p ref="descRef" class="text-base md:text-lg text-gray-600 max-w-2xl">{{ t('work.description') }}</p>
</div>
<!-- 搜索框 -->
<div ref="searchWrapRef" class="flex justify-center mb-8">
<div class="relative w-full max-w-md">
<Icon name="ph:magnifying-glass" class="w-5 h-5 text-gray-400 absolute left-4 top-1/2 -translate-y-1/2" />
<input
v-model="keyword"
type="text"
:placeholder="t('search.placeholder')"
class="w-full pl-12 pr-4 py-3 rounded-full border border-gray-200 focus:border-black focus:ring-2 focus:ring-black/5 outline-none transition-all duration-300 text-sm md:text-base"
/>
</div>
</div>
<!-- 分类筛选 -->
<div
ref="filterWrapRef"
class="flex justify-center gap-3 md:gap-4 mb-10 md:mb-14 flex-wrap"
@@ -15,7 +29,7 @@
<button
v-for="category in categories"
:key="category"
@click="activeCategory = category"
@click="setCategory(category)"
class="px-5 md:px-6 py-2 md:py-2.5 rounded-full text-sm md:text-base font-semibold transition-all duration-300"
:class="activeCategory === category
? 'bg-black text-white shadow-lg'
@@ -25,20 +39,28 @@
</button>
</div>
<!-- 空结果 -->
<p v-if="!visibleWork.length" class="text-center text-gray-500 py-16">
{{ t('search.empty') }}
</p>
<!-- 作品列表 -->
<div
v-else
ref="projectsWrapRef"
class="grid grid-cols-1 md:grid-cols-2 gap-6 md:gap-8"
>
<NuxtLink
v-for="project in filteredWorkData"
:key="project.id"
:to="`/work/${project.id}`"
v-for="project in visibleWork"
:key="project.slug"
:to="`/work/${project.slug}`"
class="work-card group relative block rounded-2xl md:rounded-3xl overflow-hidden cursor-pointer hover:shadow-2xl transition-all duration-500"
>
<div class="relative aspect-[4/3] overflow-hidden bg-gray-100">
<img
:src="project.image"
:alt="project.title"
:alt="t(`work.items.${project.slug}.title`)"
:loading="'lazy'"
class="w-full h-full object-cover transition-transform duration-700 group-hover:scale-110"
/>
<div class="absolute inset-0 bg-gradient-to-t from-black/60 via-black/20 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-500"></div>
@@ -46,12 +68,14 @@
<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">{{ project.title }}</h3>
<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`) }}
</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">{{ project.description }}</p>
<p class="text-sm md:text-base text-gray-600 mb-4">{{ t(`work.items.${project.slug}.description`) }}</p>
<div class="flex flex-wrap gap-2">
<span
v-for="tag in project.tags"
@@ -64,6 +88,20 @@
</div>
</NuxtLink>
</div>
<!-- 加载更多 -->
<div v-if="hasMore" class="flex justify-center mt-12">
<button
@click="loadMore"
class="px-8 py-3.5 rounded-full bg-black text-white font-semibold hover:bg-gray-800 transition-all duration-300 flex items-center gap-2"
>
<Icon name="ph:plus" class="w-5 h-5" />
{{ t('pagination.loadMore') }}
</button>
</div>
<p v-else-if="filteredWork.length > PAGE_SIZE" class="text-center text-gray-400 text-sm mt-8">
{{ t('pagination.noMore') }}
</p>
</main>
</template>
@@ -73,6 +111,7 @@ 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 appStore = useAppStore()
@@ -80,19 +119,41 @@ const appStore = useAppStore()
const headerWrapRef = ref<HTMLElement | null>(null)
const titleRef = ref<HTMLElement | null>(null)
const descRef = ref<HTMLElement | null>(null)
const searchWrapRef = ref<HTMLElement | null>(null)
const filterWrapRef = ref<HTMLElement | null>(null)
const projectsWrapRef = ref<HTMLElement | null>(null)
const activeCategory = ref('all')
const keyword = ref('')
const visibleCount = ref(0)
const categories = ['all', 'webDesign', 'branding', 'development']
const PAGE_SIZE = 4
const filteredWorkData = computed(() => {
if (activeCategory.value === 'all') {
return workData
}
return workData.filter(item => item.category === activeCategory.value)
const categories = ['all', ...getWorkCategories()]
// 分类 + 搜索过滤(标题/描述按当前语言文案匹配)
const filteredWork = computed(() => {
const kw = keyword.value.trim().toLowerCase()
return workItems.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()
return title.includes(kw) || desc.includes(kw)
})
})
const visibleWork = computed(() => filteredWork.value.slice(0, visibleCount.value))
const hasMore = computed(() => visibleCount.value < filteredWork.value.length)
const setCategory = (category: string) => {
activeCategory.value = category
visibleCount.value = PAGE_SIZE
}
const loadMore = () => {
visibleCount.value = Math.min(visibleCount.value + PAGE_SIZE, filteredWork.value.length)
}
useSeoMeta({
title: () => t('work.title'),
description: () => t('work.description'),
@@ -105,87 +166,26 @@ const playPageIntro = async () => {
const filterButtons = gsap.utils.toArray<HTMLElement>('button', filterWrapRef.value!)
const projectCards = gsap.utils.toArray<HTMLElement>('.work-card', projectsWrapRef.value!)
// 先设置初始状态,防止闪现
gsap.set([titleRef.value, descRef.value, ...filterButtons, ...projectCards], {
autoAlpha: 0, y: 30
gsap.set([titleRef.value, descRef.value, searchWrapRef.value, ...filterButtons, ...projectCards], {
autoAlpha: 0, y: 30,
})
// 然后播放动画
const tl = gsap.timeline({ defaults: { ease: 'power2.out' } })
tl.to(titleRef.value, { autoAlpha: 1, y: 0, duration: 0.5 })
tl.to(descRef.value, { autoAlpha: 1, y: 0, duration: 0.4 }, '-=0.3')
tl.to(searchWrapRef.value, { autoAlpha: 1, y: 0, duration: 0.4 }, '-=0.2')
tl.to(filterButtons, { autoAlpha: 1, y: 0, duration: 0.4, stagger: 0.05 }, '-=0.2')
tl.to(projectCards, { autoAlpha: 1, y: 0, duration: 0.5, stagger: 0.08 }, '-=0.2')
}
onMounted(() => {
visibleCount.value = PAGE_SIZE
if (!appStore.isAppLoading) {
playPageIntro()
} else {
window.addEventListener('app-loading-done', playPageIntro, { once: true })
}
})
interface WorkItem {
id: string
title: string
description: string
image: string
tags: string[]
category: string
}
const workData: WorkItem[] = [
{
id: 'forma-digital',
title: 'Forma Digital',
description: 'A modern e-commerce platform with seamless user experience and dynamic product showcases.',
image: 'https://picsum.photos/id/201/800/600',
tags: ['Web Design', 'E-commerce', 'React'],
category: 'webDesign'
},
{
id: 'one-step',
title: 'One Step',
description: 'Brand identity and marketing campaign for a fitness app focused on sustainable habits.',
image: 'https://picsum.photos/id/180/800/600',
tags: ['Branding', 'Marketing', 'UI/UX'],
category: 'branding'
},
{
id: 'nero-vision',
title: 'Nero Vision',
description: 'Full-stack web application for creative professionals to manage their portfolios.',
image: 'https://picsum.photos/id/119/800/600',
tags: ['Development', 'Vue.js', 'Node.js'],
category: 'development'
},
{
id: 'bold-moves',
title: 'Bold Moves',
description: 'Interactive website showcasing innovative architectural designs with 3D visualizations.',
image: 'https://picsum.photos/id/164/800/600',
tags: ['Web Design', '3D', 'Three.js'],
category: 'webDesign'
},
{
id: 'echo-labs',
title: 'Echo Labs',
description: 'Corporate branding and visual identity for a tech startup in the AI space.',
image: 'https://picsum.photos/id/101/800/600',
tags: ['Branding', 'Visual Identity', 'Corporate'],
category: 'branding'
},
{
id: 'flux-api',
title: 'Flux API',
description: 'Scalable REST API with comprehensive documentation and developer tools.',
image: 'https://picsum.photos/id/326/800/600',
tags: ['Development', 'API', 'Python'],
category: 'development'
}
]
</script>
<style scoped>