Merge pull request #61 from WeBankFinTech/patchRoutes

fix: patchRoutes 重复调用问题
This commit is contained in:
harrywan 2021-05-26 10:12:36 +08:00 committed by GitHub
commit be7c534e24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 5 deletions

View File

@ -31,7 +31,7 @@ const renderClient = (opts = {}) => {
plugin.applyPlugins({
key: 'onAppCreated',
type: ApplyPluginsType.event,
args: { app },
args: { app, routes },
});
if (rootElement) {

View File

@ -16,7 +16,7 @@ export function getRoutes() {
const ROUTER_BASE = '{{{ routerBase }}}';
let router = null;
let history = null;
export const createRouter = () => {
export const createRouter = (routes) => {
if (router) {
return router;
}
@ -27,7 +27,7 @@ export const createRouter = () => {
});
router = createVueRouter({
history,
routes: getRoutes()
routes
});
plugin.applyPlugins({

View File

@ -1,6 +1,6 @@
import { createRouter } from "./routes";
export function onAppCreated({ app }) {
const router = createRouter();
export function onAppCreated({ app, routes }) {
const router = createRouter(routes);
app.use(router);
}

View File

@ -12,3 +12,7 @@ export const request = {
}
}
};
export function patchRoutes() {
console.log('patchRoutes');
}