From 49d0f6df8d4d756669879d560b6305f980378560 Mon Sep 17 00:00:00 2001 From: "haitao(lj)" Date: Fri, 30 Sep 2022 11:10:25 +0800 Subject: [PATCH] feat(question): add [closed] tip for all question title --- ui/src/common/interface.ts | 1 + ui/src/common/variable.scss | 1 + .../Questions/Ask/components/SearchQuestion/index.tsx | 7 ++++++- ui/src/pages/Search/components/SearchItem/index.tsx | 10 ++++++---- .../Users/Personal/components/DefaultList/index.tsx | 3 +++ 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ui/src/common/interface.ts b/ui/src/common/interface.ts index daf17261..08d206f2 100644 --- a/ui/src/common/interface.ts +++ b/ui/src/common/interface.ts @@ -301,6 +301,7 @@ export interface SearchResItem { answer_count: number; accepted: boolean; tags: TagBase[]; + status?: string; }; } export interface SearchRes extends ListResult { diff --git a/ui/src/common/variable.scss b/ui/src/common/variable.scss index 1f6b7fca..99766954 100644 --- a/ui/src/common/variable.scss +++ b/ui/src/common/variable.scss @@ -1 +1,2 @@ $link-hover-decoration: none; +$blue: #0033FF !default; diff --git a/ui/src/pages/Questions/Ask/components/SearchQuestion/index.tsx b/ui/src/pages/Questions/Ask/components/SearchQuestion/index.tsx index 1f3bde27..84ccfe47 100644 --- a/ui/src/pages/Questions/Ask/components/SearchQuestion/index.tsx +++ b/ui/src/pages/Questions/Ask/components/SearchQuestion/index.tsx @@ -30,7 +30,12 @@ const SearchQuestion = ({ similarQuestions }) => { key={item.id} href={`/questions/${item.id}`} target="_blank"> - {item.title} + + {item.title} + {item.status === 'closed' + ? ` [${t('closed', { keyPrefix: 'question' })}]` + : null} + {item.accepted_answer ? ( diff --git a/ui/src/pages/Search/components/SearchItem/index.tsx b/ui/src/pages/Search/components/SearchItem/index.tsx index c0c7af52..73e98a03 100644 --- a/ui/src/pages/Search/components/SearchItem/index.tsx +++ b/ui/src/pages/Search/components/SearchItem/index.tsx @@ -1,5 +1,6 @@ import { memo, FC } from 'react'; import { ListGroupItem, Badge } from 'react-bootstrap'; +import { useTranslation } from 'react-i18next'; import { Icon, Tag, FormatTime, BaseUserCard } from '@answer/components'; import type { SearchResItem } from '@answer/common/interface'; @@ -8,6 +9,8 @@ interface Props { data: SearchResItem; } const Index: FC = ({ data }) => { + const { t } = useTranslation('translation', { keyPrefix: 'question' }); + console.log('t: ', t); if (!data?.object_type) { return null; } @@ -24,6 +27,9 @@ const Index: FC = ({ data }) => { className="h5 mb-0 text-body text-break" href={`/questions/${data.object.id}`}> {data.object.title} + {data.object.status === 'closed' + ? ` [${t('closed', { keyPrefix: 'question' })}]` + : null}
@@ -51,10 +57,6 @@ const Index: FC = ({ data }) => { )} {data.object?.answer_count}
- {/*
- - 0 -
*/} diff --git a/ui/src/pages/Users/Personal/components/DefaultList/index.tsx b/ui/src/pages/Users/Personal/components/DefaultList/index.tsx index 369e6eb4..f0d69b62 100644 --- a/ui/src/pages/Users/Personal/components/DefaultList/index.tsx +++ b/ui/src/pages/Users/Personal/components/DefaultList/index.tsx @@ -27,6 +27,9 @@ const Index: FC = ({ visible, tabName, data }) => { tabName === 'questions' ? item.question_id : item.id }`}> {item.title} + {tabName === 'questions' && item.status === 'closed' + ? ` [${t('closed', { keyPrefix: 'question' })}]` + : null}