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: axios status 403 show error msg

shuai449db3bf5bc3
diff --git a/ui/src/common/interface.ts b/ui/src/common/interface.ts
index e5d711f5..60e83af2 100644
--- a/ui/src/common/interface.ts
+++ b/ui/src/common/interface.ts
@@ -406,7 +406,7 @@ export interface TimelineObject {
question_id: string;
answer_id: string;
main_tag_slug_name?: string;
- username?: string;
+ display_name?: string;
}
export interface TimelineRes {
diff --git a/ui/src/components/DiffContent/index.tsx b/ui/src/components/DiffContent/index.tsx
index 336f71a8..2362e81c 100644
--- a/ui/src/components/DiffContent/index.tsx
+++ b/ui/src/components/DiffContent/index.tsx
@@ -87,7 +87,7 @@ const Index: FC<Props> = ({
</div>
)}
{objectType === 'tag' && opts?.showTagUrlSlug && (
- <div className="mb-4">
+ <div className="mb-4 fs-14 font-monospace">
{`/tags/${
newData?.main_tag_slug_name
? diffText(
diff --git a/ui/src/pages/Timeline/index.tsx b/ui/src/pages/Timeline/index.tsx
index ae0b7c18..f365fa2b 100644
--- a/ui/src/pages/Timeline/index.tsx
+++ b/ui/src/pages/Timeline/index.tsx
@@ -52,7 +52,7 @@ const Index: FC = () => {
linkUrl = `/questions/${timelineData?.object_info.question_id}/${timelineData?.object_info.answer_id}`;
pageTitle = `${t('title_for_answer', {
title: timelineData?.object_info.title,
- author: timelineData?.object_info.username,
+ author: timelineData?.object_info.display_name,
})}`;
}
diff --git a/ui/src/utils/request.ts b/ui/src/utils/request.ts
index 410992f2..13b668ea 100644
--- a/ui/src/utils/request.ts
+++ b/ui/src/utils/request.ts
@@ -48,7 +48,7 @@ class Request {
return data;
},
(error) => {
- const { status, data: respData, msg: respMsg } = error.response || {};
+ const { status, data: respData } = error.response || {};
const { data = {}, msg = '' } = respData || {};
if (status === 400) {
// show error message
@@ -121,12 +121,19 @@ class Request {
});
return Promise.reject(false);
}
+
+ if (msg) {
+ toastStore.getState().show({
+ msg,
+ variant: 'danger',
+ });
+ }
+ return Promise.reject(false);
}
- if (respMsg) {
- toastStore.getState().show({
- msg: `statusCode: ${status}; ${respMsg || ''}`,
- variant: 'danger',
- });
+ if (status >= 500) {
+ console.error(
+ `Request failed with status code ${status}, ${msg || ''}`,
+ );
}
return Promise.reject(false);
},