feat: 提供getHistory获取history

This commit is contained in:
wanchun 2021-03-27 23:39:16 +08:00
parent 6e27828b9f
commit 6b7dc0324a
2 changed files with 12 additions and 7 deletions

View File

@ -293,7 +293,7 @@ export default function (api) {
api.addCoreExports(() => [ api.addCoreExports(() => [
{ {
specifiers: ['getRoutes', 'getRouter'], specifiers: ['getRoutes', 'getRouter', 'getHistory'],
source: absCoreFilePath source: absCoreFilePath
} }
]); ]);

View File

@ -15,14 +15,15 @@ export function getRoutes() {
const ROUTER_BASE = '{{{ routerBase }}}'; const ROUTER_BASE = '{{{ routerBase }}}';
let router = null; let router = null;
let history = null;
export const createRouter = () => { export const createRouter = () => {
if (router) { if (router) {
return router; return router;
} }
const history = {{{ CREATE_HISTORY }}}(ROUTER_BASE) history = {{{ CREATE_HISTORY }}}(ROUTER_BASE)
router = createVueRouter({ router = createVueRouter({
history, history,
routes: getRoutes() routes: getRoutes()
}); });
plugin.applyPlugins({ plugin.applyPlugins({
@ -37,3 +38,7 @@ export const createRouter = () => {
export const getRouter = ()=>{ export const getRouter = ()=>{
return router; return router;
} }
export const getHistory = ()=>{
return history;
}