
import { defineStore } from "pinia";

export type Paragraph = {
  paragraphName: string;
  contentText: string;
};

export type Part = {
  partName: string;
  paragraphs: Paragraph[];
};

export type Exhibition = {
  id: number;
  name: string;
  parts: Part[];
};

export const useStore = defineStore("home", {
  // 相当于data
  state: () => {
    return {
      currentScene: {} as Exhibition,
      currentParagraph: {} as Paragraph,
      currentPart:{} as Part
    };
  },
  // 相当于计算属性
  getters: {},
  // 相当于vuex的 mutation + action，可以同时写同步和异步的代码
  actions: {
    setCurrentScene(currentScene: Exhibition) {
      this.currentScene = currentScene;
    },
    setCurrentParagraph(currentP: Paragraph) {
      this.currentParagraph = currentP;
    },
    setCurrentPart(currentPart: Part) {
      this.currentPart = currentPart;
    },
  },
});
