index.ts 646 B

12345678910111213141516171819202122232425
  1. import { buildingType } from "@/types";
  2. import { defineStore } from "pinia";
  3. export const useVideo = defineStore("model", {
  4. // 相当于data
  5. state: () => {
  6. return {
  7. currentBuild: {} as buildingType,
  8. buildList: [] as buildingType[],
  9. isVideo: false,
  10. isVideoHome: true,
  11. isShowBGM: true,
  12. };
  13. },
  14. // 相当于计算属性
  15. getters: {},
  16. // 相当于vuex的 mutation + action,可以同时写同步和异步的代码
  17. actions: {
  18. setCurrentBuild(building: buildingType) {
  19. this.currentBuild = building;
  20. },
  21. setBuildList(list: buildingType[]) {
  22. this.buildList = list;
  23. },
  24. },
  25. });