From d0455386e591d0a172dd520b7d2e0c281cb09b4f Mon Sep 17 00:00:00 2001 From: ailoooong Date: Thu, 2 Jan 2025 16:48:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=89=88=E6=9D=83=E5=B9=B4=E4=BB=BD?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/.vitepress/src/components/AppFooter.vue | 4 ++-- app/.vitepress/src/i18n/lang/home/en-home.ts | 2 +- app/.vitepress/src/i18n/lang/home/zh-home.ts | 2 +- app/.vitepress/src/shared/utils.ts | 17 +++++++++++++++++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/app/.vitepress/src/components/AppFooter.vue b/app/.vitepress/src/components/AppFooter.vue index 7c7aed7..8ec1d1f 100644 --- a/app/.vitepress/src/components/AppFooter.vue +++ b/app/.vitepress/src/components/AppFooter.vue @@ -12,7 +12,7 @@ import wechat_img from '@/assets/qrcode.png'; import wechat_QR from '@/assets/qrcode1.png'; import { BILIBILI_LINK, APACHE_LINK, CONTACT_MAIL } from '@/data/url-config'; -import { windowOpen } from '@/shared/utils'; +import { windowOpen, getYearByOffset } from '@/shared/utils'; interface NavItem { id: string; @@ -25,7 +25,7 @@ const data = useData(); // footer const footer = computed(() => { return { - copyright: t('footer.copyright'), + copyright: t('footer.copyright', { year: getYearByOffset() }), codeDesc: t('footer.code_text'), email: CONTACT_MAIL, footerOptions: [ diff --git a/app/.vitepress/src/i18n/lang/home/en-home.ts b/app/.vitepress/src/i18n/lang/home/en-home.ts index 6bc9850..dbf2160 100644 --- a/app/.vitepress/src/i18n/lang/home/en-home.ts +++ b/app/.vitepress/src/i18n/lang/home/en-home.ts @@ -93,7 +93,7 @@ export default { search_placeholder: 'Input content', }, footer: { - copyright: 'Copyright © 2024 openLooKeng. All rights reserved.', + copyright: 'Copyright © {year} openLooKeng. All rights reserved.', code_text: 'Follow Us', brand: 'Trademark', legal: 'Legal Notice', diff --git a/app/.vitepress/src/i18n/lang/home/zh-home.ts b/app/.vitepress/src/i18n/lang/home/zh-home.ts index cfa7c05..e85732e 100644 --- a/app/.vitepress/src/i18n/lang/home/zh-home.ts +++ b/app/.vitepress/src/i18n/lang/home/zh-home.ts @@ -89,7 +89,7 @@ export default { search_placeholder: '请输入关键词', }, footer: { - copyright: '版权所有 © 2024 openLooKeng 保留一切权利', + copyright: '版权所有 © {year} openLooKeng 保留一切权利', code_text: '关注我们', brand: '品牌', legal: '法律声明', diff --git a/app/.vitepress/src/shared/utils.ts b/app/.vitepress/src/shared/utils.ts index 1fb71be..5195576 100644 --- a/app/.vitepress/src/shared/utils.ts +++ b/app/.vitepress/src/shared/utils.ts @@ -55,3 +55,20 @@ export const windowOpen = ( export function isBoolean(val: unknown): val is boolean { return typeof val === 'boolean'; } + + +/** + * 获取指定时区偏移量的年份 + * @param {number} offset - 时区偏移量(单位:小时)。例如,UTC+8 时区,传入 8。 + * @returns {number} - 指定时区偏移量对应的年份 + */ +export const getYearByOffset = () => { + // 获取当前时间的 UTC 时间 + const now = new Date(); + const utcTime = new Date(now.getTime() + now.getTimezoneOffset() * 60000); + + // 设置偏移 + utcTime.setHours(utcTime.getHours() + 8); + + return utcTime.getFullYear(); +} \ No newline at end of file -- Gitee