feat: 赞助页面支持 ?ratio=N 隐藏参数,金额倍数显示
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+16
-1
@@ -5,6 +5,21 @@ useSeoMeta({
|
||||
title: `赞助 - ${siteConfig.siteName}`,
|
||||
description: '感谢您的支持,您的赞助将帮助我持续创作优质内容',
|
||||
})
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
const ratio = computed(() => {
|
||||
const v = Number(route.query.ratio)
|
||||
return Number.isFinite(v) && v > 0 ? v : 0
|
||||
})
|
||||
|
||||
function formatAmount(amount: string): string {
|
||||
if (!ratio.value) return amount
|
||||
const match = amount.match(/^([\d.]+)(.*)$/)
|
||||
if (!match) return amount
|
||||
const num = (parseFloat(match[1]) * ratio.value).toFixed(2)
|
||||
return num + match[2]
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -59,7 +74,7 @@ useSeoMeta({
|
||||
<div class="flex-1 min-w-0">
|
||||
<div class="font-semibold">{{ sponsor.name }}</div>
|
||||
<div class="text-sm text-muted-foreground">{{ sponsor.date }}</div>
|
||||
<div v-if="sponsor.amount" class="text-sm font-medium text-primary mt-1">{{ sponsor.amount }}</div>
|
||||
<div v-if="sponsor.amount" class="text-sm font-medium text-primary mt-1">{{ formatAmount(sponsor.amount) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user