fix(mobile-client): fix navigate is incorrect
This commit is contained in:
parent
106f9d90f5
commit
21efc5c66c
@ -2,16 +2,21 @@ import { RouteSwitchProvider, useRouteSwitchContext } from '@nocobase/client';
|
|||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import MApplication from './Application';
|
import MApplication from './Application';
|
||||||
import { isJSBridge } from '../core/bridge';
|
import { isJSBridge } from '../core/bridge';
|
||||||
|
import { useHistory, useLocation } from 'react-router-dom';
|
||||||
|
|
||||||
export const RouterSwitchProvider = (props) => {
|
export const RouterSwitchProvider = (props) => {
|
||||||
const { routes, components } = useRouteSwitchContext();
|
const { routes, components } = useRouteSwitchContext();
|
||||||
// redirect to mobile
|
// redirect to mobile
|
||||||
|
const location = useLocation();
|
||||||
|
const history = useHistory();
|
||||||
|
useEffect(() => {
|
||||||
if (isJSBridge) {
|
if (isJSBridge) {
|
||||||
const redirectRoute = routes[0];
|
if (location.pathname.includes('/admin')) {
|
||||||
if (redirectRoute.type === 'redirect' && redirectRoute.to === '/admin') {
|
history.push('/mobile');
|
||||||
redirectRoute.to = '/mobile';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}, [history, location.pathname]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RouteSwitchProvider
|
<RouteSwitchProvider
|
||||||
routes={routes}
|
routes={routes}
|
||||||
|
Loading…
Reference in New Issue
Block a user