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 28 29 30
| import { getStorageSync, removeStorageSync, setStorageSync } from '@tarojs/taro' import { persist } from 'zustand/middleware' import { create } from 'zustand'
const asyncLocalStorage = { getItem: getStorageSync, setItem: setStorageSync, removeItem: removeStorageSync }
const cretaeCardIdSlice = (set, _get) => ({ cardId: '', setCard: (input) => set({ cardId: input }) })
export const useCardIdState = create( persist( (set: any, get: any) => ({ ...cretaeCardIdSlice(set, get) }), { name: 'CARD_ID', partialize: (state) => ({ cardId: state.cardId }), getStorage: () => asyncLocalStorage } ) )
|