update
This commit is contained in:
@@ -25,13 +25,17 @@
|
||||
|
||||
<div v-if="adStats && ads.length">
|
||||
<template v-for="ad in ads" :key="ad.link">
|
||||
<NuxtLink
|
||||
:to="ad.link"
|
||||
:external="isExternal(ad.link)"
|
||||
:target="isExternal(ad.link) ? '_blank' : null"
|
||||
<a
|
||||
v-if="isExternal(ad.link)"
|
||||
:href="ad.link"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
class="text-text-muted text-sm m-0"
|
||||
v-html="buildAdHtml(ad)">
|
||||
class="text-text-muted text-sm m-0">
|
||||
<span v-html="ad.body"></span>
|
||||
</a>
|
||||
|
||||
<NuxtLink v-else :to="ad.link" class="text-text-muted text-sm m-0">
|
||||
<span v-html="ad.body"></span>
|
||||
</NuxtLink>
|
||||
</template>
|
||||
</div>
|
||||
@@ -71,7 +75,7 @@
|
||||
</p>
|
||||
|
||||
<!-- eslint-disable-next-line vue/no-v-html -->
|
||||
<div v-if="contact?.customHtml" v-html="contact.customHtml" />
|
||||
<div v-if="contact?.customHtml" v-html="contact.customHtml"></div>
|
||||
</footer>
|
||||
</template>
|
||||
|
||||
@@ -165,13 +169,6 @@ const fetchStats = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const buildAdHtml = (ad) => {
|
||||
if (!ad || !ad.text) return "";
|
||||
const imgHtml = ad.img ? `<img src="${ad.img}" alt="" class="h-7 w-auto" loading="lazy" />` : "";
|
||||
const content = ad.text.replace(/\{\{img\}\}/g, imgHtml);
|
||||
return `<span class="inline-flex items-center gap-1">${content}</span>`;
|
||||
};
|
||||
|
||||
const isExternal = (url) => {
|
||||
return typeof url === "string" && /^https?:\/\//.test(url);
|
||||
};
|
||||
|
||||
@@ -97,9 +97,8 @@ const siteConfig: SiteConfig = {
|
||||
enable: true,
|
||||
ads: [
|
||||
{
|
||||
text: "本网站由{{img}}提供云存储服务",
|
||||
body: '<p><span class="inline-flex items-center gap-2">本网站由 <img src="/ads/upyun.png" class="h-7 w-auto" alt="Upyun" /> 提供云存储服务</span></p>',
|
||||
link: "https://www.upyun.com/?utm_source=lianmeng&utm_medium=referral",
|
||||
img: "/ads/upyun.png",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -80,7 +80,7 @@ export interface UmamiConfig {
|
||||
|
||||
export interface AdConfig {
|
||||
enable?: boolean;
|
||||
ads?: [{ text?: string; link?: string; img?: string }];
|
||||
ads?: [{ body?: string; link?: string }];
|
||||
}
|
||||
|
||||
export interface SiteConfig {
|
||||
|
||||
Reference in New Issue
Block a user