Files
BYW-VoiceHub/app/components/SiteFooter.vue
T

202 lines
4.4 KiB
Vue

<template>
<div class="site-footer">
<div class="footer-info">
<span v-if="icpNumber" class="footer-item">
<a
:href="`https://beian.miit.gov.cn/`"
class="icp-link"
rel="noopener noreferrer"
target="_blank"
>
{{ icpNumber }}
</a>
</span>
<span v-if="gonganNumber" class="footer-item">
<img
v-if="showBeianIcon"
src="/images/beian.png"
alt="备案图标"
class="beian-icon"
>
<a
:href="gonganLink || 'https://beian.mps.gov.cn/'"
class="icp-link"
rel="noopener noreferrer"
target="_blank"
>
{{ gonganNumber }}
</a>
</span>
<span v-if="siteTitle" class="footer-item">© {{ currentYear }} {{ siteTitle }}</span>
<span v-else class="footer-item">© {{ currentYear }} {{ copyrightOwner }}</span>
<span class="footer-item">{{ common?.workerIn || 'Worker in' }} {{ responseTime }}ms</span>
<span class="footer-item">
<a class="voicehub-link" :href="repoUrl" rel="noopener noreferrer" target="_blank">
{{ systemName }} v{{ systemVersion }}
</a>
</span>
<span v-if="isNetlify" class="footer-item">
<a
href="https://www.netlify.com"
target="_blank"
rel="noopener noreferrer"
class="netlify-badge"
>
<img
src="https://www.netlify.com/img/global/badges/netlify-color-accent.svg"
alt="Deploys by Netlify"
>
</a>
</span>
</div>
</div>
</template>
<script setup>
import { ref, onMounted, computed } from 'vue'
import { getCopyrightOwner, getSystemName, getRepoUrl } from '@/utils/core/security'
import { useLocale } from '~/utils/locale'
import packageJson from '~~/package.json'
// 使用 useSiteConfig composable 获取配置
const { siteTitle, icp: icpNumber, gonganNumber, showBeianIcon } = useSiteConfig()
const config = useRuntimeConfig()
const { common } = useLocale()
// 自动生成公安联网备案链接
const gonganLink = computed(() => {
if (!gonganNumber.value) return '#'
// 提取数字部分
const codeMatch = gonganNumber.value.match(/\d+/)
const code = codeMatch ? codeMatch[0] : ''
if (!code) return '#'
return `https://beian.mps.gov.cn/#/query/webSearch?code=${code}`
})
const isNetlify = config.public.isNetlify
const copyrightOwner = getCopyrightOwner()
const systemName = getSystemName()
const repoUrl = getRepoUrl()
const systemVersion = packageJson.version
const currentYear = getSyncedDate().getFullYear()
const responseTime = ref(0)
onMounted(() => {
if (typeof window !== 'undefined' && window.performance) {
// 使用 requestAnimationFrame 确保在渲染后计算
requestAnimationFrame(() => {
const loadTime = Math.round(window.performance.now())
responseTime.value = loadTime
})
}
})
</script>
<style scoped>
.site-footer {
text-align: center;
padding: 20px 0;
margin-top: 30px;
border-top: 1px solid var(--border-tertiary);
width: 100%;
}
.footer-info {
display: flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
gap: 0;
}
.footer-item {
color: var(--text-tertiary);
font-size: 12px;
white-space: nowrap;
}
.footer-item:not(:last-child)::after {
content: ' | ';
margin: 0 10px;
color: var(--text-quaternary);
}
.footer-item a {
color: inherit;
text-decoration: none;
transition: color 0.2s ease;
}
.footer-item a:hover {
color: var(--text-secondary);
}
.icp-link,
.voicehub-link {
color: inherit;
text-decoration: none;
transition: color 0.2s ease;
}
.icp-link:hover,
.voicehub-link:hover {
color: var(--text-secondary);
}
.netlify-badge {
display: inline-flex;
align-items: center;
vertical-align: middle;
}
.netlify-badge img {
height: 16px;
opacity: 0.8;
transition: opacity 0.2s ease;
}
.netlify-badge:hover img {
opacity: 1;
}
.beian-icon {
height: 14px;
width: auto;
vertical-align: middle;
margin-right: 4px;
display: inline-block;
}
.sr-only {
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
}
@media (max-width: 768px) {
.site-footer {
padding: 15px 0;
margin-top: 20px;
}
.footer-info {
gap: 0;
}
.footer-item {
font-size: 11px;
}
.footer-item:not(:last-child)::after {
margin: 0 2px;
}
}
</style>