Skip to content

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: delete the slugtitle parameter in shared links to prevent the URL length from exceeding the limit #139

shuai1fd074951c17
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<IProps> = ({
qid,
aid = '',
title,
- slugTitle,
isAccepted = false,
hasAnswer = false,
memberActions = [],
@@ -268,13 +266,7 @@ const Index: FC<IProps> = ({
return (
<div className="d-flex align-items-center">
- <Share
- type={type}
- qid={qid}
- aid={aid}
- title={title}
- slugTitle={slugTitle}
- />
+ <Share type={type} qid={qid} aid={aid} title={title} />
{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<IProps> = ({ type, qid, aid, title, slugTitle = '' }) => {
+const Index: FC<IProps> = ({ 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<IProps> = ({ 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<Props> = ({
</>
)}
<div className="small text-secondary d-flex flex-row flex-md-column align-items-center align-items-md-start">
- <div className="me-1 me-md-0">
+ <div className="me-1 me-md-0 d-flex align-items-center">
{data?.status !== 'deleted' ? (
- <Link to={`/users/${data?.username}`} className="me-1 text-break">
+ <Link
+ to={`/users/${data?.username}`}
+ className="me-1 text-break name-ellipsis"
+ style={{ maxWidth: '100px' }}>
{data?.display_name}
</Link>
) : (
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<Props> = ({
data,
isLogged,
questionTitle = '',
- slugTitle,
callback,
canAccept = false,
}) => {
@@ -132,7 +130,6 @@ const Index: FC<Props> = ({
type="answer"
isAccepted={data.accepted === 2}
title={questionTitle}
- slugTitle={slugTitle}
callback={callback}
/>
</div>
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<Props> = ({ 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}