chore: sync local latest state and repository cleanup

This commit is contained in:
Your Name
2026-03-23 13:02:36 +08:00
parent f1ff3d629f
commit 2ef0f17961
493 changed files with 46912 additions and 7977 deletions

View File

@@ -34,10 +34,10 @@
<div class="flex flex-wrap items-center gap-3">
<template v-if="hasAuth">
<MosquitoShareButton :activity-id="activityId" :user-id="userId" />
<button class="mos-btn mos-btn-accent !py-2 !px-4">
<MosquitoShareButton :activity-id="activityId" :user-id="userId" @copied="handleCopied" @error="handleCopyError" />
<button class="mos-btn mos-btn-accent !py-2 !px-4" @click="handleCopyLink">
<Icons name="copy" class="w-4 h-4" />
复制链接
{{ copyButtonText }}
</button>
</template>
<template v-else>
@@ -125,7 +125,7 @@ type ActivitySummary = {
}
const route = useRoute()
const { getActivities } = useMosquito()
const { getActivities, getShareUrl } = useMosquito()
const apiKey = import.meta.env.VITE_MOSQUITO_API_KEY
const userToken = import.meta.env.VITE_MOSQUITO_USER_TOKEN
const routeUserId = computed(() => parseUserId(route.query.userId ?? route.params.userId))
@@ -134,6 +134,8 @@ const activityId = ref(1)
const activityLabel = computed(() => `活动 #${activityId.value}`)
const loadError = ref('')
const hasAuth = computed(() => Boolean(apiKey && userToken && userId.value))
const copyButtonText = ref('复制链接')
const copyFeedback = ref<'success' | 'error' | null>(null)
const guideSteps = [
'点击"分享给好友"生成专属链接',
@@ -141,6 +143,65 @@ const guideSteps = [
'回到首页查看最新排行和奖励进度'
]
// 复制链接处理
const handleCopyLink = async () => {
try {
const shareResponse = await getShareUrl(activityId.value, userId.value, 'default')
let urlToCopy: string
if (shareResponse && typeof shareResponse === 'object') {
if (shareResponse.originalUrl) {
urlToCopy = shareResponse.originalUrl
} else if (shareResponse.path) {
urlToCopy = shareResponse.path.startsWith('http')
? shareResponse.path
: `${window.location.origin}${shareResponse.path}`
} else {
throw new Error('分享链接响应格式异常')
}
} else {
throw new Error('分享链接响应格式异常')
}
// 复制到剪贴板
try {
await navigator.clipboard.writeText(urlToCopy)
showCopyFeedback('success')
} catch {
// 回退到传统方法
const textArea = document.createElement('textarea')
textArea.value = urlToCopy
document.body.appendChild(textArea)
textArea.select()
document.execCommand('copy')
document.body.removeChild(textArea)
showCopyFeedback('success')
}
} catch (error) {
console.error('复制链接失败:', error)
showCopyFeedback('error')
}
}
// 显示复制反馈
const showCopyFeedback = (type: 'success' | 'error') => {
copyFeedback.value = type
copyButtonText.value = type === 'success' ? '已复制!' : '复制失败'
setTimeout(() => {
copyButtonText.value = '复制链接'
copyFeedback.value = null
}, 2000)
}
// MosquitoShareButton 回调处理
const handleCopied = () => {
showCopyFeedback('success')
}
const handleCopyError = () => {
showCopyFeedback('error')
}
const loadActivity = async () => {
if (!hasAuth.value) {
return