From 2ad6bf2a080920244d9f2162a49982a272ee3e63 Mon Sep 17 00:00:00 2001 From: Ricardo Gobbo de Souza Date: Wed, 14 Aug 2019 16:38:25 -0300 Subject: [PATCH] feat(vue-app): export router options (#6231) --- packages/vue-app/template/router.js | 30 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/packages/vue-app/template/router.js b/packages/vue-app/template/router.js index 33984c30d1..8533cb3dbf 100644 --- a/packages/vue-app/template/router.js +++ b/packages/vue-app/template/router.js @@ -84,18 +84,20 @@ const _routes = recursiveRoutes(router.routes, ' ', _components, 2) Vue.use(Router) -export function createRouter() { - return new Router({ - mode: '<%= router.mode %>', - base: decodeURI('<%= router.base %>'), - linkActiveClass: '<%= router.linkActiveClass %>', - linkExactActiveClass: '<%= router.linkExactActiveClass %>', - scrollBehavior, - <%= isTest ? '/* eslint-disable quotes, object-curly-spacing, key-spacing */' : '' %> - routes: [<%= _routes %>], - <%= isTest ? '/* eslint-enable quotes, object-curly-spacing, key-spacing */' : '' %> - <% if (router.parseQuery) { %>parseQuery: <%= serializeFunction(router.parseQuery) %>,<% } %> - <% if (router.stringifyQuery) { %>stringifyQuery: <%= serializeFunction(router.stringifyQuery) %>,<% } %> - fallback: <%= router.fallback %> - }) +export const routerOptions = { + mode: '<%= router.mode %>', + base: decodeURI('<%= router.base %>'), + linkActiveClass: '<%= router.linkActiveClass %>', + linkExactActiveClass: '<%= router.linkExactActiveClass %>', + scrollBehavior, + <%= isTest ? '/* eslint-disable quotes, object-curly-spacing, key-spacing */' : '' %> + routes: [<%= _routes %>], + <%= isTest ? '/* eslint-enable quotes, object-curly-spacing, key-spacing */' : '' %> + <% if (router.parseQuery) { %>parseQuery: <%= serializeFunction(router.parseQuery) %>,<% } %> + <% if (router.stringifyQuery) { %>stringifyQuery: <%= serializeFunction(router.stringifyQuery) %>,<% } %> + fallback: <%= router.fallback %> +} + +export function createRouter() { + return new Router(routerOptions) }