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) // Call fetch(context)
if (hasFetch) { 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)<% } %> <% if(loading) { %>if(this.$loading.increase) this.$loading.increase(loadingIncrease)<% } %>
}) })
promises.push(promise) promises.push(p)
} }
return Promise.all(promises).then(() => { return Promise.all(promises).then(() => {
@ -364,8 +368,10 @@ function fixPrepatch (to, ___) {
} }
this.setLayout(layout) this.setLayout(layout)
<% if (isDev) { %>
// Hot reloading // Hot reloading
setTimeout(() => hotReloadAPI(this), 100) setTimeout(() => hotReloadAPI(this), 100)
<% } %>
}) })
} }

View File

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

View File

@ -81,12 +81,12 @@ export default async context => {
// Resolve components // Resolve components
let Components = [] let Components = []
try { 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) { if (typeof Component !== 'function' || Component.super === Vue) {
return resolve(sanitizeComponent(Component)) return sanitizeComponent(Component)
} }
return Component().then(Component => sanitizeComponent(Component)) return Component().then(Component => sanitizeComponent(Component))
}))) }))
} catch (err) { } catch (err) {
// Throw back error to renderRoute() // Throw back error to renderRoute()
throw err throw err