服务端websiteConfigDTO增加favicon、网页标题、公安部备案编号三个字段,博客前端支持动态获取这三个字段

master
wanghao 3 years ago
parent 79b7478b44
commit 20287c5080

@ -68,4 +68,16 @@ public class WebsiteConfigDTO {
private String alipayQRCode;
private String favicon;
/**
*
*/
private String websiteTitle;
/**
*
*/
private String gonganBeianNumber;
}

@ -99,6 +99,7 @@ export default defineComponent({
appStore.categoryCount = data.data.categoryCount
appStore.tagCount = data.data.tagCount
appStore.websiteConfig = data.data.websiteConfigDTO
initFavicon(data.data.websiteConfigDTO.favicon)
})
}
const copyEventHandler = (event: any) => {
@ -130,8 +131,30 @@ export default defineComponent({
}, 10)
}
}
const initFavicon = (faviconUrl: string) => {
if (!faviconUrl) {
return
}
// head
var head = document.getElementsByTagName('head')[0];
// favicon
var favicon = document.querySelector("link[rel*='icon']") || document.createElement('link');
// Cast favicon to HTMLLinkElement
var faviconLink = favicon as HTMLLinkElement;
faviconLink.type = 'image/x-icon';
faviconLink.rel = 'shortcut icon';
// favicon
faviconLink.href = faviconUrl;
// head favicon favicon head
if (!document.querySelector("link[rel*='icon']")) {
head.appendChild(faviconLink);
}
}
return {
title: metaStore.title,
title: computed(() => appStore.websiteConfig.websiteTitle) || metaStore.title,
theme: computed(() => appStore.themeConfig.theme),
headerImage: computed(() => {
return {

@ -6,11 +6,17 @@
<div
class="flex flex-col lg:flex-row gap-6 lg:gap-12 row-span-1 lg:col-span-5 text-center lg:text-left mx-auto">
<ul class="flex flex-col gap-2 mx-auto">
<li>
<li class="flex flex-row mx-auto">
Copyright © 2022 - {{ currentYear }}
<b class="font-extrabold">{{ websiteConfig.author }}</b>
<b class="font-extrabold">&nbsp;{{ websiteConfig.author }}</b>
</li>
<li v-if="websiteConfig.beian_number != ''" class="flex flex-row mx-auto">
<li v-if="websiteConfig.gonganBeianNumber != '' && websiteConfig.gonganBeianNumber != undefined" class="flex flex-row mx-auto">
<a href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=11011402013558" target="_blank">
<img src="https://oss.supermouse.cn/aurora/config/gongan-beian-icon.png" style="float:left;"/> &nbsp;
<b class="font-extrabold border-b-2 border-ob hover:text-ob"> {{ websiteConfig.gonganBeianNumber }} </b>
</a>
</li>
<li v-if="websiteConfig.beianNumber != '' && websiteConfig.beianNumber != undefined" class="flex flex-row mx-auto">
<a href="https://beian.miit.gov.cn/" target="_blank">
<b class="font-extrabold border-b-2 border-ob hover:text-ob"> {{ websiteConfig.beianNumber }} </b>
</a>

Loading…
Cancel
Save