diff --git a/src/composables/store.ts b/src/composables/store.ts index d32ed50..b7bd26f 100644 --- a/src/composables/store.ts +++ b/src/composables/store.ts @@ -1,3 +1,4 @@ +import { isKirby5 } from "./compatibility"; import { usePanel } from "./panel"; type PanelAppStoreState = Record; @@ -25,10 +26,7 @@ interface PanelAppStore { * @deprecated The Vuex store is removed in Kirby 5. Use the `useContent` composable instead. */ export function useStore() { - // `window.panel.app.$store` is not available in Kirby 5 - const store = (usePanel() as any).app.$store as Readonly; - - if (!store) { + if (isKirby5()) { return new Proxy({} as Readonly, { get() { throw new Error( @@ -38,5 +36,8 @@ export function useStore() { }); } + // @ts-expect-error: `window.panel.app.$store` is not available in Kirby 5 + const store = usePanel().app.$store as Readonly; + return store; }