mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-02 10:27:15 +00:00
fix(app, nitro): fix app:rendered
hook (#53)
Co-authored-by: Pooya Parsa <pyapar@gmail.com>
This commit is contained in:
parent
07e70ac35a
commit
7f97015c74
@ -13,12 +13,12 @@ async function initApp () {
|
|||||||
await applyPlugins(nuxt, plugins)
|
await applyPlugins(nuxt, plugins)
|
||||||
await applyPlugins(nuxt, clientPlugins)
|
await applyPlugins(nuxt, clientPlugins)
|
||||||
|
|
||||||
await app.$nuxt.hooks.callHook('app:created', app)
|
await nuxt.hooks.callHook('app:created', app)
|
||||||
await app.$nuxt.hooks.callHook('app:beforeMount', app)
|
await nuxt.hooks.callHook('app:beforeMount', app)
|
||||||
|
|
||||||
app.mount('#__nuxt')
|
app.mount('#__nuxt')
|
||||||
|
|
||||||
await app.$nuxt.hooks.callHook('app:mounted', app)
|
await nuxt.hooks.callHook('app:mounted', app)
|
||||||
await nextTick()
|
await nextTick()
|
||||||
nuxt.isHydrating = false
|
nuxt.isHydrating = false
|
||||||
}
|
}
|
||||||
|
@ -12,11 +12,7 @@ export default async function createNuxtAppServer (ssrContext = {}) {
|
|||||||
await applyPlugins(nuxt, plugins)
|
await applyPlugins(nuxt, plugins)
|
||||||
await applyPlugins(nuxt, serverPlugins)
|
await applyPlugins(nuxt, serverPlugins)
|
||||||
|
|
||||||
await app.$nuxt.hooks.callHook('app:created', app)
|
await nuxt.hooks.callHook('app:created', app)
|
||||||
|
|
||||||
nuxt.hooks.hook('vue-renderer:done',
|
|
||||||
() => nuxt.hooks.callHook('app:rendered', app)
|
|
||||||
)
|
|
||||||
|
|
||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,11 @@ export async function renderMiddleware (req, res) {
|
|||||||
...(req.context || {})
|
...(req.context || {})
|
||||||
}
|
}
|
||||||
const rendered = await renderer.renderToString(ssrContext)
|
const rendered = await renderer.renderToString(ssrContext)
|
||||||
|
|
||||||
|
if (ssrContext.nuxt.hooks) {
|
||||||
|
await ssrContext.nuxt.hooks.callHook('app:rendered')
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: nuxt3 should not reuse `nuxt` property for different purpose!
|
// TODO: nuxt3 should not reuse `nuxt` property for different purpose!
|
||||||
const payload = ssrContext.payload /* nuxt 3 */ || ssrContext.nuxt /* nuxt 2 */
|
const payload = ssrContext.payload /* nuxt 3 */ || ssrContext.nuxt /* nuxt 2 */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user