mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix(nuxt): manually assign payload reactivity when ssr: false
(#27542)
This commit is contained in:
parent
bdf8f9e0dd
commit
b17aa3f08e
@ -3,6 +3,7 @@ import { parse } from 'devalue'
|
||||
import { useHead } from '@unhead/vue'
|
||||
import { getCurrentInstance, onServerPrefetch } from 'vue'
|
||||
import { useNuxtApp, useRuntimeConfig } from '../nuxt'
|
||||
import type { NuxtPayload } from '../nuxt'
|
||||
|
||||
import { useRoute } from './router'
|
||||
import { getAppManifest, getRouteRules } from './manifest'
|
||||
@ -95,11 +96,12 @@ export async function isPrerendered (url = useRoute().path) {
|
||||
return !!rules.prerender && !rules.redirect
|
||||
}
|
||||
|
||||
let payloadCache: any = null
|
||||
let payloadCache: NuxtPayload | null = null
|
||||
|
||||
/** @since 3.4.0 */
|
||||
export async function getNuxtClientPayload () {
|
||||
if (import.meta.server) {
|
||||
return
|
||||
return null
|
||||
}
|
||||
if (payloadCache) {
|
||||
return payloadCache
|
||||
@ -107,7 +109,7 @@ export async function getNuxtClientPayload () {
|
||||
|
||||
const el = document.getElementById('__NUXT_DATA__')
|
||||
if (!el) {
|
||||
return {}
|
||||
return {} as Partial<NuxtPayload>
|
||||
}
|
||||
|
||||
const inlineData = await parsePayload(el.textContent || '')
|
||||
|
@ -69,7 +69,7 @@ export interface NuxtSSRContext extends SSRContext {
|
||||
/** whether we are rendering an SSR error */
|
||||
error?: boolean
|
||||
nuxt: _NuxtApp
|
||||
payload: NuxtPayload
|
||||
payload: Partial<NuxtPayload>
|
||||
head: VueHeadClient<MergeHead>
|
||||
/** This is used solely to render runtime config with SPA renderer. */
|
||||
config?: Pick<RuntimeConfig, 'public' | 'app'>
|
||||
|
@ -165,11 +165,7 @@ const getSPARenderer = lazyCachedFunction(async () => {
|
||||
const config = useRuntimeConfig(ssrContext.event)
|
||||
ssrContext.modules = ssrContext.modules || new Set<string>()
|
||||
ssrContext!.payload = {
|
||||
_errors: {},
|
||||
serverRendered: false,
|
||||
data: {},
|
||||
state: {},
|
||||
once: new Set<string>(),
|
||||
}
|
||||
ssrContext.config = {
|
||||
public: config.public,
|
||||
|
Loading…
Reference in New Issue
Block a user