mirror of https://gitee.com/answerdev/answer.git
Merge branch 'feat/1.0.7/ui' of github.com:answerdev/answer into feat/1.0.7/ui
This commit is contained in:
commit
9a410a1250
|
@ -5,6 +5,7 @@ import { NavLink, useNavigate } from 'react-router-dom';
|
|||
|
||||
import type * as Type from '@/common/interface';
|
||||
import { Avatar, Icon } from '@/components';
|
||||
import { floppyNavigation } from '@/utils';
|
||||
|
||||
interface Props {
|
||||
redDot: Type.NotificationStatus | undefined;
|
||||
|
@ -16,10 +17,12 @@ const Index: FC<Props> = ({ redDot, userInfo, logOut }) => {
|
|||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const handleLinkClick = (evt) => {
|
||||
evt.preventDefault();
|
||||
const { href } = evt.currentTarget;
|
||||
const { pathname } = new URL(href);
|
||||
navigate(pathname);
|
||||
if (floppyNavigation.shouldProcessLinkClick(evt)) {
|
||||
evt.preventDefault();
|
||||
const { href } = evt.currentTarget;
|
||||
const { pathname } = new URL(href);
|
||||
navigate(pathname);
|
||||
}
|
||||
};
|
||||
return (
|
||||
<>
|
||||
|
|
|
@ -70,10 +70,12 @@ const Header: FC = () => {
|
|||
window.location.replace(window.location.href);
|
||||
};
|
||||
const onLoginClick = (evt) => {
|
||||
evt.preventDefault();
|
||||
floppyNavigation.navigateToLogin((loginPath) => {
|
||||
navigate(loginPath, { replace: true });
|
||||
});
|
||||
if (floppyNavigation.shouldProcessLinkClick(evt)) {
|
||||
evt.preventDefault();
|
||||
floppyNavigation.navigateToLogin((loginPath) => {
|
||||
navigate(loginPath, { replace: true });
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -13,6 +13,7 @@ import {
|
|||
reopenQuestion,
|
||||
} from '@/services';
|
||||
import { tryNormalLogged } from '@/utils/guard';
|
||||
import { floppyNavigation } from '@/utils';
|
||||
|
||||
interface IProps {
|
||||
type: 'answer' | 'question';
|
||||
|
@ -109,6 +110,9 @@ const Index: FC<IProps> = ({
|
|||
}
|
||||
};
|
||||
const handleEdit = (evt, targetUrl) => {
|
||||
if (!floppyNavigation.shouldProcessLinkClick(evt)) {
|
||||
return;
|
||||
}
|
||||
evt.preventDefault();
|
||||
let checkObjectId = qid;
|
||||
if (type === 'answer') {
|
||||
|
|
|
@ -3,7 +3,7 @@ import { Pagination } from 'react-bootstrap';
|
|||
import { useTranslation } from 'react-i18next';
|
||||
import { useSearchParams, useNavigate, useLocation } from 'react-router-dom';
|
||||
|
||||
import { scrollToDocTop } from '@/utils';
|
||||
import { scrollToDocTop, floppyNavigation } from '@/utils';
|
||||
|
||||
interface Props {
|
||||
currentPage: number;
|
||||
|
@ -48,10 +48,12 @@ const PageItem = ({ page, currentPage, path }: PageItemProps) => {
|
|||
active={currentPage === page}
|
||||
href={path}
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
navigate(path);
|
||||
scrollToDocTop();
|
||||
if (floppyNavigation.shouldProcessLinkClick(e)) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
navigate(path);
|
||||
scrollToDocTop();
|
||||
}
|
||||
}}>
|
||||
{page}
|
||||
</Pagination.Item>
|
||||
|
@ -91,9 +93,11 @@ const Index: FC<Props> = ({
|
|||
<Pagination.Prev
|
||||
href={handleParams(currentPage - 1)}
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
navigate(handleParams(currentPage - 1));
|
||||
scrollToDocTop();
|
||||
if (floppyNavigation.shouldProcessLinkClick(e)) {
|
||||
e.preventDefault();
|
||||
navigate(handleParams(currentPage - 1));
|
||||
scrollToDocTop();
|
||||
}
|
||||
}}>
|
||||
{t('prev')}
|
||||
</Pagination.Prev>
|
||||
|
@ -186,9 +190,11 @@ const Index: FC<Props> = ({
|
|||
disabled={currentPage === totalPage}
|
||||
href={handleParams(currentPage + 1)}
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
navigate(handleParams(currentPage + 1));
|
||||
scrollToDocTop();
|
||||
if (floppyNavigation.shouldProcessLinkClick(e)) {
|
||||
e.preventDefault();
|
||||
navigate(handleParams(currentPage + 1));
|
||||
scrollToDocTop();
|
||||
}
|
||||
}}>
|
||||
{t('next')}
|
||||
</Pagination.Next>
|
||||
|
|
|
@ -5,6 +5,8 @@ import { useTranslation } from 'react-i18next';
|
|||
|
||||
import classNames from 'classnames';
|
||||
|
||||
import { floppyNavigation } from '@/utils';
|
||||
|
||||
interface Props {
|
||||
data;
|
||||
i18nKeyPrefix: string;
|
||||
|
@ -39,10 +41,12 @@ const Index: FC<Props> = ({
|
|||
};
|
||||
|
||||
const handleClick = (e, type) => {
|
||||
e.preventDefault();
|
||||
const str = handleParams(type);
|
||||
if (pathname) {
|
||||
navigate(`${pathname}${str}`);
|
||||
if (floppyNavigation.shouldProcessLinkClick(e)) {
|
||||
e.preventDefault();
|
||||
navigate(`${pathname}${str}`);
|
||||
}
|
||||
} else {
|
||||
setUrlSearchParams(str);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import {
|
|||
clearNotificationStatus,
|
||||
readNotification,
|
||||
} from '@/services';
|
||||
import { floppyNavigation } from '@/utils';
|
||||
|
||||
import Inbox from './components/Inbox';
|
||||
import Achievements from './components/Achievements';
|
||||
|
@ -45,6 +46,9 @@ const Notifications = () => {
|
|||
const navigate = useNavigate();
|
||||
|
||||
const handleTypeChange = (evt, val) => {
|
||||
if (!floppyNavigation.shouldProcessLinkClick(evt)) {
|
||||
return;
|
||||
}
|
||||
evt.preventDefault();
|
||||
if (type === val) {
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue