Merge branch 'feat/ui-v0.4' into 'test'

bug fixes

See merge request opensource/answer!249
This commit is contained in:
贾海涛(龙笛)
2022-11-17 06:51:37 +00:00
8 changed files with 42 additions and 17 deletions
+1
View File
@@ -337,6 +337,7 @@ export interface SearchResItem {
object_type: string;
object: {
id: string;
question_id?: string;
title: string;
excerpt: string;
created_at: number;
@@ -22,17 +22,36 @@ const HealthStatus: FC<IProps> = ({ data }) => {
<span className="text-secondary me-1">{t('version')}</span>
<strong>{version}</strong>
{isLatest && (
<Badge pill bg="success" className="ms-1">
<Badge
pill
bg="success"
className="ms-1"
as="a"
target="_blank"
href="https://github.com/answerdev/answer/releases">
{t('latest')}
</Badge>
)}
{!isLatest && remote_version && (
<Badge pill bg="warning" text="dark" className="ms-1">
<Badge
pill
bg="warning"
text="dark"
className="ms-1"
as="a"
target="_blank"
href="https://github.com/answerdev/answer/releases">
{t('update_to')} {remote_version}
</Badge>
)}
{!isLatest && !remote_version && (
<Badge pill bg="danger" className="ms-1">
<Badge
pill
bg="danger"
className="ms-1"
as="a"
target="_blank"
href="https://github.com/answerdev/answer/releases">
{t('check_failed')}
</Badge>
)}
@@ -36,7 +36,7 @@ const Index: FC<Props> = ({ data }) => {
<div className="mb-5">
<h3 className="mb-3">{t('title')}</h3>
<p>
<span className="me-1 text-secondary">{t('keywords')}</span>
<span className="text-secondary">{t('keywords')}</span>
{q?.replace(reg, '')}
<br />
{options?.length && (
@@ -14,6 +14,10 @@ const Index: FC<Props> = ({ data }) => {
if (!data?.object_type) {
return null;
}
let itemUrl = `/questions/${data.object.id}`;
if (data.object_type === 'answer') {
itemUrl = `/questions/${data.object.question_id}/${data.object.id}`;
}
return (
<ListGroupItem className="py-3 px-0">
<div className="mb-2 clearfix">
@@ -23,9 +27,7 @@ const Index: FC<Props> = ({ data }) => {
style={{ marginTop: '2px' }}>
{data.object_type === 'question' ? 'Q' : 'A'}
</Badge>
<a
className="h5 mb-0 link-dark text-break"
href={`/questions/${data.object.id}`}>
<a className="h5 mb-0 link-dark text-break" href={itemUrl}>
{data.object.title}
{data.object.status === 'closed'
? ` [${t('closed', { keyPrefix: 'question' })}]`
+5 -2
View File
@@ -1,6 +1,6 @@
import { FC, memo, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { useSearchParams } from 'react-router-dom';
import { useSearchParams, useNavigate } from 'react-router-dom';
import { loggedUserInfoStore } from '@/stores';
import { activateAccount } from '@/services';
@@ -10,6 +10,7 @@ const Index: FC = () => {
const { t } = useTranslation('translation', { keyPrefix: 'page_title' });
const [searchParams] = useSearchParams();
const updateUser = loggedUserInfoStore((state) => state.update);
const navigate = useNavigate();
useEffect(() => {
const code = searchParams.get('code');
@@ -17,9 +18,11 @@ const Index: FC = () => {
activateAccount(encodeURIComponent(code)).then((res) => {
updateUser(res);
setTimeout(() => {
window.location.replace('/users/account-activation/success');
navigate('/users/account-activation/success', { replace: true });
}, 0);
});
} else {
navigate('/', { replace: true });
}
}, []);
return <PageTitle title={t('account_activation')} />;
+7 -7
View File
@@ -167,13 +167,13 @@ const routes: RouteNode[] = [
{
path: 'users/account-activation',
page: 'pages/Users/ActiveEmail',
guard: async () => {
const notActivated = guard.notActivated();
if (notActivated.ok) {
return notActivated;
}
return guard.notLogged();
},
// guard: async () => {
// const notActivated = guard.notActivated();
// if (notActivated.ok) {
// return notActivated;
// }
// return guard.notLogged();
// },
},
{
path: 'users/account-activation/success',
-1
View File
@@ -85,7 +85,6 @@ export const getCurrentLang = () => {
export const setupAppLanguage = async () => {
const lang = getCurrentLang();
console.log(lang);
if (!i18next.getDataByLanguage(lang)) {
await addI18nResource(lang);
}
+1
View File
@@ -103,6 +103,7 @@ class Request {
return Promise.reject(false);
}
if (status === 403) {
debugger;
// Permission interception
if (data?.type === 'url_expired') {
// url expired