2023-08-25 19:38:52 +08:00
|
|
|
import { useState } from 'react'
|
|
|
|
import { useContext } from 'use-context-selector'
|
|
|
|
import I18n from '@/context/i18n'
|
|
|
|
import { X } from '@/app/components/base/icons/src/vender/line/general'
|
2024-02-23 14:31:06 +08:00
|
|
|
import { NOTICE_I18N } from '@/i18n/language'
|
2023-08-25 19:38:52 +08:00
|
|
|
|
|
|
|
const MaintenanceNotice = () => {
|
|
|
|
const { locale } = useContext(I18n)
|
2024-01-26 15:28:33 +08:00
|
|
|
|
2023-08-25 19:38:52 +08:00
|
|
|
const [showNotice, setShowNotice] = useState(localStorage.getItem('hide-maintenance-notice') !== '1')
|
2024-01-26 13:23:06 +08:00
|
|
|
const handleJumpNotice = () => {
|
|
|
|
window.open(NOTICE_I18N.href, '_blank')
|
|
|
|
}
|
2024-01-26 15:28:33 +08:00
|
|
|
|
2023-08-25 19:38:52 +08:00
|
|
|
const handleCloseNotice = () => {
|
|
|
|
localStorage.setItem('hide-maintenance-notice', '1')
|
|
|
|
setShowNotice(false)
|
|
|
|
}
|
|
|
|
|
2024-01-23 21:14:53 +08:00
|
|
|
const titleByLocale: { [key: string]: string } = NOTICE_I18N.title
|
|
|
|
const descByLocale: { [key: string]: string } = NOTICE_I18N.desc
|
|
|
|
|
2023-08-25 19:38:52 +08:00
|
|
|
if (!showNotice)
|
|
|
|
return null
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className='shrink-0 flex items-center px-4 h-[38px] bg-[#FFFAEB] border-b border-[0.5px] border-b-[#FEF0C7] z-20'>
|
2024-02-23 14:31:06 +08:00
|
|
|
<div className='shrink-0 flex items-center mr-2 px-2 h-[22px] bg-[#F79009] text-white text-[11px] font-medium rounded-xl'>{titleByLocale[locale]}</div>
|
2024-01-26 15:28:33 +08:00
|
|
|
{
|
|
|
|
(NOTICE_I18N.href && NOTICE_I18N.href !== '#')
|
2024-02-23 14:31:06 +08:00
|
|
|
? <div className='grow text-xs font-medium text-gray-700 cursor-pointer' onClick={handleJumpNotice}>{descByLocale[locale]}</div>
|
|
|
|
: <div className='grow text-xs font-medium text-gray-700'>{descByLocale[locale]}</div>
|
2024-01-26 15:28:33 +08:00
|
|
|
}
|
|
|
|
<X className='shrink-0 w-4 h-4 text-gray-500 cursor-pointer' onClick={handleCloseNotice} />
|
2023-08-25 19:38:52 +08:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default MaintenanceNotice
|