From ee71681505e620ed9b0025cda434c9df1554c1c0 Mon Sep 17 00:00:00 2001 From: winixt Date: Tue, 25 May 2021 22:21:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20patchRoutes=20=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fes-preset-built-in/src/plugins/generateFiles/fes/fes.tpl | 2 +- .../src/plugins/misc/route/template/routes.tpl | 4 ++-- .../src/plugins/misc/route/template/runtime.tpl | 4 ++-- packages/fes-template-h5/src/app.js | 4 ++++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/fes-preset-built-in/src/plugins/generateFiles/fes/fes.tpl b/packages/fes-preset-built-in/src/plugins/generateFiles/fes/fes.tpl index a4d45f41..a2ecd1d9 100644 --- a/packages/fes-preset-built-in/src/plugins/generateFiles/fes/fes.tpl +++ b/packages/fes-preset-built-in/src/plugins/generateFiles/fes/fes.tpl @@ -31,7 +31,7 @@ const renderClient = (opts = {}) => { plugin.applyPlugins({ key: 'onAppCreated', type: ApplyPluginsType.event, - args: { app }, + args: { app, routes }, }); if (rootElement) { diff --git a/packages/fes-preset-built-in/src/plugins/misc/route/template/routes.tpl b/packages/fes-preset-built-in/src/plugins/misc/route/template/routes.tpl index 3e134cd6..55fddff5 100644 --- a/packages/fes-preset-built-in/src/plugins/misc/route/template/routes.tpl +++ b/packages/fes-preset-built-in/src/plugins/misc/route/template/routes.tpl @@ -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({ diff --git a/packages/fes-preset-built-in/src/plugins/misc/route/template/runtime.tpl b/packages/fes-preset-built-in/src/plugins/misc/route/template/runtime.tpl index 3c40ee5d..7d05be90 100644 --- a/packages/fes-preset-built-in/src/plugins/misc/route/template/runtime.tpl +++ b/packages/fes-preset-built-in/src/plugins/misc/route/template/runtime.tpl @@ -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); } diff --git a/packages/fes-template-h5/src/app.js b/packages/fes-template-h5/src/app.js index 9da182a1..8d70d71f 100644 --- a/packages/fes-template-h5/src/app.js +++ b/packages/fes-template-h5/src/app.js @@ -12,3 +12,7 @@ export const request = { } } }; + +export function patchRoutes() { + console.log('patchRoutes'); +}