@@ -142,11 +142,15 @@ export default function (viteCompilerContext: ViteH5CompilerContext): PluginOpti
142
142
} )
143
143
const [ , pxtransformOption ] = __postcssOption . find ( ( [ name ] ) => name === 'postcss-pxtransform' ) || [ ]
144
144
const pxTransformConfig = pxtransformOption ?. config || { }
145
+ const routerMode = appConfig ?. router ?. mode || 'hash'
146
+ const historyCreator = routerMode === 'browser' ? 'createBrowserHistory' : routerMode === 'multi' ? 'createMpaHistory' : 'createHashHistory'
147
+ const appMountHandler = appConfig . tabBar ? 'handleAppMountWithTabbar' : 'handleAppMount'
148
+
145
149
146
150
return [
147
151
setReconciler ,
148
152
'import { initPxTransform } from "@tarojs/taro"' ,
149
- `import { ${ routerCreator } } from "@tarojs/router"` ,
153
+ `import { ${ routerCreator } , ${ historyCreator } , ${ appMountHandler } } from "@tarojs/router"` ,
150
154
`import component from "${ app . scriptPath } "` ,
151
155
'import { window } from "@tarojs/runtime"' ,
152
156
`import { ${ creator } } from "${ creatorLocation } "` ,
@@ -158,7 +162,9 @@ export default function (viteCompilerContext: ViteH5CompilerContext): PluginOpti
158
162
routesConfig ,
159
163
execBeforeCreateWebApp || '' ,
160
164
`var inst = ${ creator } (component, ${ frameworkArgs } )` ,
161
- `${ routerCreator } (inst, config, ${ importFrameworkName } )` ,
165
+ `var history = ${ historyCreator } ({ window })` ,
166
+ `${ appMountHandler } (config, history)` ,
167
+ `${ routerCreator } (history, inst, config, ${ importFrameworkName } )` ,
162
168
'initPxTransform({' ,
163
169
` designWidth: ${ pxTransformConfig . designWidth } ,` ,
164
170
` deviceRatio: ${ JSON . stringify ( pxTransformConfig . deviceRatio ) } ,` ,
0 commit comments