Merge branch 'feat/1.0.7/ui' of github.com:answerdev/answer into feat/1.0.7/ui

This commit is contained in:
shuai 2023-03-03 17:32:49 +08:00
commit 9a410a1250
6 changed files with 44 additions and 21 deletions

View File

@ -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 (
<>

View File

@ -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(() => {

View File

@ -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') {

View File

@ -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>

View File

@ -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);
}

View File

@ -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;