From 1fd074951c1727529fc2108cf14fbe7dcc6a2055 Mon Sep 17 00:00:00 2001 From: shuai Date: Thu, 7 Sep 2023 10:53:26 +0800 Subject: [PATCH] fix: delete the slugtitle parameter in shared links to prevent the URL length from exceeding the limit #139 --- ui/src/components/Operate/index.tsx | 10 +--------- ui/src/components/Share/index.tsx | 16 ++++------------ ui/src/components/UserCard/index.tsx | 7 +++++-- .../Questions/Detail/components/Answer/index.tsx | 3 --- .../Detail/components/Question/index.tsx | 1 - ui/src/pages/Questions/Detail/index.tsx | 1 - 6 files changed, 10 insertions(+), 28 deletions(-) diff --git a/ui/src/components/Operate/index.tsx b/ui/src/components/Operate/index.tsx index d322b9d1..972b0501 100644 --- a/ui/src/components/Operate/index.tsx +++ b/ui/src/components/Operate/index.tsx @@ -23,7 +23,6 @@ interface IProps { qid: string; aid?: string; title: string; - slugTitle: string; hasAnswer?: boolean; isAccepted: boolean; callback: (type: string) => void; @@ -34,7 +33,6 @@ const Index: FC = ({ qid, aid = '', title, - slugTitle, isAccepted = false, hasAnswer = false, memberActions = [], @@ -268,13 +266,7 @@ const Index: FC = ({ return (
- + {firstAction?.map((item) => { if (item.action === 'edit') { return ( diff --git a/ui/src/components/Share/index.tsx b/ui/src/components/Share/index.tsx index dcab12fe..e9f739ce 100644 --- a/ui/src/components/Share/index.tsx +++ b/ui/src/components/Share/index.tsx @@ -6,17 +6,16 @@ import { FacebookShareButton, TwitterShareButton } from 'next-share'; import copy from 'copy-to-clipboard'; import { loggedUserInfoStore } from '@/stores'; -import { pathFactory } from '@/router/pathFactory'; interface IProps { type: 'answer' | 'question'; qid: any; aid?: any; title: string; - slugTitle: string; + // slugTitle: string; } -const Index: FC = ({ type, qid, aid, title, slugTitle = '' }) => { +const Index: FC = ({ type, qid, aid, title }) => { const user = loggedUserInfoStore((state) => state.user); const [show, setShow] = useState(false); const [showTip, setShowTip] = useState(false); @@ -24,15 +23,8 @@ const Index: FC = ({ type, qid, aid, title, slugTitle = '' }) => { const { t } = useTranslation(); let baseUrl = type === 'question' - ? `${window.location.origin}${pathFactory.questionLanding( - qid, - slugTitle, - )}` - : `${window.location.origin}${pathFactory.answerLanding({ - questionId: qid, - slugTitle, - answerId: aid, - })}`; + ? `${window.location.origin}/questions/${qid}` + : `${window.location.origin}/questions/${qid}/${aid}`; if (user.id) { baseUrl = `${baseUrl}?shareUserId=${user.username}`; } diff --git a/ui/src/components/UserCard/index.tsx b/ui/src/components/UserCard/index.tsx index b27abe33..26de5201 100644 --- a/ui/src/components/UserCard/index.tsx +++ b/ui/src/components/UserCard/index.tsx @@ -63,9 +63,12 @@ const Index: FC = ({ )}
-
+
{data?.status !== 'deleted' ? ( - + {data?.display_name} ) : ( diff --git a/ui/src/pages/Questions/Detail/components/Answer/index.tsx b/ui/src/pages/Questions/Detail/components/Answer/index.tsx index 26777cbb..9ad324ea 100644 --- a/ui/src/pages/Questions/Detail/components/Answer/index.tsx +++ b/ui/src/pages/Questions/Detail/components/Answer/index.tsx @@ -23,7 +23,6 @@ interface Props { aid?: string; canAccept: boolean; questionTitle: string; - slugTitle: string; isLogged: boolean; callback: (type: string) => void; } @@ -32,7 +31,6 @@ const Index: FC = ({ data, isLogged, questionTitle = '', - slugTitle, callback, canAccept = false, }) => { @@ -132,7 +130,6 @@ const Index: FC = ({ type="answer" isAccepted={data.accepted === 2} title={questionTitle} - slugTitle={slugTitle} callback={callback} />
diff --git a/ui/src/pages/Questions/Detail/components/Question/index.tsx b/ui/src/pages/Questions/Detail/components/Question/index.tsx index 0f1c3d04..22042919 100644 --- a/ui/src/pages/Questions/Detail/components/Question/index.tsx +++ b/ui/src/pages/Questions/Detail/components/Question/index.tsx @@ -148,7 +148,6 @@ const Index: FC = ({ data, initPage, hasAnswer, isLogged }) => { type="question" memberActions={data?.member_actions} title={data.title} - slugTitle={data.url_title} hasAnswer={hasAnswer} isAccepted={Boolean(data?.accepted_answer_id)} callback={initPage} diff --git a/ui/src/pages/Questions/Detail/index.tsx b/ui/src/pages/Questions/Detail/index.tsx index c625b0ce..317454df 100644 --- a/ui/src/pages/Questions/Detail/index.tsx +++ b/ui/src/pages/Questions/Detail/index.tsx @@ -234,7 +234,6 @@ const Index = () => { key={item?.id} data={item} questionTitle={question?.title || ''} - slugTitle={question?.url_title} canAccept={isAuthor || isAdmin || isModerator} callback={initPage} isLogged={isLogged}