Skip to content

Commit

Permalink
refactor: install
Browse files Browse the repository at this point in the history
  • Loading branch information
iodsfx3d committed Jan 30, 2020
1 parent 25ab209 commit f7fd2d2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const install: Install<Router | PluginOptions> = (
const app: any = {}
let router: Router
let globalMiddlewares: Middleware[] = []
let context: RouteContext = { app }
let context: RouteContext = { app: vue }

if (options && (options as PluginOptions).router) {
// if options object
Expand Down Expand Up @@ -97,17 +97,17 @@ export const install: Install<Router | PluginOptions> = (
router.beforeEach(routeHook)

// ==== helpers ============
app.$MiddlewarePlugin = true
app.$getMiddlewareContext = () => {
vue.$MiddlewarePlugin = true
vue.$getMiddlewareContext = () => {
const { app, ..._context } = context
return _context
}
app.$setMiddlewareContext = (_context: any): any => {
vue.$setMiddlewareContext = (_context: any): any => {
const { app, to, from, redirect } = context
context = { ..._context, app, to, from, redirect }
return context
}
app.$updateMiddlewareContext = (key: string, value: any) => {
vue.$updateMiddlewareContext = (key: string, value: any) => {
const { app, to, from, redirect } = context
context = { [key]: value, app, to, from, redirect }
}
Expand Down

0 comments on commit f7fd2d2

Please sign in to comment.