import { defineStore } from 'pinia';

export const useCounterStore = defineStore('counter', {
  state: () => {
    return { count: 1 };
  },
  // 也可以这样定义
  // state: () => ({ count: 0 })
  getters: {
    doubleCount(state) {
      return state.count * 2;
    },
    doublePlusOne(): number {
      return this.doubleCount + 1;
    },
  },
  actions: {
    increment() {
      this.count++;
    },
  },
});
