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:
@@ -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>
|
||||
|
||||
@@ -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">
|
||||
<!-- 左侧菜单 (前两个菜单项) -->
|
||||
|
||||
Reference in New Issue
Block a user