Sign in

cnlive_project / cnlive-community-web-vue · Files

GitLab

  • Back to group
  • Project
  • Activity
  • Files
  • Commits
  • Network
  • Graphs
  • Milestones
  • Issues 0
  • Merge Requests 0
  • Labels
  • Wiki
  • cnlive-community-web-vue
  • src
  • pinia
  • data.ts
  • pinia store
    3095c84b
    杨泽宇 authored
    2022-01-28 12:42:20 +0800  
    Browse Code »
data.ts 439 Bytes
Edit Raw Blame History Permalink
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
import { defineStore } from 'pinia'

export const useDataStore = defineStore({
  id: 'data',
  state: () => {
    return {
      count: 1000,
      maxCount: 2000
    }
  },
  actions: {
    resetCount(num) {
      this.count = 1000
    },
  },
  getters: {
    isMax: (state) => {
      return state.count >= state.maxCount
    },
    getMaxCount: (state) => {
      return state.maxCount
    },
  },
  persist: {
    enabled: true
  }
})