feat: 收官补齐全部未实现功能

- 账号体系:修改密码(/account + PATCH /api/auth/password)、自助删除账号
  (DELETE /api/auth/me)、订阅退订(token + /unsubscribe 页)
- 前台/SEO:RSS 订阅 /feed.xml、作品详情分享、canonical URL、
  文章 Article JSON-LD、品牌化错误页(i18n)
- 后台增强:图片管理 /admin/uploads、操作审计日志 /admin/audit(含清空)、
  联系消息已读标记、评论列表分页
- 工程:vitest 测试(密码哈希/内容校验器/种子完整性,12 例)+ pnpm test
- DB 迁移:contacts.read、subscribers.token、audit_logs(老库 ALTER 兼容)
- 密码逻辑抽为 server/utils/password.ts 供测试
This commit is contained in:
2026-08-06 17:26:26 +08:00
parent d67849a311
commit 685c7b51d1
47 changed files with 1600 additions and 72 deletions
+60 -1
View File
@@ -129,6 +129,38 @@
<!-- 收藏 -->
<FavoriteButton :work-slug="slug" />
</div>
<!-- 分享 -->
<div class="mt-8 pt-6 border-t border-gray-200">
<p class="text-sm text-gray-500 mb-3">{{ t('share.article') }}</p>
<div class="flex gap-3">
<button
@click="shareToX"
class="w-10 h-10 rounded-full bg-white border border-gray-200 hover:bg-black hover:text-white hover:border-black 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
@click="shareToLinkedIn"
class="w-10 h-10 rounded-full bg-white border border-gray-200 hover:bg-black hover:text-white hover:border-black 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
@click="copyLink"
class="w-10 h-10 rounded-full bg-white border border-gray-200 hover:bg-black hover:text-white hover:border-black 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>
<p v-if="copyFeedback" class="text-sm mt-3 text-green-600">{{ copyFeedback }}</p>
</div>
</div>
</div>
</div>
@@ -160,7 +192,7 @@
</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'
@@ -218,4 +250,31 @@ useSeoMeta({
title: () => `${title.value} - ${t('work.title')}`,
description: () => description.value,
})
// ---- 分享(真实动作) ----
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>