mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-06 03:59:53 +08:00
36 lines
761 B
Smarty
36 lines
761 B
Smarty
import { createRouter as createVueRouter, {{{ CREATE_HISTORY }}}, ApplyPluginsType } from '{{{ runtimePath }}}';
|
|
import { plugin } from '@@/core/coreExports';
|
|
|
|
export function getRoutes() {
|
|
const routes = {{{ routes }}};
|
|
|
|
plugin.applyPlugins({
|
|
key: 'patchRoutes',
|
|
type: ApplyPluginsType.event,
|
|
args: { routes },
|
|
});
|
|
|
|
return routes;
|
|
}
|
|
|
|
const ROUTER_BASE = '{{{ routerBase }}}';
|
|
let router = null;
|
|
export const createRouter = () => {
|
|
if (router) {
|
|
return router;
|
|
}
|
|
const history = {{{ CREATE_HISTORY }}}(ROUTER_BASE)
|
|
router = createVueRouter({
|
|
history,
|
|
routes: getRoutes()
|
|
});
|
|
|
|
plugin.applyPlugins({
|
|
key: 'onRouterCreated',
|
|
type: ApplyPluginsType.event,
|
|
args: { router },
|
|
});
|
|
|
|
return router;
|
|
};
|