fix plugins injectAs

This commit is contained in:
Pooya Parsa 2017-05-15 02:26:00 +04:30
parent cb524e0424
commit 59ece4978e
3 changed files with 5 additions and 7 deletions

View File

@ -89,7 +89,7 @@ function render (to, from, next) {
nextCalled = true
next(path)
}
let context = getContext({ to<%= (store ? ', store' : '') %>, isClient: true, next: _next.bind(this), error: this.error.bind(this) })
let context = getContext({ to<%= (store ? ', store' : '') %>, isClient: true, next: _next.bind(this), error: this.error.bind(this) }, app)
let Components = getMatchedComponents(to)
this._context = context
this._dateLastError = this.$options._nuxt.dateErr
@ -274,7 +274,7 @@ function addHotReload ($component, depth) {
<%= (loading ? 'this.$loading.finish && this.$loading.finish()' : '') %>
router.push(path)
}
let context = getContext({ route: router.currentRoute<%= (store ? ', store' : '') %>, isClient: true, next: next.bind(this), error: this.error })
let context = getContext({ route: router.currentRoute<%= (store ? ', store' : '') %>, isClient: true, next: next.bind(this), error: this.error }, app)
<%= (loading ? 'this.$loading.start && this.$loading.start()' : '') %>
callMiddleware.call(this, Components, context)
.then(() => {

View File

@ -82,10 +82,10 @@ export default context => {
// Add route to the context
context.route = router.currentRoute
// Update context
ctx = getContext(context)
ctx = getContext(context, app)
// nuxtServerInit
<% if (store) { %>
let promise = (store._actions && store._actions.nuxtServerInit ? store.dispatch('nuxtServerInit', omit(getContext(context), 'redirect', 'error')) : null)
let promise = (store._actions && store._actions.nuxtServerInit ? store.dispatch('nuxtServerInit', omit(getContext(context, app), 'redirect', 'error')) : null)
if (!promise || (!(promise instanceof Promise) && (typeof promise.then !== 'function'))) promise = Promise.resolve()
<% } else { %>
let promise = Promise.resolve()

View File

@ -1,6 +1,4 @@
'use strict'
import { app } from './index'
const noopData = () => ({})
export function applyAsyncData (Component, asyncData = {}) {
@ -38,7 +36,7 @@ export function flatMapComponents (route, fn) {
}))
}
export function getContext (context) {
export function getContext (context, app) {
let ctx = {
isServer: !!context.isServer,
isClient: !!context.isClient,