diff --git a/web/src/i18n/locales/en.json b/web/src/i18n/locales/en.json index 1f984333..21738a79 100644 --- a/web/src/i18n/locales/en.json +++ b/web/src/i18n/locales/en.json @@ -1526,5 +1526,8 @@ "腾讯混元": "Hunyuan", "360智脑": "360 AI Brain", "零一万物": "Yi", - "豆包": "Doubao" + "豆包": "Doubao", + "系统公告": "System Notice", + "今日关闭": "Close Today", + "关闭公告": "Close Notice" } \ No newline at end of file diff --git a/web/src/pages/Home/index.js b/web/src/pages/Home/index.js index e42be2e0..e88b0716 100644 --- a/web/src/pages/Home/index.js +++ b/web/src/pages/Home/index.js @@ -1,6 +1,6 @@ import React, { useContext, useEffect, useState } from 'react'; -import { Button, Typography, Tag } from '@douyinfe/semi-ui'; -import { API, showError, showNotice } from '../../helpers'; +import { Button, Typography, Tag, Modal } from '@douyinfe/semi-ui'; +import { API, showError, isMobile } from '../../helpers'; import { StatusContext } from '../../context/Status'; import { marked } from 'marked'; import { useTranslation } from 'react-i18next'; @@ -16,18 +16,34 @@ const Home = () => { const [statusState] = useContext(StatusContext); const [homePageContentLoaded, setHomePageContentLoaded] = useState(false); const [homePageContent, setHomePageContent] = useState(''); + const [noticeVisible, setNoticeVisible] = useState(false); + const [noticeContent, setNoticeContent] = useState(''); const isDemoSiteMode = statusState?.status?.demo_site_enabled || false; + const handleCloseNotice = () => { + setNoticeVisible(false); + }; + + const handleCloseTodayNotice = () => { + const today = new Date().toDateString(); + localStorage.setItem('notice_close_date', today); + setNoticeVisible(false); + }; + const displayNotice = async () => { const res = await API.get('/api/notice'); const { success, message, data } = res.data; if (success) { - let oldNotice = localStorage.getItem('notice'); - if (data !== oldNotice && data !== '') { - const htmlNotice = marked(data); - showNotice(htmlNotice, true); - localStorage.setItem('notice', data); + if (data !== '') { + const htmlNotice = marked.parse(data); + setNoticeContent(htmlNotice); + const lastCloseDate = localStorage.getItem('notice_close_date'); + const today = new Date().toDateString(); + + if (lastCloseDate !== today) { + setNoticeVisible(true); + } } } else { showError(message); @@ -71,6 +87,27 @@ const Home = () => { return (