fix: Dark mode bug, pinia store reset across Vite entry points (#7851)

This commit is contained in:
Matthew Holloway 2024-08-24 10:50:31 +12:00 committed by GitHub
parent d3fe1c0008
commit af21347b67
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 4 deletions

View file

@ -1,11 +1,11 @@
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import piniaPersist from 'pinia-plugin-persist'
import Embedded from './Embedded.vue'
import { createPiniaSingleton } from './shared/create-pinia-singleton'
// Initialize store (Pinia)
const pinia = createPinia()
const pinia = createPiniaSingleton()
pinia.use(piniaPersist)
// Mount App

View file

@ -1,14 +1,14 @@
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import piniaPersist from 'pinia-plugin-persist'
import App from './App.vue'
import router from './router'
import { createPiniaSingleton } from './shared/create-pinia-singleton'
const app = createApp(App, {})
// Initialize store (Pinia)
const pinia = createPinia()
const pinia = createPiniaSingleton()
pinia.use(piniaPersist)
app.use(pinia)

View file

@ -0,0 +1,6 @@
import { createPinia } from 'pinia'
export function createPiniaSingleton(){
window.pinia = window.pinia ?? createPinia()
return window.pinia
}