Skip to content

Commit

Permalink
feat: auto redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
ybgbob committed Nov 21, 2023
1 parent 013b345 commit 9a7ec36
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
35 changes: 19 additions & 16 deletions src/pages/R.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ export const R = () => {

const { handleModalOpen } = useWalletModal();

console.log(
'status',
accountStatus,
resourceBid,
resourceOid,
detailBid,
detailOid,
);
// console.log(
// 'status',
// accountStatus,
// resourceBid,
// resourceOid,
// detailBid,
// detailOid,
// );

const bucketIsListed = useMemo(() => {
return !_.isEmpty(resourceBid);
Expand All @@ -52,7 +52,6 @@ export const R = () => {
} else {
if (!_.isEmpty(detailBid)) {
if (detailBid.bucketInfo && !detailOid?.objectInfo) {
console.log('xx', bucketIsListed);
url = `/detail?bid=${detailBid.bucketInfo.id}`;

if (!bucketIsListed) {
Expand All @@ -68,10 +67,13 @@ export const R = () => {
}
}

navigator(url, {
replace: true,
});
console.log('url', url);
if (url) {
navigator(url, {
replace: true,
});
return;
}
// console.log('url', url);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [
detailBid?.bucketInfo.id,
Expand All @@ -83,7 +85,7 @@ export const R = () => {
useEffect(() => {
if (accountStatus === 'NOT_LOGIN') {
handleModalOpen();
return;
// return;
}
if (accountStatus === 'ACCOUNT_IS_NOT_SAME') {
NiceModal.show(Tips, {
Expand All @@ -92,7 +94,7 @@ export const R = () => {
<SwitchCorrectAccount>{trimLongStr(account)}</SwitchCorrectAccount>
),
});
return;
// return;
}

if (accountStatus === 'SAME_ACCOUNT') {
Expand All @@ -103,8 +105,9 @@ export const R = () => {
});
} else {
// ...
// alert(1);
}
return;
// return;
}
}, [account, accountStatus]);

Expand Down
18 changes: 9 additions & 9 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { useLocation } from 'react-router-dom';
import { useGlobal } from '../hooks/useGlobal';

const Route = ({ children }: any) => {
const location = useLocation();
const state = useGlobal();
useEffect(() => {
if (['/resource', '/folder'].indexOf(location.pathname) < 0) {
state.globalDispatch({
type: 'RESET',
});
}
}, [location]);
// const location = useLocation();
// const state = useGlobal();
// useEffect(() => {
// if (['/resource', '/folder'].indexOf(location.pathname) < 0) {
// state.globalDispatch({
// type: 'RESET',
// });
// }
// }, [location]);

return children;
};
Expand Down

0 comments on commit 9a7ec36

Please sign in to comment.