chore: minor fixes

This commit is contained in:
Pooya Parsa 2017-07-10 04:27:50 +04:30
parent a9f2f299a3
commit 518692b2f4
3 changed files with 13 additions and 5 deletions

View File

@ -279,10 +279,14 @@ async function render (to, from, next) {
// Call fetch(context)
if (hasFetch) {
const promise = Component.options.fetch.call(_this, context).then(fetchResult => {
let p = Component.options.fetch.call(_this, context)
if (!p || (!(p instanceof Promise) && (typeof p.then !== 'function'))) {
p = Promise.resolve(p)
}
p.then(fetchResult => {
<% if(loading) { %>if(this.$loading.increase) this.$loading.increase(loadingIncrease)<% } %>
})
promises.push(promise)
promises.push(p)
}
return Promise.all(promises).then(() => {
@ -364,8 +368,10 @@ function fixPrepatch (to, ___) {
}
this.setLayout(layout)
<% if (isDev) { %>
// Hot reloading
setTimeout(() => hotReloadAPI(this), 100)
<% } %>
})
}

View File

@ -116,6 +116,8 @@ async function createApp (ssrContext) {
const _nuxt = this._nuxt || this.$options._nuxt
_nuxt.dateErr = Date.now()
_nuxt.err = err
console.error(err)
console.error('[nuxt] ' + err)
return err
}
},

View File

@ -81,12 +81,12 @@ export default async context => {
// Resolve components
let Components = []
try {
Components = await Promise.all(getMatchedComponents(router.match(context.url)).map((Component) => new Promise((resolve, reject) => {
Components = await Promise.all(getMatchedComponents(router.match(context.url)).map(Component => {
if (typeof Component !== 'function' || Component.super === Vue) {
return resolve(sanitizeComponent(Component))
return sanitizeComponent(Component)
}
return Component().then(Component => sanitizeComponent(Component))
})))
}))
} catch (err) {
// Throw back error to renderRoute()
throw err