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
+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>