mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
load pinia persistence only when on client side
This commit is contained in:
parent
89fa3f2b29
commit
8036f50bf3
@ -19,7 +19,7 @@ async function render(pageContext: PageContextServer) {
|
|||||||
throw new Error('My render() hook expects pageContext.Page to be defined')
|
throw new Error('My render() hook expects pageContext.Page to be defined')
|
||||||
}
|
}
|
||||||
|
|
||||||
const app = createApp(Page, pageProps, pageContext)
|
const app = createApp(Page, pageProps, pageContext, false)
|
||||||
|
|
||||||
const appHtml = await renderToString(app)
|
const appHtml = await renderToString(app)
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
|
||||||
import { createSSRApp, defineComponent, h } from 'vue'
|
import { createSSRApp, defineComponent, h } from 'vue'
|
||||||
|
|
||||||
import PageShell from '#components/PageShell.vue'
|
import PageShell from '#components/PageShell.vue'
|
||||||
@ -10,7 +11,12 @@ import { PageProps } from '#types/PageProps'
|
|||||||
|
|
||||||
import type { PageContext } from '#types/PageContext'
|
import type { PageContext } from '#types/PageContext'
|
||||||
|
|
||||||
function createApp(Page: Page, pageProps: PageProps | undefined, pageContext: PageContext) {
|
function createApp(
|
||||||
|
Page: Page,
|
||||||
|
pageProps: PageProps | undefined,
|
||||||
|
pageContext: PageContext,
|
||||||
|
isClient = true,
|
||||||
|
) {
|
||||||
const PageWithLayout = defineComponent({
|
const PageWithLayout = defineComponent({
|
||||||
render() {
|
render() {
|
||||||
return h(
|
return h(
|
||||||
@ -25,6 +31,10 @@ function createApp(Page: Page, pageProps: PageProps | undefined, pageContext: Pa
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if(isClient){
|
||||||
|
pinia.use(piniaPluginPersistedstate)
|
||||||
|
}
|
||||||
|
|
||||||
const app = createSSRApp(PageWithLayout)
|
const app = createSSRApp(PageWithLayout)
|
||||||
app.use(pinia)
|
app.use(pinia)
|
||||||
app.use(i18n)
|
app.use(i18n)
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
import { createPinia } from 'pinia'
|
import { createPinia } from 'pinia'
|
||||||
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
|
|
||||||
|
|
||||||
const pinia = createPinia()
|
const pinia = createPinia()
|
||||||
pinia.use(piniaPluginPersistedstate)
|
|
||||||
export default pinia
|
export default pinia
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user