From c7ae51ebd31fa9fbe8d48cce229d74e46ea91de0 Mon Sep 17 00:00:00 2001 From: linxd <544554903@qq.com> Date: Wed, 6 Aug 2025 14:17:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/help/help.less | 7 ++++- src/pages/help/help.tsx | 42 ++++++++++++++++++++------- src/pages/help/helpInfo.tsx | 50 ++++++++++++++------------------ src/pages/index/index.tsx | 4 +-- src/pages/notice/noticeInfo.less | 1 + src/pages/notice/noticeInfo.tsx | 2 +- src/pages/policy/policyInfo.tsx | 2 +- src/servers/api/help.ts | 19 ++++++++++++ 8 files changed, 83 insertions(+), 44 deletions(-) diff --git a/src/pages/help/help.less b/src/pages/help/help.less index f2dfaef..7ded55b 100644 --- a/src/pages/help/help.less +++ b/src/pages/help/help.less @@ -8,7 +8,7 @@ display: flex; justify-content: space-between; align-items: center; - margin-bottom: 20px; + // margin-bottom: 20px; h2 { margin-bottom: 0; @@ -34,4 +34,9 @@ } } } + .ant-tabs-nav { + &::before { + border: none; + } + } } diff --git a/src/pages/help/help.tsx b/src/pages/help/help.tsx index 05705b8..1874610 100644 --- a/src/pages/help/help.tsx +++ b/src/pages/help/help.tsx @@ -1,32 +1,43 @@ -import React, { useState, useEffect } from 'react'; -import { Table, Typography, Button } from 'antd'; -import { history, useIntl } from 'umi'; +import React, { useState, useEffect, useRef } from 'react'; +import { Table, Typography, Button, Tabs } from 'antd'; +import { history, useIntl, connect } from 'umi'; +import type { ConnectProps, Dispatch } from 'umi'; import { PlusOutlined } from '@ant-design/icons'; -import { getHelpCenterList } from '@/servers/api/help'; +import { getHelpCenterList, qandaGetPage } from '@/servers/api/help'; +import type { UserModelState } from '@/models/user'; import { QUESTION_TYPES } from '@/dicts/help'; import './help.less'; +import type { UserInfo } from '@/models/user'; const { Title } = Typography; - -const HelpPage: React.FC = () => { +interface PageProps extends ConnectProps { + user: UserModelState; // dva model状态 + dispatch: Dispatch; // dva dispatch方法 +} +const HelpPage: React.FC = ({ user, dispatch }) => { const intl = useIntl(); const [helpData, setHelpData] = useState([]); const [loading, setLoading] = useState(true); + const userInfo: UserInfo | undefined = user.userInfo; const [pagination, setPagination] = useState({ current: 1, pageSize: 10, total: 0, }); + const tabActiveKey = useRef('helpCenter'); // 获取帮助中心数据 const fetchHelpData = async (current = 1, pageSize = 10) => { setLoading(true); + console.log(userInfo?.userId); + const request = tabActiveKey.current == 'helpCenter' ? getHelpCenterList : qandaGetPage; try { - const response = await getHelpCenterList({ + const response = await request({ basePageRequest: { pageNo: current, pageSize: pageSize, }, + createBy: tabActiveKey.current == 'myQuestion' ? userInfo?.userId : null }); if (response.success) { @@ -56,7 +67,7 @@ const HelpPage: React.FC = () => { // 处理点击问题标题 const handleHelpClick = (id: string) => { - history.push(`/help/helpInfo?id=${id}`); + history.push(`/help/helpInfo?id=${id}&tabActiveKey=${tabActiveKey.current}`); }; // 处理点击提问按钮 @@ -66,7 +77,7 @@ const HelpPage: React.FC = () => { // 获取问题分类名称 const getQuestionTypeName = (type: string) => { - const found = QUESTION_TYPES.find(item => item.value === type); + const found = QUESTION_TYPES.find((item) => item.value === type); return found ? found.label : type; }; @@ -107,10 +118,19 @@ const HelpPage: React.FC = () => { }, ]; + // 处理标签页切换 + const tabsOnChange = (key: string) => { + tabActiveKey.current = key; + fetchHelpData(); + }; + return (
- {intl.formatMessage({ id: 'help.title' })} + + + {user.token && } +
-
- - {helpDetail.title} - -
- -
-
- - {intl.formatMessage({ id: 'help.info.publishTime' })}: {helpDetail.createTime} - -
-
- - {intl.formatMessage({ id: 'help.info.questionType' })}: {getQuestionTypeName(helpDetail.type)} | - {intl.formatMessage({ id: 'help.info.publisher' })}: {helpDetail.createBy || '系统管理员'} - -
-
+ + {/* <QuestionCircleOutlined /> */} + <CommentOutlined /> + <span style={{ margin: '0 15px' }}>{helpDetail.title}</span> + <Tag color="success">{helpDetail.isAnswer == '1' ? '已回答' : '未回答'}</Tag> + +
-
+ 答: +
diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 9de361d..3088e59 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -199,7 +199,7 @@ const IndexPage: React.FC = ({ user }) => { className="cardTitleText" onClick={() => { history.push({ - pathname: '/announce/announceInfo', + pathname: '/notice/noticeInfo', search: '?id=' + item.id, }); }} @@ -361,7 +361,7 @@ const IndexPage: React.FC = ({ user }) => {
友情链接
{friendshipConnections.map((item, index) => ( - + window.open(item.url)} key={item.id} style={{ width: '16.6667%', height: '130px' }}> ))} diff --git a/src/pages/notice/noticeInfo.less b/src/pages/notice/noticeInfo.less index 1d12208..ca9b8ac 100644 --- a/src/pages/notice/noticeInfo.less +++ b/src/pages/notice/noticeInfo.less @@ -62,6 +62,7 @@ .contentBody { font-size: 16px; line-height: 1.8; + word-break: break-all; p { margin-bottom: 16px; diff --git a/src/pages/notice/noticeInfo.tsx b/src/pages/notice/noticeInfo.tsx index ac164b9..0a04ff6 100644 --- a/src/pages/notice/noticeInfo.tsx +++ b/src/pages/notice/noticeInfo.tsx @@ -79,7 +79,7 @@ const NoticeInfo: React.FC = () => { }; return ( -
+