A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
fix: linked page list add order params
shuai81fbea171b16
diff --git a/ui/src/pages/Questions/Detail/components/LinkedQuestions/index.tsx b/ui/src/pages/Questions/Detail/components/LinkedQuestions/index.tsxindex c5d92cbe..0706cc4b 100644--- a/ui/src/pages/Questions/Detail/components/LinkedQuestions/index.tsx+++ b/ui/src/pages/Questions/Detail/components/LinkedQuestions/index.tsx@@ -25,7 +25,7 @@ import { useTranslation } from 'react-i18next';import { isEmpty } from 'lodash';import { Icon } from '@/components';-import { questionLink } from '@/services';+import { useQuestionLink } from '@/services';import { pathFactory } from '@/router/pathFactory';interface Props {@@ -39,7 +39,7 @@ const Index: FC<Props> = ({ id }) => {keyPrefix: 'related_question',});- const { data } = questionLink({+ const { data } = useQuestionLink({question_id: id,page: 1,page_size: 5,diff --git a/ui/src/pages/Questions/Linked/index.tsx b/ui/src/pages/Questions/Linked/index.tsxindex 981e8c4e..9a08af52 100644--- a/ui/src/pages/Questions/Linked/index.tsx+++ b/ui/src/pages/Questions/Linked/index.tsx@@ -17,13 +17,13 @@* under the License.*/-import { FC, useState } from 'react';+import { FC, useEffect, useState } from 'react';import { Row, Col } from 'react-bootstrap';import { useParams, useSearchParams, Link } from 'react-router-dom';import { useTranslation } from 'react-i18next';import { usePageTags } from '@/hooks';-import { questionLink, questionDetail } from '@/services';+import { useQuestionLink, questionDetail } from '@/services';import * as Type from '@/common/interface';import {QuestionList,@@ -50,21 +50,25 @@ const LinkedQuestions: FC = () => {QUESTION_ORDER_KEYS[0]) as Type.QuestionOrderBy;const pageSize = 10;const { siteInfo } = siteInfoStore();- const { data: listData, isLoading: listLoading } = questionLink({+ const { data: listData, isLoading: listLoading } = useQuestionLink({question_id: qid || '',page: curPage,page_size: pageSize,+ order: curOrder,});const { login: loginSetting } = loginSettingStore();const [questionTitle, setQuestionTitle] = useState('');- questionDetail(qid || '')- .then((res) => {- setQuestionTitle(res.title);- })- .catch((err) => {- console.error('get question detail failed:', err);- setQuestionTitle(`#${qid}`);- });++ useEffect(() => {+ questionDetail(qid || '')+ .then((res) => {+ setQuestionTitle(res.title);+ })+ .catch((err) => {+ console.error('get question detail failed:', err);+ setQuestionTitle(`#${qid}`);+ });+ }, []);usePageTags({title: t('title'),});@@ -81,11 +85,7 @@ const LinkedQuestions: FC = () => {source="linked"data={listData}order={curOrder}- orderList={- loggedUser.username- ? QUESTION_ORDER_KEYS- : QUESTION_ORDER_KEYS.filter((key) => key !== 'recommend')- }+ orderList={QUESTION_ORDER_KEYS.slice(0, 5)}isLoading={listLoading}/></Col>diff --git a/ui/src/pages/Tags/Detail/index.tsx b/ui/src/pages/Tags/Detail/index.tsxindex ac2fa937..33f65414 100644--- a/ui/src/pages/Tags/Detail/index.tsx+++ b/ui/src/pages/Tags/Detail/index.tsx@@ -176,7 +176,7 @@ const Index: FC = () => {source="tag"data={listData}order={curOrder}- orderList={QUESTION_ORDER_KEYS.slice(0, 4)}+ orderList={QUESTION_ORDER_KEYS.slice(0, 5)}isLoading={listLoading}/></Col>diff --git a/ui/src/services/common.ts b/ui/src/services/common.tsindex ad0d99e0..724f8eca 100644--- a/ui/src/services/common.ts+++ b/ui/src/services/common.ts@@ -199,10 +199,11 @@ export const questionDetail = (id: string) => {);};-export const questionLink = (params: {+export const useQuestionLink = (params: {question_id: string;page: number;page_size: number;+ order?: string;}) => {const apiUrl = `/answer/api/v1/question/link?${qs.stringify(params)}`;const { data, error } = useSWR<Type.ListResult, Error>(