diff --git a/packages/create-app-shared/CHANGELOG.md b/packages/create-app-shared/CHANGELOG.md index 8cde1a39d1..d70920972c 100644 --- a/packages/create-app-shared/CHANGELOG.md +++ b/packages/create-app-shared/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.2.5 + +- [feat] be able to pass arguments to memory router + ## 1.2.4 - [fix] support history for custom configuration diff --git a/packages/create-app-shared/package.json b/packages/create-app-shared/package.json index fb2908ac65..b3e4114255 100644 --- a/packages/create-app-shared/package.json +++ b/packages/create-app-shared/package.json @@ -1,6 +1,6 @@ { "name": "create-app-shared", - "version": "1.2.4", + "version": "1.2.5", "description": "", "author": "ice-admin@alibaba-inc.com", "homepage": "https://github.com/alibaba/ice#readme", diff --git a/packages/create-app-shared/src/createInitHistory.ts b/packages/create-app-shared/src/createInitHistory.ts index 1d3121d58d..4952250dc5 100644 --- a/packages/create-app-shared/src/createInitHistory.ts +++ b/packages/create-app-shared/src/createInitHistory.ts @@ -14,6 +14,8 @@ export type CreateHistory = (options: { location?: Location; routes?: Route[]; customHistory?: History; + initialIndex?: number; + initialEntries?: string[]; }) => History type InitialContext = null | { location?: Location } type Options = { @@ -32,8 +34,16 @@ export default (createHistory: CreateHistory) => } const { initialContext = null, staticConfig = { routes: [] } } = options; const { router } = appConfig; - const { type = DEFAULT_APP_CONFIG.router.type, basename, history: customHistory } = router; + const { type = DEFAULT_APP_CONFIG.router.type, basename, history: customHistory, initialEntries, initialIndex } = router; const location = initialContext ? initialContext.location : null; - const newHistory = createHistory({ type, basename, location, customHistory, routes: staticConfig.routes }); + const newHistory = createHistory({ + type, + basename, + location, + customHistory, + routes: staticConfig.routes, + initialEntries, + initialIndex + }); appConfig.router.history = newHistory; }; diff --git a/packages/create-app-shared/src/types.ts b/packages/create-app-shared/src/types.ts index 2287caf60c..9e7fcd7d1f 100644 --- a/packages/create-app-shared/src/types.ts +++ b/packages/create-app-shared/src/types.ts @@ -21,6 +21,8 @@ export interface AppConfig { type?: 'hash' | 'browser' | 'memory' | 'static'; history?: History; basename?: string; + initialIndex?: number; + initialEntries?: string[]; }, } diff --git a/packages/create-app-shared/src/web/history.ts b/packages/create-app-shared/src/web/history.ts index cf4575490e..2aa1a9693c 100644 --- a/packages/create-app-shared/src/web/history.ts +++ b/packages/create-app-shared/src/web/history.ts @@ -3,7 +3,14 @@ import type { CreateHistory, InitHistory } from '../createInitHistory'; import createInitHistory from '../createInitHistory'; import { setHistory } from '../storage'; -const createHistory: CreateHistory = ({ type, basename, location, customHistory }) => { +const createHistory: CreateHistory = ({ + type, + basename, + location, + customHistory, + initialIndex, + initialEntries, +}) => { let history: History; if (process.env.__IS_SERVER__) { history = createMemoryHistory(); @@ -16,7 +23,10 @@ const createHistory: CreateHistory = ({ type, basename, location, customHistory } else if (type === 'browser') { history = createBrowserHistory({ basename }); } else { - history = createMemoryHistory(); + history = createMemoryHistory({ + initialIndex, + initialEntries + }); } setHistory(history); return history; diff --git a/packages/icejs/package.json b/packages/icejs/package.json index 5fed2bc9a3..c729f97439 100644 --- a/packages/icejs/package.json +++ b/packages/icejs/package.json @@ -1,6 +1,6 @@ { "name": "ice.js", - "version": "2.6.1", + "version": "2.6.2", "description": "command line interface and builtin plugin for icejs", "author": "ice-admin@alibaba-inc.com", "homepage": "", @@ -31,7 +31,7 @@ "build-plugin-ice-logger": "2.0.0", "build-plugin-ice-mpa": "2.1.1", "build-plugin-ice-request": "2.0.0", - "build-plugin-ice-router": "2.1.2", + "build-plugin-ice-router": "2.1.3", "build-plugin-ice-ssr": "3.1.1", "build-plugin-ice-store": "2.0.7", "build-plugin-react-app": "2.2.1", diff --git a/packages/plugin-icestark/CHANGELOG.md b/packages/plugin-icestark/CHANGELOG.md index 4d89a35fe2..2f41968d17 100644 --- a/packages/plugin-icestark/CHANGELOG.md +++ b/packages/plugin-icestark/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 2.5.3 + +- [fix] revert from version 2.5.2 and suport memory router + ## 2.5.2 - [fix] support custom history configuration. diff --git a/packages/plugin-icestark/package.json b/packages/plugin-icestark/package.json index b4d212bb7e..990ed85bb4 100644 --- a/packages/plugin-icestark/package.json +++ b/packages/plugin-icestark/package.json @@ -1,6 +1,6 @@ { "name": "build-plugin-icestark", - "version": "2.5.2", + "version": "2.5.3", "description": "Easy use `icestark` in icejs.", "author": "ice-admin@alibaba-inc.com", "homepage": "", diff --git a/packages/plugin-icestark/src/runtime.tsx b/packages/plugin-icestark/src/runtime.tsx index 2526798f56..ee91c7df06 100644 --- a/packages/plugin-icestark/src/runtime.tsx +++ b/packages/plugin-icestark/src/runtime.tsx @@ -37,7 +37,14 @@ const module = ({ getApps, $$props } = (icestark || {}) as IPrivateIceStark; - const { type, basename, modifyRoutes: runtimeModifyRoutes, fallback, history: customHistory } = router; + const { + type, + basename, + modifyRoutes: runtimeModifyRoutes, + fallback, + initialIndex, + initialEntries, + } = router; // compatible with deprecated runtime API const wrapperComponent = wrapperPageComponent || wrapperRouteComponent; const createAppHistory = createHistory || ((options: any) => applyRuntimeAPI('createHistory', options)); @@ -54,7 +61,7 @@ const module = ({ const childBasename = isInIcestark() ? getBasename() : basename; - const history = createAppHistory({ type, basename: childBasename, customHistory }); + const history = createAppHistory({ type, basename: childBasename, initialIndex, initialEntries }); addDOMRender(({ App, appMountNode }) => { return new Promise(resolve => { @@ -136,7 +143,7 @@ const module = ({ modifyRoutes(removeRootLayout); } const RootApp = ({ routes }) => { - const [routerHistory] = useState(createAppHistory({ type, basename, customHistory })); + const [routerHistory] = useState(createAppHistory({ type, basename, initialEntries, initialIndex })); const routerProps = { type, routes, diff --git a/packages/plugin-router/CHANGELOG.md b/packages/plugin-router/CHANGELOG.md index 59bf5daad1..a990081751 100644 --- a/packages/plugin-router/CHANGELOG.md +++ b/packages/plugin-router/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 2.1.3 + +- [fix] be able to pass arguments to memory router + ## 2.1.2 - [fix] bump version of `@builder/pack`(^0.6.0) diff --git a/packages/plugin-router/package.json b/packages/plugin-router/package.json index f977e9f20e..009c183970 100644 --- a/packages/plugin-router/package.json +++ b/packages/plugin-router/package.json @@ -1,6 +1,6 @@ { "name": "build-plugin-ice-router", - "version": "2.1.2", + "version": "2.1.3", "description": "build-plugin-ice-router", "author": "ice-admin@alibaba-inc.com", "homepage": "", diff --git a/packages/plugin-router/src/runtime.tsx b/packages/plugin-router/src/runtime.tsx index 1c0cce279f..8e0aa02b5b 100644 --- a/packages/plugin-router/src/runtime.tsx +++ b/packages/plugin-router/src/runtime.tsx @@ -28,7 +28,12 @@ const module = ({ setRenderApp, appConfig, modifyRoutes, modifyRoutesComponent, ...customRouterProps, }; if (!routerProps.history) { - routerProps.history = applyRuntimeAPI('createHistory', { type: appConfigRouter.type, basename: appConfigRouter.basename }); + routerProps.history = applyRuntimeAPI('createHistory', { + type: appConfigRouter.type, + basename: appConfigRouter.basename, + initialIndex: appConfigRouter.initialIndex, + initialEntries: appConfigRouter.initialEntries + }); } if (process.env.__IS_SERVER__) { const { initialContext = {} } = context; diff --git a/packages/plugin-router/src/types/index.ts b/packages/plugin-router/src/types/index.ts index 390b4a1ad1..74275f90bb 100644 --- a/packages/plugin-router/src/types/index.ts +++ b/packages/plugin-router/src/types/index.ts @@ -12,6 +12,8 @@ export interface IAppRouterProps { modifyRoutes?: IModifyRoutes; fallback?: React.ReactNode; history?: History; + initialIndex?: number; + initialEntries?: string[]; } export interface IRouterConfig extends DefaultRouteProps {