index.ts 719 B

1234567891011121314151617181920212223242526
  1. import type { App } from "vue";
  2. import { createPinia } from "pinia";
  3. import piniaPluginPersistedstate from "pinia-plugin-persistedstate";
  4. const store = createPinia();
  5. store.use(piniaPluginPersistedstate);
  6. store.use(({ store }) => {
  7. const initialState = JSON.parse(JSON.stringify(store.$state));
  8. store.$reset = () => {
  9. store.$patch(initialState);
  10. };
  11. });
  12. // 全局注册 store
  13. export function setupStore(app: App<Element>) {
  14. app.use(store);
  15. }
  16. export * from "./modules/app";
  17. export * from "./modules/permission";
  18. export * from "./modules/settings";
  19. export * from "./modules/tagsView";
  20. export * from "./modules/user";
  21. export * from "./modules/common";
  22. export * from "./modules/dictionary";
  23. export { store };