mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 22:25:12 +00:00
update server.js
This commit is contained in:
parent
85825d190c
commit
db2a5ef75a
@ -49,8 +49,10 @@ export default async context => {
|
|||||||
const { app, router<%= (store ? ', store' : '') %> } = await createApp(context)
|
const { app, router<%= (store ? ', store' : '') %> } = await createApp(context)
|
||||||
const _app = new Vue(app)
|
const _app = new Vue(app)
|
||||||
|
|
||||||
|
<% if (store) { %>
|
||||||
// Add store to the context
|
// Add store to the context
|
||||||
<%= (store ? 'context.store = store' : '') %>
|
context.store = store
|
||||||
|
<% } %>
|
||||||
|
|
||||||
// Add route to the context
|
// Add route to the context
|
||||||
context.route = router.currentRoute
|
context.route = router.currentRoute
|
||||||
@ -91,12 +93,14 @@ export default async context => {
|
|||||||
throw err
|
throw err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dispatch nuxtServerInit
|
<% if (store) { %>
|
||||||
|
// Dispatch store nuxtServerInit
|
||||||
if (store._actions && store._actions.nuxtServerInit) {
|
if (store._actions && store._actions.nuxtServerInit) {
|
||||||
await store.dispatch('nuxtServerInit', ctx)
|
await store.dispatch('nuxtServerInit', ctx)
|
||||||
}
|
}
|
||||||
// ...If there is a redirect
|
// ...If there is a redirect
|
||||||
if (context.redirected) return noopApp()
|
if (context.redirected) return noopApp()
|
||||||
|
<% } %>
|
||||||
|
|
||||||
// Call global middleware (nuxt.config.js)
|
// Call global middleware (nuxt.config.js)
|
||||||
let midd = <%= serialize(router.middleware, { isJSON: true }) %>
|
let midd = <%= serialize(router.middleware, { isJSON: true }) %>
|
||||||
|
Loading…
Reference in New Issue
Block a user