From 1642b5ad813c7e4c726d9c6a8d02c8496e0d80a3 Mon Sep 17 00:00:00 2001 From: linxd <544554903@qq.com> Date: Thu, 3 Jul 2025 11:29:53 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=B2=E6=94=B9=E9=80=9A=E7=9F=A5=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E4=B8=8E=E4=B8=8B=E8=BD=BD=E4=B8=AD=E5=BF=83=E7=9A=84?= =?UTF-8?q?=E5=B7=A6=E4=BE=A7=E8=8F=9C=E5=8D=95=E5=AD=97=E5=85=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/download/download.tsx | 31 ++++++++++++++--------- src/pages/notice/notice.tsx | 31 ++++++++++++++--------- src/servers/api/dict.ts | 45 +++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 24 deletions(-) create mode 100644 src/servers/api/dict.ts diff --git a/src/pages/download/download.tsx b/src/pages/download/download.tsx index 47ca03f..b512109 100644 --- a/src/pages/download/download.tsx +++ b/src/pages/download/download.tsx @@ -3,19 +3,18 @@ import { Card, Menu, Row, Col, Pagination, Button, Typography, Space, message } import { FileOutlined, BookOutlined, DownloadOutlined } from '@ant-design/icons'; import { useIntl, FormattedMessage } from 'umi'; import styles from './download.less'; -import { downloadFile, getDownloadList, DownloadRecord } from '@/servers/api/download'; +import { getDownloadList } from '@/servers/api/download'; +import type { DownloadRecord } from '@/servers/api/download'; +import { getDictList } from '@/servers/api/dict'; +import type { DictItem } from '@/servers/api/dict'; const { Title, Text } = Typography; -// 模拟模板文件数据 - 后期将通过API获取分类 -const mockCategories: { [key: string]: string } = { - template: '模板文件', - manual: '操作手册' -}; const DownloadPage: React.FC = () => { const intl = useIntl(); const [activeMenu, setActiveMenu] = useState('template'); + const [menuList, setMenuList] = useState([]); const [downloadData, setDownloadData] = useState([]); const [loading, setLoading] = useState(true); const [pagination, setPagination] = useState({ @@ -55,6 +54,15 @@ const DownloadPage: React.FC = () => { } }; + // 获取下载中心左侧菜单字典 + useEffect(() => { + getDictList('download_section').then((res) => { + if (res.code === 200 && res.success) { + setMenuList(res.data); + } + }); + }, []); + // 初始加载和分页变化时加载数据 useEffect(() => { loadDownloadData(pagination.current, pagination.pageSize); @@ -105,12 +113,11 @@ const DownloadPage: React.FC = () => { onClick={handleMenuClick} className={styles.downloadMenu} > - }> - - - }> - - + {menuList.map((item) => ( + }> + {item.dicName} + + ))} diff --git a/src/pages/notice/notice.tsx b/src/pages/notice/notice.tsx index 516aef8..dde48b3 100644 --- a/src/pages/notice/notice.tsx +++ b/src/pages/notice/notice.tsx @@ -3,17 +3,16 @@ import { Table, Menu, Row, Col, message } from 'antd'; import { history, useIntl, FormattedMessage } from 'umi'; import { BellOutlined, AppstoreOutlined } from '@ant-design/icons'; import styles from './notice.less'; -import { getNoticeList, NoticeRecord } from '@/servers/api/notice'; +import { getNoticeList } from '@/servers/api/notice'; +import type { NoticeRecord } from '@/servers/api/notice'; +import { getDictList } from '@/servers/api/dict'; +import type { DictItem } from '@/servers/api/dict'; -// 通知类型映射 -const noticeTypes: { [key: string]: string } = { - system: '系统更新通知', - other: '其他通知' -}; const NoticePage: React.FC = () => { const intl = useIntl(); const [activeMenu, setActiveMenu] = useState('system'); + const [menuList, setMenuList] = useState([]); const [noticeData, setNoticeData] = useState([]); const [loading, setLoading] = useState(true); const [pagination, setPagination] = useState({ @@ -53,6 +52,15 @@ const NoticePage: React.FC = () => { } }; + // 获取通知中心左侧菜单字典 + useEffect(() => { + getDictList('notification_center').then((res) => { + if (res.code === 200 && res.success) { + setMenuList(res.data); + } + }); + }, []); + // 初始加载和分页变化时加载数据 useEffect(() => { loadNoticeData(pagination.current, pagination.pageSize); @@ -121,12 +129,11 @@ const NoticePage: React.FC = () => { onClick={handleMenuClick} className={styles.noticeMenu} > - }> - - - }> - - + {menuList.map((item) => ( + }> + {item.dicName} + + ))} diff --git a/src/servers/api/dict.ts b/src/servers/api/dict.ts new file mode 100644 index 0000000..7a6c0b0 --- /dev/null +++ b/src/servers/api/dict.ts @@ -0,0 +1,45 @@ +import request from '@/utils/request'; + +// 定义接口返回数据类型 +export type DictResponse = { + code: number; + data: DictItem[]; + message: string; + success: boolean; + [property: string]: any; +} + +export type DictItem = { + basePageRequest: null; + code: string; + createBy: null; + createDate: null; + defaultFlag: null; + deleteFlag: null; + description: string; + dicName: string; + dictTypeCode: null | string; + dictTypeName: null | string; + id: string; + lastUpdateTime: null; + orderFlag: string; + parentCode: string; + parentType: string; + tenantId: null; + tenantName: null; + updateBy: null; + updateDate: null; + useFlag: string; + [property: string]: any; +} + +/** + * 获取字典列表 + * @param code 字典编码 + * @returns 字典列表 + */ +export async function getDictList(code: string): Promise { + return request(`/cosco/dictProject/getAllList/${code}`, { + method: 'GET', + }); +}