mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
This commit is contained in:
parent
44471ec9df
commit
fe0498cecd
@ -1,4 +1,5 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
<% if (store) { %>import Vuex from 'vuex'<% } %>
|
||||||
<% if (features.meta) { %>import Meta from 'vue-meta'<% } %>
|
<% if (features.meta) { %>import Meta from 'vue-meta'<% } %>
|
||||||
<% if (features.componentClientOnly) { %>import ClientOnly from 'vue-client-only'<% } %>
|
<% if (features.componentClientOnly) { %>import ClientOnly from 'vue-client-only'<% } %>
|
||||||
<% if (features.deprecations) { %>import NoSsr from 'vue-no-ssr'<% } %>
|
<% if (features.deprecations) { %>import NoSsr from 'vue-no-ssr'<% } %>
|
||||||
@ -66,6 +67,15 @@ const defaultTransition = <%=
|
|||||||
%><%= isTest ? '// eslint-disable-line' : '' %>
|
%><%= isTest ? '// eslint-disable-line' : '' %>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
|
<% if (store) { %>
|
||||||
|
const originalRegisterModule = Vuex.Store.prototype.registerModule
|
||||||
|
const baseStoreOptions = { preserveState: process.client }
|
||||||
|
|
||||||
|
function registerModule (path, rawModule, options = {}) {
|
||||||
|
return originalRegisterModule.call(this, path, rawModule, { ...baseStoreOptions, ...options })
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
async function createApp(ssrContext, config = {}) {
|
async function createApp(ssrContext, config = {}) {
|
||||||
const router = await createRouter(ssrContext)
|
const router = await createRouter(ssrContext)
|
||||||
|
|
||||||
@ -75,8 +85,7 @@ async function createApp(ssrContext, config = {}) {
|
|||||||
store.$router = router
|
store.$router = router
|
||||||
<% if (mode === 'universal') { %>
|
<% if (mode === 'universal') { %>
|
||||||
// Fix SSR caveat https://github.com/nuxt/nuxt.js/issues/3757#issuecomment-414689141
|
// Fix SSR caveat https://github.com/nuxt/nuxt.js/issues/3757#issuecomment-414689141
|
||||||
const registerModule = store.registerModule
|
store.registerModule = registerModule
|
||||||
store.registerModule = (path, rawModule, options) => registerModule.call(store, path, rawModule, Object.assign({ preserveState: process.client }, options))
|
|
||||||
<% } %>
|
<% } %>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user