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
+154
View File
@@ -0,0 +1,154 @@
<template>
<section class="mt-16">
<h2 class="text-2xl md:text-3xl font-bold text-black mb-8">{{ t('comments.title') }}</h2>
<!-- 登录提示 -->
<div
v-if="!userStore.isAuthenticated"
class="p-6 rounded-2xl bg-gray-50 border border-gray-200 text-center"
>
<p class="text-gray-600 mb-4">{{ t('comments.loginToComment') }}</p>
<button
@click="authModal.openLogin()"
class="px-6 py-2.5 rounded-full bg-black text-white text-sm font-semibold hover:bg-gray-800 transition-colors"
>
{{ t('auth.login') }}
</button>
</div>
<!-- 评论表单(已登录) -->
<form v-else @submit.prevent="handleSubmit" class="mb-10">
<div class="flex items-start gap-4">
<img
:src="userStore.avatar"
:alt="userStore.user?.username"
class="w-10 h-10 rounded-full object-cover flex-shrink-0"
/>
<div class="flex-1">
<textarea
v-model="content"
rows="3"
maxlength="2000"
:placeholder="t('comments.placeholder')"
:disabled="isSubmitting"
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 duration-300 resize-none disabled:opacity-50"
></textarea>
<div class="flex items-center justify-between mt-3">
<span v-if="errorMessage" class="text-sm text-red-600">{{ errorMessage }}</span>
<button
type="submit"
:disabled="isSubmitting || !content.trim()"
class="ml-auto px-6 py-2.5 rounded-full bg-black text-white text-sm font-semibold flex items-center gap-2 transition-all"
:class="isSubmitting || !content.trim() ? 'opacity-50 cursor-not-allowed' : 'hover:bg-gray-800'"
>
<Icon v-if="isSubmitting" name="ph:circle-notch" class="w-4 h-4 animate-spin" />
{{ isSubmitting ? t('comments.submitting') : t('comments.submit') }}
</button>
</div>
</div>
</div>
</form>
<!-- 评论列表 -->
<div v-if="comments.length" class="space-y-6">
<div
v-for="comment in comments"
:key="comment.id"
class="flex items-start gap-4 p-5 rounded-2xl bg-gray-50 border border-gray-100"
>
<img
:src="avatarUrl(comment.author.username)"
:alt="comment.author.username"
class="w-10 h-10 rounded-full object-cover flex-shrink-0"
/>
<div class="flex-1 min-w-0">
<div class="flex items-center justify-between gap-3 mb-1">
<p class="text-sm font-semibold text-black">{{ comment.author.username }}</p>
<p class="text-xs text-gray-400 shrink-0">{{ formatDate(comment.createdAt) }}</p>
</div>
<p class="text-gray-700 text-sm md:text-base leading-relaxed break-words">{{ comment.content }}</p>
</div>
</div>
</div>
<div v-else-if="!loading && userStore.isAuthenticated" class="text-center text-gray-500 py-8">
{{ t('comments.empty') }}
</div>
</section>
</template>
<script setup lang="ts">
import { ref, watch, onMounted } from 'vue'
import { useI18n } from 'vue-i18n'
import { useUserStore } from '~/stores/user'
import { useAuthModalStore } from '~/stores/authModal'
const props = defineProps<{ newsSlug: string }>()
const { t, locale } = useI18n()
const userStore = useUserStore()
const authModal = useAuthModalStore()
interface CommentItem {
id: number
content: string
createdAt: string
author: { username: string }
}
const comments = ref<CommentItem[]>([])
const content = ref('')
const isSubmitting = ref(false)
const isLoading = ref(true)
const errorMessage = ref('')
const avatarUrl = (name: string) =>
`https://ui-avatars.com/api/?name=${encodeURIComponent(name)}&background=000&color=fff&size=128`
const formatDate = (raw: string) => {
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',
hour: '2-digit',
minute: '2-digit',
}).format(d)
}
const fetchComments = async () => {
isLoading.value = true
try {
const data = await $fetch<{ comments: CommentItem[] }>('/api/comments', {
query: { newsSlug: props.newsSlug },
})
comments.value = data.comments
} catch (err) {
console.error('fetch comments error:', err)
} finally {
isLoading.value = false
}
}
const handleSubmit = async () => {
if (isSubmitting.value || !content.value.trim()) return
isSubmitting.value = true
errorMessage.value = ''
try {
await $fetch('/api/comments', {
method: 'POST',
body: { newsSlug: props.newsSlug, content: content.value.trim() },
})
content.value = ''
await fetchComments()
} catch (err) {
console.error('post comment error:', err)
errorMessage.value = t('comments.commentError')
} finally {
isSubmitting.value = false
}
}
onMounted(fetchComments)
watch(() => props.newsSlug, fetchComments)
</script>
+71
View File
@@ -0,0 +1,71 @@
<template>
<button
type="button"
:disabled="isLoading"
@click="toggle"
class="inline-flex w-full items-center justify-center gap-2 px-6 py-3.5 rounded-full font-semibold transition-all duration-300"
:class="isFavorite
? 'bg-gray-100 text-black hover:bg-gray-200'
: 'bg-black text-white hover:bg-gray-800'"
>
<Icon v-if="isLoading" name="ph:circle-notch" class="w-5 h-5 animate-spin" />
<Icon v-else :name="isFavorite ? 'ph:bookmark-simple-fill' : 'ph:bookmark-simple'" class="w-5 h-5" />
<span>{{ isFavorite ? t('favorites.remove') : t('favorites.add') }}</span>
</button>
</template>
<script setup lang="ts">
import { ref, watch, onMounted } from 'vue'
import { useI18n } from 'vue-i18n'
import { useUserStore } from '~/stores/user'
import { useAuthModalStore } from '~/stores/authModal'
const props = defineProps<{ workSlug: string }>()
const { t } = useI18n()
const userStore = useUserStore()
const authModal = useAuthModalStore()
const isFavorite = ref(false)
const isLoading = ref(false)
// 已登录时同步收藏状态
const refresh = async () => {
if (!userStore.isAuthenticated) {
isFavorite.value = false
return
}
try {
const data = await $fetch<{ slugs: string[] }>('/api/favorites')
isFavorite.value = data.slugs.includes(props.workSlug)
} catch {
// 忽略,保持现状
}
}
const toggle = async () => {
if (!userStore.isAuthenticated) {
authModal.openLogin()
return
}
if (isLoading.value) return
isLoading.value = true
try {
if (isFavorite.value) {
await $fetch('/api/favorites', { method: 'DELETE', body: { workSlug: props.workSlug } })
isFavorite.value = false
} else {
await $fetch('/api/favorites', { method: 'POST', body: { workSlug: props.workSlug } })
isFavorite.value = true
}
} catch (err) {
console.error('favorite toggle error:', err)
} finally {
isLoading.value = false
}
}
onMounted(refresh)
watch(() => userStore.isAuthenticated, refresh)
watch(() => props.workSlug, refresh)
</script>
+40 -69
View File
@@ -2,7 +2,7 @@
<Teleport to="body">
<Transition name="modal">
<div
v-if="isOpen"
v-if="authModal.isLoginOpen"
class="fixed inset-0 z-[100] flex items-center justify-center bg-black/50 backdrop-blur-sm px-4"
@click.self="closeModal"
>
@@ -35,7 +35,8 @@
v-model="account"
type="text"
required
:disabled="isLoggingIn"
autocomplete="username"
:disabled="isSubmitting"
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 duration-300 disabled:opacity-50 disabled:cursor-not-allowed"
:placeholder="t('auth.accountPlaceholder')"
/>
@@ -50,7 +51,8 @@
v-model="password"
type="password"
required
:disabled="isLoggingIn"
autocomplete="current-password"
:disabled="isSubmitting"
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 duration-300 disabled:opacity-50 disabled:cursor-not-allowed"
:placeholder="t('auth.passwordPlaceholder')"
/>
@@ -64,26 +66,21 @@
<!-- 登录按钮 -->
<button
type="submit"
:disabled="isLoggingIn || !account || !password"
:disabled="isSubmitting || !account || !password"
class="w-full py-3 rounded-xl font-semibold text-white transition-all duration-300 flex items-center justify-center gap-2"
:class="isLoggingIn || !account || !password
:class="isSubmitting || !account || !password
? 'bg-gray-400 cursor-not-allowed'
: 'bg-black hover:bg-gray-800 shadow-lg hover:shadow-xl'"
>
<Icon v-if="isLoggingIn" name="ph:circle-notch" class="w-5 h-5 animate-spin" />
<span>{{ isLoggingIn ? t('auth.loggingIn') : t('auth.loginButton') }}</span>
<Icon v-if="isSubmitting" name="ph:circle-notch" class="w-5 h-5 animate-spin" />
<span>{{ isSubmitting ? t('auth.loggingIn') : t('auth.loginButton') }}</span>
</button>
</form>
<!-- 提示信息 -->
<p class="mt-6 text-center text-sm text-gray-500">
{{ t('auth.demoHint') }}
</p>
<!-- 注册账号链接 -->
<p class="mt-4 text-center text-sm text-gray-600">
<p class="mt-6 text-center text-sm text-gray-600">
{{ t('auth.noAccount') }}
<button @click="switchToRegister" class="text-black font-semibold hover:underline">
<button @click="authModal.switchToRegister()" class="text-black font-semibold hover:underline">
{{ t('auth.createAccount') }}
</button>
</p>
@@ -98,86 +95,60 @@
import { ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { useUserStore } from '~/stores/user'
import { useAuthModalStore } from '~/stores/authModal'
import { useApiError } from '~/composables/useApiError'
const { t } = useI18n()
const userStore = useUserStore()
const authModal = useAuthModalStore()
const apiError = useApiError()
interface Props {
isOpen: boolean
}
const props = defineProps<Props>()
const emit = defineEmits<{
close: []
switchToRegister: []
}>()
const modalRef = ref<HTMLElement | null>(null)
const account = ref('')
const password = ref('')
const isLoggingIn = ref(false)
const isSubmitting = ref(false)
const errorMessage = ref('')
// 关闭模态框
const closeModal = () => {
if (!isLoggingIn.value) {
emit('close')
if (!isSubmitting.value) {
authModal.closeAll()
}
}
// 切换到注册
const switchToRegister = () => {
emit('switchToRegister')
}
// 处理登录
const handleLogin = async () => {
if (isLoggingIn.value) return
isLoggingIn.value = true
errorMessage.value = ''
try {
const result = await userStore.login(account.value, password.value)
if (result.success) {
// 登录成功,关闭模态框
// 打开时重置表单
watch(
() => authModal.isLoginOpen,
(open) => {
if (open) {
account.value = ''
password.value = ''
closeModal()
} else {
errorMessage.value = t('auth.loginError')
errorMessage.value = ''
}
} catch (error) {
console.error('Login error:', error)
errorMessage.value = t('auth.loginError')
} finally {
isLoggingIn.value = false
}
}
},
)
// 监听打开状态,重置表单
watch(() => props.isOpen, (isOpen) => {
if (isOpen) {
const handleLogin = async () => {
if (isSubmitting.value) return
isSubmitting.value = true
errorMessage.value = ''
const result = await userStore.login(account.value, password.value)
if (result.success) {
account.value = ''
password.value = ''
errorMessage.value = ''
// 禁止背景滚动
document.body.style.overflow = 'hidden'
authModal.closeAll()
} else {
// 恢复滚动
document.body.style.overflow = ''
errorMessage.value = apiError({ data: { code: result.code } })
}
})
isSubmitting.value = false
}
// ESC 键关闭
// ESC 关闭
const handleKeydown = (e: KeyboardEvent) => {
if (e.key === 'Escape' && props.isOpen) {
if (e.key === 'Escape' && authModal.isLoginOpen) {
closeModal()
}
}
// 添加键盘事件监听
if (typeof window !== 'undefined') {
window.addEventListener('keydown', handleKeydown)
}
+64 -92
View File
@@ -2,7 +2,7 @@
<Teleport to="body">
<Transition name="modal">
<div
v-if="isOpen"
v-if="authModal.isRegisterOpen"
class="fixed inset-0 z-[100] flex items-center justify-center bg-black/50 backdrop-blur-sm px-4"
@click.self="closeModal"
>
@@ -35,7 +35,8 @@
v-model="username"
type="text"
required
:disabled="isRegistering"
autocomplete="username"
:disabled="isSubmitting"
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 duration-300 disabled:opacity-50 disabled:cursor-not-allowed"
:placeholder="t('auth.usernamePlaceholder')"
/>
@@ -50,7 +51,8 @@
v-model="email"
type="email"
required
:disabled="isRegistering"
autocomplete="email"
:disabled="isSubmitting"
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 duration-300 disabled:opacity-50 disabled:cursor-not-allowed"
:placeholder="t('auth.emailPlaceholder')"
/>
@@ -64,7 +66,8 @@
id="reg-phone"
v-model="phone"
type="tel"
:disabled="isRegistering"
autocomplete="tel"
:disabled="isSubmitting"
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 duration-300 disabled:opacity-50 disabled:cursor-not-allowed"
:placeholder="t('auth.phonePlaceholder')"
/>
@@ -79,7 +82,8 @@
v-model="password"
type="password"
required
:disabled="isRegistering"
autocomplete="new-password"
:disabled="isSubmitting"
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 duration-300 disabled:opacity-50 disabled:cursor-not-allowed"
:placeholder="t('auth.passwordPlaceholder')"
/>
@@ -94,7 +98,8 @@
v-model="confirmPassword"
type="password"
required
:disabled="isRegistering"
autocomplete="new-password"
:disabled="isSubmitting"
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 duration-300 disabled:opacity-50 disabled:cursor-not-allowed"
:placeholder="t('auth.confirmPasswordPlaceholder')"
/>
@@ -113,21 +118,21 @@
<!-- 注册按钮 -->
<button
type="submit"
:disabled="isRegistering || !username || !email || !password || !confirmPassword"
:disabled="isSubmitting || !username || !email || !password || !confirmPassword"
class="w-full py-3 rounded-xl font-semibold text-white transition-all duration-300 flex items-center justify-center gap-2"
:class="isRegistering || !username || !email || !password || !confirmPassword
:class="isSubmitting || !username || !email || !password || !confirmPassword
? 'bg-gray-400 cursor-not-allowed'
: 'bg-black hover:bg-gray-800 shadow-lg hover:shadow-xl'"
>
<Icon v-if="isRegistering" name="ph:circle-notch" class="w-5 h-5 animate-spin" />
<span>{{ isRegistering ? t('auth.registering') : t('auth.registerButton') }}</span>
<Icon v-if="isSubmitting" name="ph:circle-notch" class="w-5 h-5 animate-spin" />
<span>{{ isSubmitting ? t('auth.registering') : t('auth.registerButton') }}</span>
</button>
</form>
<!-- 返回登录链接 -->
<p class="mt-6 text-center text-sm text-gray-600">
{{ t('auth.alreadyHaveAccount') }}
<button @click="switchToLogin" class="text-black font-semibold hover:underline">
<button @click="authModal.switchToLogin()" class="text-black font-semibold hover:underline">
{{ t('auth.backToLogin') }}
</button>
</p>
@@ -142,122 +147,89 @@
import { ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { useUserStore } from '~/stores/user'
import { useAuthModalStore } from '~/stores/authModal'
import { useApiError } from '~/composables/useApiError'
const { t } = useI18n()
const userStore = useUserStore()
const authModal = useAuthModalStore()
const apiError = useApiError()
interface Props {
isOpen: boolean
}
const props = defineProps<Props>()
const emit = defineEmits<{
close: []
switchToLogin: []
}>()
const modalRef = ref<HTMLElement | null>(null)
const username = ref('')
const email = ref('')
const phone = ref('')
const password = ref('')
const confirmPassword = ref('')
const isRegistering = ref(false)
const isSubmitting = ref(false)
const errorMessage = ref('')
const successMessage = ref('')
// 关闭模态框
const closeModal = () => {
if (!isRegistering.value) {
emit('close')
if (!isSubmitting.value) {
authModal.closeAll()
}
}
// 切换到登录
const switchToLogin = () => {
emit('switchToLogin')
}
// 处理注册
const handleRegister = async () => {
if (isRegistering.value) return
// 验证密码匹配
if (password.value !== confirmPassword.value) {
errorMessage.value = t('auth.passwordMismatch')
return
}
// 验证手机号格式(如果填写了)
if (phone.value && !/^1[3-9]\d{9}$/.test(phone.value)) {
errorMessage.value = t('auth.invalidPhone')
return
}
isRegistering.value = true
errorMessage.value = ''
successMessage.value = ''
try {
const result = await userStore.register({
username: username.value,
email: email.value,
phone: phone.value,
password: password.value
})
if (result.success) {
// 注册成功
successMessage.value = t('auth.registerSuccess')
// 清空表单
// 打开时重置表单
watch(
() => authModal.isRegisterOpen,
(open) => {
if (open) {
username.value = ''
email.value = ''
phone.value = ''
password.value = ''
confirmPassword.value = ''
// 2秒后关闭并自动登录
setTimeout(() => {
closeModal()
}, 2000)
} else {
errorMessage.value = result.error || t('auth.registerError')
errorMessage.value = ''
successMessage.value = ''
}
} catch (error) {
console.error('Register error:', error)
errorMessage.value = t('auth.registerError')
} finally {
isRegistering.value = false
}
}
},
)
// 监听打开状态,重置表单
watch(() => props.isOpen, (isOpen) => {
if (isOpen) {
const handleRegister = async () => {
if (isSubmitting.value) return
errorMessage.value = ''
successMessage.value = ''
if (password.value !== confirmPassword.value) {
errorMessage.value = t('auth.passwordMismatch')
return
}
if (phone.value && !/^1[3-9]\d{9}$/.test(phone.value)) {
errorMessage.value = t('auth.invalidPhone')
return
}
isSubmitting.value = true
const result = await userStore.register({
username: username.value,
email: email.value,
phone: phone.value,
password: password.value,
})
if (result.success) {
successMessage.value = t('auth.registerSuccess')
username.value = ''
email.value = ''
phone.value = ''
password.value = ''
confirmPassword.value = ''
errorMessage.value = ''
successMessage.value = ''
// 禁止背景滚动
document.body.style.overflow = 'hidden'
setTimeout(() => {
authModal.closeAll()
}, 1500)
} else {
// 恢复滚动
document.body.style.overflow = ''
errorMessage.value = apiError({ data: { code: result.code } })
}
})
isSubmitting.value = false
}
// ESC 键关闭
// ESC 关闭
const handleKeydown = (e: KeyboardEvent) => {
if (e.key === 'Escape' && props.isOpen) {
if (e.key === 'Escape' && authModal.isRegisterOpen) {
closeModal()
}
}
// 添加键盘事件监听
if (typeof window !== 'undefined') {
window.addEventListener('keydown', handleKeydown)
}
+27 -65
View File
@@ -3,6 +3,7 @@ import { onMounted, onUnmounted, ref, nextTick } from 'vue'
import { useI18n } from 'vue-i18n'
import gsap from 'gsap'
import { ScrollTrigger } from 'gsap/ScrollTrigger'
import { workItems } from '~/data/work'
gsap.registerPlugin(ScrollTrigger)
@@ -49,46 +50,6 @@ const partners = [
},
]
const toImageUrl = (prompt: string, imageSize: string) => {
const encoded = encodeURIComponent(prompt)
return `https://coresg-normal.trae.ai/api/ide/v1/text_to_image?prompt=${encoded}&image_size=${imageSize}`
}
const workItems = [
{
titleKey: 'home.work.items.forma',
year: '26',
image: toImageUrl(
'high-end editorial product still life, minimal composition, matte ceramics and brushed aluminum on soft neutral background, studio lighting, shallow depth of field, premium, clean, realistic, 35mm photo',
'landscape_16_9'
),
},
{
titleKey: 'home.work.items.oneStep',
year: '24',
image: toImageUrl(
'architectural close-up, modern brutalist concrete facade with sharp shadows, minimal, cinematic lighting, high contrast, ultra realistic, 35mm photography, no people',
'landscape_16_9'
),
},
{
titleKey: 'home.work.items.neroVision',
year: '25',
image: toImageUrl(
'minimal graphic poster photographed in studio, black ink typography on off-white textured paper, premium editorial style, soft shadow, ultra realistic, no people',
'landscape_16_9'
),
},
{
titleKey: 'home.work.items.boldMoves',
year: '24',
image: toImageUrl(
'moody nighttime city street still life, neon reflection on wet asphalt, abstract bokeh, premium cinematic photography, no people, high detail',
'landscape_16_9'
),
},
] as const
let ctx: gsap.Context | null = null
const refresh = () => {
@@ -140,12 +101,12 @@ onMounted(async () => {
tl.to(
next,
{ y: 0, duration: 1, ease: 'power2.out' },
start
start,
)
tl.to(
prev,
{ scale: scaleTo, y: depthOffsetY, duration: 0.6, ease: 'power2.out' },
start + 0.35
start + 0.35,
)
tl.set(prev, { scale: scaleTo, y: depthOffsetY }, start + 1)
}
@@ -235,29 +196,30 @@ onUnmounted(() => {
<div class="relative flex-1 h-full flex items-center">
<div class="relative w-full h-[78svh] md:h-[82svh] lg:h-[88svh] p-[clamp(14px,2.4vw,28px)]">
<div class="relative h-full w-full">
<article
v-for="(item, idx) in workItems"
:key="`${item.titleKey}-${idx}`"
ref="cardRefs"
class="will-change-transform relative"
>
<img
class="h-full w-full object-cover"
:src="item.image"
:alt="t(item.titleKey)"
loading="lazy"
decoding="async"
@load="refresh"
/>
<div class="absolute left-6 top-6 flex items-baseline gap-3">
<p class="text-white text-sm md:text-base font-semibold tracking-tight drop-shadow-[0_10px_18px_rgba(0,0,0,0.4)]">
{{ t(item.titleKey) }}
</p>
<p class="text-white/80 text-xs md:text-sm font-semibold tracking-tight drop-shadow-[0_10px_18px_rgba(0,0,0,0.4)]">
{{ item.year }} ©
</p>
</div>
</article>
<NuxtLink
v-for="(item, idx) in workItems"
:key="item.slug"
:to="`/work/${item.slug}`"
ref="cardRefs"
class="will-change-transform relative block"
>
<img
class="h-full w-full object-cover"
:src="item.image"
:alt="t(`work.items.${item.slug}.title`)"
loading="lazy"
decoding="async"
@load="refresh"
/>
<div class="absolute left-6 top-6 flex items-baseline gap-3">
<p class="text-white text-sm md:text-base font-semibold tracking-tight drop-shadow-[0_10px_18px_rgba(0,0,0,0.4)]">
{{ t(`work.items.${item.slug}.title`) }}
</p>
<p class="text-white/80 text-xs md:text-sm font-semibold tracking-tight drop-shadow-[0_10px_18px_rgba(0,0,0,0.4)]">
{{ item.year }} ©
</p>
</div>
</NuxtLink>
</div>
</div>
</div>
+1 -1
View File
@@ -15,7 +15,7 @@
v-for="(tech, index) in technologies"
:key="tech.id"
:ref="el => setTechRef(el, index)"
class="tech-tag absolute flex items-center gap-3 px-5 py-3 bg-white rounded-full shadow-lg border-2 cursor-pointer hover:scale-110 transition-transform duration-300"
class="tech-tag absolute flex items-center gap-3 px-5 py-3 bg-white rounded-full shadow-lg border-2 hover:scale-110 transition-transform duration-300"
:class="tech.borderColor"
:style="getTechStyle(index)"
>
+28 -67
View File
@@ -13,11 +13,12 @@
<!-- Bento 网格 -->
<div class="grid grid-cols-12 gap-4 md:gap-6 auto-rows-[200px]">
<div
<NuxtLink
v-for="(item, index) in updates"
:key="item.id"
:key="item.slug"
:to="`/news/${item.slug}`"
:ref="el => setCardRef(el, index)"
class="update-card group relative overflow-hidden rounded-3xl cursor-pointer"
class="update-card group relative overflow-hidden rounded-3xl cursor-pointer block"
:class="item.gridClass"
:style="{ opacity: 0 }"
@mouseenter="() => handleCardHover(index, true)"
@@ -31,27 +32,27 @@
<div>
<div class="inline-flex items-center gap-2 px-3 py-1.5 rounded-full bg-white/20 backdrop-blur-sm text-xs md:text-sm font-semibold mb-4">
<Icon :name="item.categoryIcon" class="w-4 h-4" />
{{ t(`home.updates.categories.${item.category}`) }}
{{ t(`news.categories.${item.category}`) }}
</div>
<h3 class="text-xl md:text-3xl font-bold mb-3 line-clamp-2">
{{ t(`home.updates.items.${item.id}.title`) }}
{{ t(`news.items.${item.slug}.title`) }}
</h3>
<p v-if="item.showDescription" class="text-white/90 text-sm md:text-base line-clamp-3">
{{ t(`home.updates.items.${item.id}.description`) }}
{{ t(`news.items.${item.slug}.excerpt`) }}
</p>
</div>
<div class="flex items-center justify-between">
<span class="text-xs md:text-sm text-white/80">{{ item.date }}</span>
<span class="text-xs md:text-sm text-white/80">{{ formatNewsDate(item.date, locale) }}</span>
<Icon name="ph:arrow-up-right" class="w-5 h-5 md:w-6 md:h-6 transition-transform duration-300 group-hover:translate-x-1 group-hover:-translate-y-1" />
</div>
</div>
<!-- 悬浮效果 -->
<div class="absolute inset-0 bg-black/0 group-hover:bg-black/10 transition-colors duration-300"></div>
</div>
</NuxtLink>
</div>
<!-- 查看更多 -->
@@ -73,10 +74,11 @@ import { ref, onMounted, onUnmounted, nextTick } from 'vue'
import { useI18n } from 'vue-i18n'
import gsap from 'gsap'
import { ScrollTrigger } from 'gsap/ScrollTrigger'
import { newsItems, formatNewsDate } from '~/data/news'
gsap.registerPlugin(ScrollTrigger)
const { t } = useI18n()
const { t, locale } = useI18n()
const rootRef = ref<HTMLElement | null>(null)
const headerRef = ref<HTMLElement | null>(null)
@@ -87,62 +89,21 @@ const setCardRef = (el: any, index: number) => {
if (el) cardElements.value[index] = el
}
const updates = [
{
id: 'project1',
category: 'project',
categoryIcon: 'ph:briefcase',
gradient: 'bg-gradient-to-br from-blue-500 via-purple-500 to-pink-500',
gridClass: 'col-span-12 md:col-span-6 md:row-span-2',
showDescription: true,
date: '2026-06-01'
},
{
id: 'blog1',
category: 'blog',
categoryIcon: 'ph:article',
gradient: 'bg-gradient-to-br from-orange-500 to-red-500',
gridClass: 'col-span-12 md:col-span-3 md:row-span-1',
showDescription: false,
date: '2026-05-28'
},
{
id: 'news1',
category: 'news',
categoryIcon: 'ph:newspaper',
gradient: 'bg-gradient-to-br from-green-500 to-emerald-500',
gridClass: 'col-span-12 md:col-span-3 md:row-span-1',
showDescription: false,
date: '2026-05-25'
},
{
id: 'project2',
category: 'project',
categoryIcon: 'ph:briefcase',
gradient: 'bg-gradient-to-br from-indigo-500 to-blue-500',
gridClass: 'col-span-12 md:col-span-3 md:row-span-2',
showDescription: true,
date: '2026-05-20'
},
{
id: 'blog2',
category: 'blog',
categoryIcon: 'ph:article',
gradient: 'bg-gradient-to-br from-pink-500 to-rose-500',
gridClass: 'col-span-12 md:col-span-6 md:row-span-1',
showDescription: false,
date: '2026-05-15'
},
{
id: 'news2',
category: 'news',
categoryIcon: 'ph:newspaper',
gradient: 'bg-gradient-to-br from-amber-500 to-orange-500',
gridClass: 'col-span-12 md:col-span-3 md:row-span-1',
showDescription: false,
date: '2026-05-10'
}
]
// Bento 布局(与动态数据一一对应;分类图标/渐变/跨度)
const layout = [
{ categoryIcon: 'ph:article', gradient: 'bg-gradient-to-br from-blue-500 via-purple-500 to-pink-500', gridClass: 'col-span-12 md:col-span-6 md:row-span-2', showDescription: true },
{ categoryIcon: 'ph:briefcase', gradient: 'bg-gradient-to-br from-orange-500 to-red-500', gridClass: 'col-span-12 md:col-span-3 md:row-span-1', showDescription: false },
{ categoryIcon: 'ph:newspaper', gradient: 'bg-gradient-to-br from-green-500 to-emerald-500', gridClass: 'col-span-12 md:col-span-3 md:row-span-1', showDescription: false },
{ categoryIcon: 'ph:article', gradient: 'bg-gradient-to-br from-indigo-500 to-blue-500', gridClass: 'col-span-12 md:col-span-3 md:row-span-2', showDescription: true },
{ categoryIcon: 'ph:briefcase', gradient: 'bg-gradient-to-br from-pink-500 to-rose-500', gridClass: 'col-span-12 md:col-span-6 md:row-span-1', showDescription: false },
{ categoryIcon: 'ph:newspaper', gradient: 'bg-gradient-to-br from-amber-500 to-orange-500', gridClass: 'col-span-12 md:col-span-3 md:row-span-1', showDescription: false },
] as const
// 取前 6 条动态,绑定布局
const updates = newsItems.slice(0, 6).map((item, i) => ({
...item,
...layout[i],
}))
// 卡片悬浮效果
const handleCardHover = (index: number, isHover: boolean) => {
@@ -155,7 +116,7 @@ const handleCardHover = (index: number, isHover: boolean) => {
? '0 25px 50px -12px rgba(0, 0, 0, 0.25)'
: '0 10px 15px -3px rgba(0, 0, 0, 0.1)',
duration: 0.3,
ease: 'power2.out'
ease: 'power2.out',
})
}
@@ -171,7 +132,7 @@ onMounted(async () => {
gsap.set(card, { autoAlpha: 0, y: 60, scale: 0.9 })
})
// 入场动画(无 pin):标题 + 卡片错开出现
// 入场动画:标题 + 卡片错开出现
const tl = gsap.timeline()
tl.to(headerRef.value, { autoAlpha: 1, y: 0, duration: 0.8, ease: 'power3.out' }, 0)
+24 -23
View File
@@ -5,6 +5,7 @@ import { gsap } from 'gsap'
import { ScrollTrigger } from 'gsap/ScrollTrigger'
import FooterLogo from '~/components/common/FooterLogo.vue'
import AnimatedButton from '~/components/common/AnimatedButton.vue'
import { siteConfig } from '~/config/site'
gsap.registerPlugin(ScrollTrigger)
@@ -43,14 +44,8 @@ const handleNewsletterSubmit = async () => {
subscribeStatus.value = 'idle'
try {
// 模拟 API 调用 - 你需要替换为真实的 Newsletter 服务
// 可选方案:
// 1. Mailchimp: await $fetch('/api/newsletter/subscribe', { method: 'POST', body: { email: newsletterEmail.value } })
// 2. ConvertKit, SendGrid, 或其他邮件服务
await new Promise(resolve => setTimeout(resolve, 1000)) // 模拟网络延迟
console.log('Newsletter subscription:', newsletterEmail.value)
// 真实订阅:落库 + 尽力发送欢迎邮件
await $fetch('/api/newsletter', { method: 'POST', body: { email: newsletterEmail.value } })
subscribeStatus.value = 'success'
newsletterEmail.value = ''
@@ -61,8 +56,12 @@ const handleNewsletterSubmit = async () => {
}, 3000)
} catch (error) {
console.error('Newsletter subscription error:', error)
subscribeStatus.value = 'error'
// 已在订阅列表视为成功(用户确实已订阅)
if ((error as any)?.data?.code === 'ALREADY_SUBSCRIBED') {
subscribeStatus.value = 'success'
} else {
subscribeStatus.value = 'error'
}
setTimeout(() => {
subscribeStatus.value = 'idle'
@@ -227,10 +226,10 @@ onUnmounted(() => {
<div class="grid grid-cols-1 sm:grid-cols-2 gap-8">
<ul class="space-y-3">
<li class="animated-item">
<a href="mailto:chenchun@virtheart.com" class="group flex items-center overflow-hidden text-[16px] font-bold text-white/80 hover:text-white transition-colors" style="justify-content: flex-start;">
<a :href="`mailto:${siteConfig.email}`" class="group flex items-center overflow-hidden text-[16px] font-bold text-white/80 hover:text-white transition-colors" style="justify-content: flex-start;">
<div class="flex items-center transition-transform duration-300 group-hover:translate-x-0 -translate-x-[21px] pr-[21px]">
<span class="mr-[10px] h-[11px] w-[11px] rounded-full bg-white shrink-0"></span>
<span>chenchun@virtheart.com</span>
<span>{{ siteConfig.email }}</span>
</div>
</a>
</li>
@@ -238,7 +237,7 @@ onUnmounted(() => {
<span class="group flex items-center overflow-hidden text-[16px] font-bold text-white/80 transition-colors cursor-default" style="justify-content: flex-start;">
<div class="flex items-center transition-transform duration-300 group-hover:translate-x-0 -translate-x-[21px] pr-[21px]">
<span class="mr-[10px] h-[11px] w-[11px] rounded-full bg-white shrink-0"></span>
<span>{{ t('footer.wechat') }}: LucskyNew</span>
<span>{{ t('footer.wechat') }}: {{ siteConfig.wechat }}</span>
</div>
</span>
</li>
@@ -246,10 +245,10 @@ onUnmounted(() => {
<ul class="space-y-3">
<li class="animated-item">
<a href="mailto:info@virtheart.com" class="group flex items-center overflow-hidden text-[16px] font-bold text-white/80 hover:text-white transition-colors" style="justify-content: flex-start;">
<a :href="`mailto:${siteConfig.infoEmail}`" class="group flex items-center overflow-hidden text-[16px] font-bold text-white/80 hover:text-white transition-colors" style="justify-content: flex-start;">
<div class="flex items-center transition-transform duration-300 group-hover:translate-x-0 -translate-x-[21px] pr-[21px]">
<span class="mr-[10px] h-[11px] w-[11px] rounded-full bg-white shrink-0"></span>
<span>info@virtheart.com</span>
<span>{{ siteConfig.infoEmail }}</span>
</div>
</a>
</li>
@@ -266,14 +265,16 @@ onUnmounted(() => {
</div>
<div class="flex gap-3 animated-item">
<a href="#" class="w-10 h-10 rounded-full bg-[#1f1f1f] hover:bg-[#2f2f2f] flex items-center justify-center transition-colors text-white">
<Icon name="ph:instagram-logo" class="w-4 h-4" />
</a>
<a href="#" class="w-10 h-10 rounded-full bg-[#1f1f1f] hover:bg-[#2f2f2f] flex items-center justify-center transition-colors text-white">
<Icon name="ph:x-logo" class="w-4 h-4" />
</a>
<a href="#" class="w-10 h-10 rounded-full bg-[#1f1f1f] hover:bg-[#2f2f2f] flex items-center justify-center transition-colors text-white">
<Icon name="ph:diamond-fill" class="w-4 h-4" />
<a
v-for="social in siteConfig.socials"
:key="social.name"
:href="social.url"
target="_blank"
rel="noopener noreferrer"
class="w-10 h-10 rounded-full bg-[#1f1f1f] hover:bg-[#2f2f2f] flex items-center justify-center transition-colors text-white"
:aria-label="social.name"
>
<Icon :name="social.icon" class="w-4 h-4" />
</a>
</div>
</div>
+43 -55
View File
@@ -6,16 +6,18 @@ import gsap from 'gsap'
import { ScrollTrigger } from 'gsap/ScrollTrigger'
import { useAppStore } from '~/stores/app'
import { useUserStore } from '~/stores/user'
import { useAuthModalStore } from '~/stores/authModal'
import AppLogo from '~/components/common/AppLogo.vue'
import LoginModal from '~/components/common/LoginModal.vue'
import RegisterModal from '~/components/common/RegisterModal.vue'
gsap.registerPlugin(ScrollTrigger)
const { t } = useI18n()
const { t, locale, setLocale } = useI18n()
const route = useRoute()
const appStore = useAppStore()
const userStore = useUserStore()
const authModal = useAuthModalStore()
// 恢复用户状态
onMounted(() => {
@@ -36,46 +38,15 @@ const topHeaderRef = ref<HTMLElement | null>(null)
const bottomHeaderRef = ref<HTMLElement | null>(null)
const mobileMenuRef = ref<HTMLElement | null>(null)
const isMobileMenuOpen = ref(false)
const isLoginModalOpen = ref(false)
const isRegisterModalOpen = ref(false)
const isUserMenuOpen = ref(false)
let topHeaderTween: gsap.core.Tween | null = null
let bottomHeaderScrollTrigger: ReturnType<typeof ScrollTrigger.create> | null = null
let isBottomHeaderVisible = false
let fallbackTimer: ReturnType<typeof setTimeout> | null = null
// 打开登录弹窗
const openLoginModal = () => {
isLoginModalOpen.value = true
isRegisterModalOpen.value = false
}
// 关闭登录弹窗
const closeLoginModal = () => {
isLoginModalOpen.value = false
}
// 打开注册弹窗
const openRegisterModal = () => {
isRegisterModalOpen.value = true
isLoginModalOpen.value = false
}
// 关闭注册弹窗
const closeRegisterModal = () => {
isRegisterModalOpen.value = false
}
// 从登录切换到注册
const switchToRegister = () => {
isLoginModalOpen.value = false
isRegisterModalOpen.value = true
}
// 从注册切换到登录
const switchToLogin = () => {
isRegisterModalOpen.value = false
isLoginModalOpen.value = true
// 语言切换
const switchLocale = () => {
setLocale(locale.value === 'zh' ? 'en' : 'zh')
}
// 切换用户菜单
@@ -368,12 +339,21 @@ if (typeof window !== 'undefined') {
</NuxtLink>
</nav>
<!-- 右侧:登录按钮 / 用户信息(桌面端) -->
<!-- 右侧:登录按钮 / 用户信息 / 语言切换(桌面端) -->
<div class="hidden md:flex items-center gap-4">
<!-- 语言切换 -->
<button
@click="switchLocale"
class="px-3 py-2 rounded-full border border-gray-200 text-sm font-semibold text-black hover:bg-gray-100 transition-all duration-300"
:aria-label="locale === 'zh' ? t('lang.toEnglish') : t('lang.toChinese')"
>
{{ locale === 'zh' ? t('lang.toEnglish') : t('lang.toChinese') }}
</button>
<!-- 未登录:显示登录按钮 -->
<button
v-if="!userStore.isAuthenticated"
@click="openLoginModal"
@click="authModal.openLogin()"
class="px-5 py-2.5 rounded-full bg-black text-white text-sm font-semibold hover:bg-gray-800 transition-all duration-300 shadow-md hover:shadow-lg"
>
{{ t('auth.login') }}
@@ -387,10 +367,10 @@ if (typeof window !== 'undefined') {
>
<img
:src="userStore.user?.avatar"
:alt="userStore.user?.name"
:alt="userStore.user?.username"
class="w-9 h-9 rounded-full object-cover border-2 border-gray-200"
/>
<span class="text-sm font-semibold text-black">{{ userStore.user?.name }}</span>
<span class="text-sm font-semibold text-black">{{ userStore.user?.username }}</span>
<Icon
name="ph:caret-down"
class="w-4 h-4 text-gray-600 transition-transform duration-300"
@@ -406,9 +386,17 @@ if (typeof window !== 'undefined') {
@click="closeUserMenu"
>
<div class="px-4 py-3 border-b border-gray-100">
<p class="text-sm font-semibold text-black">{{ userStore.user?.name }}</p>
<p class="text-sm font-semibold text-black">{{ userStore.user?.username }}</p>
<p class="text-xs text-gray-500 truncate">{{ userStore.user?.email }}</p>
</div>
<NuxtLink
to="/account"
@click="closeUserMenu"
class="w-full px-4 py-2.5 text-left text-sm font-medium text-gray-700 hover:bg-gray-100 transition-colors duration-200 flex items-center gap-2"
>
<Icon name="ph:user-circle" class="w-4 h-4" />
{{ t('account.title') }}
</NuxtLink>
<button
@click="handleLogout"
class="w-full px-4 py-2.5 text-left text-sm font-medium text-red-600 hover:bg-red-50 transition-colors duration-200 flex items-center gap-2"
@@ -458,10 +446,18 @@ if (typeof window !== 'undefined') {
<!-- 移动端登录/用户信息 -->
<div class="mobile-menu-item mt-8 pt-8 border-t border-gray-200 w-full flex flex-col items-center gap-4">
<!-- 语言切换 -->
<button
@click="switchLocale"
class="px-8 py-3 rounded-full border-2 border-black text-black text-base font-semibold hover:bg-gray-100 transition-all duration-300"
>
{{ locale === 'zh' ? t('lang.toEnglish') : t('lang.toChinese') }}
</button>
<!-- 未登录 -->
<button
v-if="!userStore.isAuthenticated"
@click="openLoginModal"
@click="authModal.openLogin()"
class="px-8 py-3 rounded-full bg-black text-white text-base font-semibold hover:bg-gray-800 transition-all duration-300"
>
{{ t('auth.login') }}
@@ -472,11 +468,11 @@ if (typeof window !== 'undefined') {
<div class="flex items-center gap-3">
<img
:src="userStore.user?.avatar"
:alt="userStore.user?.name"
:alt="userStore.user?.username"
class="w-12 h-12 rounded-full object-cover border-2 border-gray-200"
/>
<div class="text-left">
<p class="text-lg font-bold text-black">{{ userStore.user?.name }}</p>
<p class="text-lg font-bold text-black">{{ userStore.user?.username }}</p>
<p class="text-sm text-gray-500">{{ userStore.user?.email }}</p>
</div>
</div>
@@ -492,19 +488,11 @@ if (typeof window !== 'undefined') {
</nav>
</div>
<!-- 登录弹窗 -->
<LoginModal
:is-open="isLoginModalOpen"
@close="closeLoginModal"
@switch-to-register="switchToRegister"
/>
<!-- 登录弹窗(由 authModal store 控制开关) -->
<LoginModal />
<!-- 注册弹窗 -->
<RegisterModal
:is-open="isRegisterModalOpen"
@close="closeRegisterModal"
@switch-to-login="switchToLogin"
/>
<!-- 注册弹窗(由 authModal store 控制开关) -->
<RegisterModal />
<header ref="bottomHeaderRef" class="site-header-bottom z-50 bg-white/80 backdrop-blur-md">
<!-- 左侧菜单 (前两个菜单项) -->