Skip to content

Commit

Permalink
feat(packages): add route Transition animation
Browse files Browse the repository at this point in the history
  • Loading branch information
mufeng889 committed Aug 8, 2024
1 parent 8b27596 commit da94e7c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions packages/simple-router/src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Location, RouteObject } from 'react-router-dom';
import { RouterProvider, createBrowserRouter, createHashRouter, createMemoryRouter } from 'react-router-dom';
import type { BlockerFunction, Router as RemixRouter, RouterState } from '@remix-run/router';
import type { ElegantConstRoute } from '@ohh-889/react-auto-route';
import { createContext } from 'react';
import React, { createContext } from 'react';
import type { RouteLocationNamedRaw, RouteLocationNormalizedLoaded, Router, RouterOptions } from './types';
import CreateRouterMatcher from './matcher';
import type { RouteRecordNormalized } from './matcher/types';
Expand Down Expand Up @@ -191,7 +191,7 @@ class CreateRouter {
};
}

CustomRouterProvider: () => JSX.Element = () => {
CustomRouterProvider: (loading:React.ReactNode) => JSX.Element = (loading) => {
const reactiveRoute = {} as RouteLocationNormalizedLoaded;
// eslint-disable-next-line guard-for-in
for (const key in START_LOCATION_NORMALIZED) {
Expand All @@ -206,7 +206,7 @@ class CreateRouter {
<RouterContext.Provider value={this}>
<RouteContext.Provider value={reactiveRoute}>
<RouterProvider
fallbackElement={'加载中'}
fallbackElement={loading}
router={this.reactRouter}
/>
</RouteContext.Provider>
Expand Down
2 changes: 1 addition & 1 deletion packages/simple-router/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export interface Router {
readonly reactRouter: RemixRouter;
readonly reactRoutes: RouteObject[];
addReactRoutes: (routes: ElegantConstRoute[]) => void;
CustomRouterProvider: () => JSX.Element;
CustomRouterProvider: (loading: React.ReactNode) => JSX.Element;
getRoutes: () => RouteRecordNormalized[];
getRouteByName: (name: string) => RouteRecordNormalized | undefined;
resetRoute: () => void;
Expand Down
5 changes: 2 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import MenuProvider from '@/components/common/MenuProvider.tsx';
import { router } from '@/router';
import { antdLocales } from './locales/antd';
import AppProvider from './components/common/AppProvider.tsx';
import GlobalLoading from './components/common/GlobalLoading.tsx';

const App = () => {
const locale = useAppSelector(getLocale);
Expand All @@ -28,9 +29,7 @@ const App = () => {
button={{ classNames: { icon: 'align-1px text-icon' } }}
>
<MenuProvider>
<AppProvider>
<router.CustomRouterProvider />
</AppProvider>
<AppProvider>{router.CustomRouterProvider(<GlobalLoading />)}</AppProvider>
</MenuProvider>
</ConfigProvider>
);
Expand Down

0 comments on commit da94e7c

Please sign in to comment.