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