fix: Dark mode bug, pinia store reset across Vite entry points (#7851)
This commit is contained in:
parent
d3fe1c0008
commit
af21347b67
|
@ -1,11 +1,11 @@
|
||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
import { createPinia } from 'pinia'
|
|
||||||
import piniaPersist from 'pinia-plugin-persist'
|
import piniaPersist from 'pinia-plugin-persist'
|
||||||
import Embedded from './Embedded.vue'
|
import Embedded from './Embedded.vue'
|
||||||
|
import { createPiniaSingleton } from './shared/create-pinia-singleton'
|
||||||
|
|
||||||
// Initialize store (Pinia)
|
// Initialize store (Pinia)
|
||||||
|
|
||||||
const pinia = createPinia()
|
const pinia = createPiniaSingleton()
|
||||||
pinia.use(piniaPersist)
|
pinia.use(piniaPersist)
|
||||||
|
|
||||||
// Mount App
|
// Mount App
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
import { createPinia } from 'pinia'
|
|
||||||
import piniaPersist from 'pinia-plugin-persist'
|
import piniaPersist from 'pinia-plugin-persist'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import router from './router'
|
import router from './router'
|
||||||
|
import { createPiniaSingleton } from './shared/create-pinia-singleton'
|
||||||
|
|
||||||
const app = createApp(App, {})
|
const app = createApp(App, {})
|
||||||
|
|
||||||
// Initialize store (Pinia)
|
// Initialize store (Pinia)
|
||||||
|
|
||||||
const pinia = createPinia()
|
const pinia = createPiniaSingleton()
|
||||||
pinia.use(piniaPersist)
|
pinia.use(piniaPersist)
|
||||||
app.use(pinia)
|
app.use(pinia)
|
||||||
|
|
||||||
|
|
6
client/shared/create-pinia-singleton.js
Normal file
6
client/shared/create-pinia-singleton.js
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import { createPinia } from 'pinia'
|
||||||
|
|
||||||
|
export function createPiniaSingleton(){
|
||||||
|
window.pinia = window.pinia ?? createPinia()
|
||||||
|
return window.pinia
|
||||||
|
}
|
Loading…
Reference in a new issue