diff --git a/components/GongAnBeiAn.js b/components/GongAnBeiAn.js new file mode 100644 index 00000000..61c8d6e1 --- /dev/null +++ b/components/GongAnBeiAn.js @@ -0,0 +1,30 @@ +import { siteConfig } from '@/lib/config' +import LazyImage from './LazyImage' + +/** + * 公安备案号组件 + * @returns + */ +export const GongAnBeiAn = () => { + const BEI_AN_GONGAN = siteConfig( + 'BEI_AN_GONGAN', + '京公网安备 11010102000001号' + ) + // 从BEI_AN_GONGAN 字段中利用正则匹配提取出纯数字部分 + const codeMatch = BEI_AN_GONGAN.match(/\d+/) // 匹配纯数字 + const code = codeMatch ? codeMatch[0] : null // 如果匹配成功则取出数字部分 + + const href = `https://beian.mps.gov.cn/#/query/webSearch?code=${code}` // 动态生成链接 + + if (!BEI_AN_GONGAN) { + return null + } + return ( +
+ + + {BEI_AN_GONGAN} + +
+ ) +} diff --git a/public/images/gongan.png b/public/images/gongan.png new file mode 100644 index 00000000..6fe667f7 Binary files /dev/null and b/public/images/gongan.png differ diff --git a/themes/commerce/components/Footer.js b/themes/commerce/components/Footer.js index a3eda45a..dbe0d224 100644 --- a/themes/commerce/components/Footer.js +++ b/themes/commerce/components/Footer.js @@ -1,3 +1,4 @@ +import { GongAnBeiAn } from '@/components/GongAnBeiAn' import { siteConfig } from '@/lib/config' import Link from 'next/link' import CONFIG from '../config' @@ -234,6 +235,7 @@ const Footer = props => { )} + diff --git a/themes/example/components/Footer.js b/themes/example/components/Footer.js index 77c8bad6..02614f9d 100644 --- a/themes/example/components/Footer.js +++ b/themes/example/components/Footer.js @@ -1,26 +1,46 @@ import DarkModeButton from '@/components/DarkModeButton' +import { GongAnBeiAn } from '@/components/GongAnBeiAn' import { siteConfig } from '@/lib/config' -export const Footer = (props) => { +export const Footer = props => { const d = new Date() const currentYear = d.getFullYear() const since = siteConfig('SINCE') - const copyrightDate = parseInt(since) < currentYear ? since + '-' + currentYear : currentYear + const copyrightDate = + parseInt(since) < currentYear ? since + '-' + currentYear : currentYear - return