opraRecords.ts 661 B

1234567891011121314151617181920212223242526
  1. import { ConstantLocalStorage } from '@/utils/constant'
  2. import { ConstantStore } from '@/utils/constant'
  3. import { defineStore } from 'pinia'
  4. import { useLocalStorageState } from 'vue-hooks-plus'
  5. export const useOpraRecordStore = defineStore(ConstantStore.OPRARECORDS, () => {
  6. const [ state, setState ] = useLocalStorageState<API.LearnPlanRecords[]>(ConstantLocalStorage.OPRARECORDS, {
  7. defaultValue: []
  8. })
  9. const _push = (records: any) => setState([...state.value!, records])
  10. const _clear = () => setState([])
  11. const _get = () => state.value
  12. return {
  13. push: _push,
  14. get: _get,
  15. clear: _clear,
  16. length: state.value?.length
  17. }
  18. })