mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
feat: improve app, fetch and support vuex5
Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>
This commit is contained in:
parent
ba32279d04
commit
5a7f5164f0
@ -96,8 +96,11 @@ export default class SSRRenderer extends BaseRenderer {
|
|||||||
// Call Vue renderer renderToString
|
// Call Vue renderer renderToString
|
||||||
let APP = await this.vueRenderer.renderToString(renderContext)
|
let APP = await this.vueRenderer.renderToString(renderContext)
|
||||||
|
|
||||||
|
// Call render:done in app
|
||||||
|
await renderContext.nuxt.hooks.callHook('vue-renderer:done')
|
||||||
|
|
||||||
if (typeof getSSRLog === 'function') {
|
if (typeof getSSRLog === 'function') {
|
||||||
renderContext.nuxt.logs = getSSRLog()
|
renderContext.payload.logs = getSSRLog()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call ssr:context hook
|
// Call ssr:context hook
|
||||||
@ -107,7 +110,7 @@ export default class SSRRenderer extends BaseRenderer {
|
|||||||
await this.serverContext.nuxt.callHook('_render:context', renderContext.nuxt)
|
await this.serverContext.nuxt.callHook('_render:context', renderContext.nuxt)
|
||||||
|
|
||||||
// Fallback to empty response
|
// Fallback to empty response
|
||||||
if (!renderContext.nuxt.serverRendered) {
|
if (!renderContext.payload.serverRendered) {
|
||||||
APP = `<div id="${this.serverContext.globals.id}"></div>`
|
APP = `<div id="${this.serverContext.globals.id}"></div>`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,7 +118,7 @@ export default class SSRRenderer extends BaseRenderer {
|
|||||||
if (renderContext.redirected && renderContext.target === TARGETS.server) {
|
if (renderContext.redirected && renderContext.target === TARGETS.server) {
|
||||||
return {
|
return {
|
||||||
html: APP,
|
html: APP,
|
||||||
error: renderContext.nuxt.error,
|
error: renderContext.payload.error,
|
||||||
redirected: renderContext.redirected
|
redirected: renderContext.redirected
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,7 +128,7 @@ export default class SSRRenderer extends BaseRenderer {
|
|||||||
// Inject head meta
|
// Inject head meta
|
||||||
// (this is unset when features.meta is false in server template)
|
// (this is unset when features.meta is false in server template)
|
||||||
const meta = renderContext.meta && renderContext.meta.inject({
|
const meta = renderContext.meta && renderContext.meta.inject({
|
||||||
isSSR: renderContext.nuxt.serverRendered,
|
isSSR: renderContext.payload.serverRendered,
|
||||||
ln: this.options.dev
|
ln: this.options.dev
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -224,7 +227,7 @@ export default class SSRRenderer extends BaseRenderer {
|
|||||||
let serializedSession
|
let serializedSession
|
||||||
if (shouldInjectScripts || shouldHashCspScriptSrc) {
|
if (shouldInjectScripts || shouldHashCspScriptSrc) {
|
||||||
// Only serialized session if need inject scripts or csp hash
|
// Only serialized session if need inject scripts or csp hash
|
||||||
serializedSession = `window.${this.serverContext.globals.context}=${devalue(renderContext.nuxt)};`
|
serializedSession = `window.${this.serverContext.globals.context}=${devalue(renderContext.payload)};`
|
||||||
inlineScripts.push(serializedSession)
|
inlineScripts.push(serializedSession)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,7 +274,7 @@ export default class SSRRenderer extends BaseRenderer {
|
|||||||
|
|
||||||
// Template params
|
// Template params
|
||||||
const templateParams = {
|
const templateParams = {
|
||||||
HTML_ATTRS: meta ? meta.htmlAttrs.text(renderContext.nuxt.serverRendered /* addSrrAttribute */) : '',
|
HTML_ATTRS: meta ? meta.htmlAttrs.text(renderContext.payload.serverRendered /* addSrrAttribute */) : '',
|
||||||
HEAD_ATTRS: meta ? meta.headAttrs.text() : '',
|
HEAD_ATTRS: meta ? meta.headAttrs.text() : '',
|
||||||
BODY_ATTRS: meta ? meta.bodyAttrs.text() : '',
|
BODY_ATTRS: meta ? meta.bodyAttrs.text() : '',
|
||||||
HEAD,
|
HEAD,
|
||||||
|
Loading…
Reference in New Issue
Block a user