mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
* Refactor store registration to use SSR methods across multiple plugins for improved state management * fix database file field drag and drop * fix storybook dependencies warning. * refactor: Replace `useAsyncData` with a direct `watch` and `renderMarkdown` function for markdown content. * fix workspace hydratation warning * replace direct `role.isBillable` access with `roleIsBillable` computed property * fix auth settings form * fix alert slot usage * please linter * please prettier * fix SSR rendering * refactor: simplify relay state URL generation by directly passing the user source object. * refactor: Replace `registerModuleSSR` with `registerModuleNuxtSafe` for Vuex module registration across all plugins. * please linter * fix: add retry logic for Firefox NS_BINDING_ABORTED navigation errors in E2E tests * test: reload page and assert link visibility using getByRole after setting parameters. * refactor: simplify `goto` navigation by removing retry logic and adding a fixed delay. * refactor: trigger initial markdown rendering via immediate watcher option * update snapshots
39 lines
1.4 KiB
JavaScript
39 lines
1.4 KiB
JavaScript
/**
|
|
* Plugin to serialize/deserialize Vuex state for SSR hydration
|
|
* This ensures that the Vuex store state is transferred from server to client
|
|
*/
|
|
export default defineNuxtPlugin({
|
|
name: 'vuex-state',
|
|
dependsOn: ['create-store'],
|
|
setup(nuxtApp) {
|
|
const store = nuxtApp.$store
|
|
|
|
// Server-side: Serialize Vuex state to payload after render
|
|
if (import.meta.server) {
|
|
nuxtApp.hook('app:rendered', () => {
|
|
nuxtApp.payload.vuex = store.state
|
|
})
|
|
}
|
|
|
|
// Client-side: Restore Vuex state from payload SYNCHRONOUSLY
|
|
// This must happen during plugin setup, not in a hook, because
|
|
// middleware runs before hooks complete and needs access to the
|
|
// hydrated state (e.g., settings.isLoaded, auth.isAuthenticated)
|
|
if (import.meta.client && nuxtApp.payload.vuex) {
|
|
store.replaceState(nuxtApp.payload.vuex)
|
|
}
|
|
|
|
// Add helper method for registering modules with proper SSR hydration
|
|
// On client after hydration, use preserveState to keep the hydrated state
|
|
// and avoid "[vuex] state field was overridden" warnings
|
|
store.registerModuleNuxtSafe = (path, module, options = {}) => {
|
|
const shouldPreserveState =
|
|
import.meta.client && nuxtApp.payload.vuex !== undefined
|
|
store.registerModule(path, module, {
|
|
...options,
|
|
preserveState: shouldPreserveState || options.preserveState,
|
|
})
|
|
}
|
|
},
|
|
})
|