diff --git a/src/CurrentYear.tsx b/src/CurrentYear.tsx new file mode 100644 index 0000000..651f036 --- /dev/null +++ b/src/CurrentYear.tsx @@ -0,0 +1,22 @@ +import { useEffect, useState } from 'react'; + +// Update every half hour +const TIMER_UPDATE_INTERVAL = 30 * 60 * 1000; + +const getCurrentYear = () => new Date().getFullYear(); + +export function CurrentYear() { + const [year, setYear] = useState(getCurrentYear); + + useEffect(() => { + const updateTime = () => setYear(getCurrentYear); + updateTime(); + + const timer = setInterval(updateTime, TIMER_UPDATE_INTERVAL); + return () => { + clearInterval(timer); + }; + }, []); + + return <>{year}; +} diff --git a/src/Footer.tsx b/src/Footer.tsx index a8c121e..8cd3c68 100644 --- a/src/Footer.tsx +++ b/src/Footer.tsx @@ -1,6 +1,7 @@ import { Center, Flex, Link, Text } from '@chakra-ui/react'; import { Suspense } from 'react'; import { SDKVersion } from './SDKVersion'; +import { CurrentYear } from './CurrentYear'; export function Footer() { return ( @@ -25,7 +26,8 @@ export function Footer() { {') - 移除已购音乐的加密保护。'} - {'Copyright © 2019 - 2023 '} + {'Copyright © 2019 - '} + {' '} UnlockMusic 团队