import { Util } from "../Common/Utils/Util" ; export default class StoreManager { private userData : any = this . getAll ( ) ; getUID ( ) { return "Tap" ; } param key getItem ( key ) { if ( this . userData . size == 0 ) { this . userData = this . getAll ( ) ; } return this . userData [ key ] ; } hasItem ( key ) { if ( this . userData . size == 0 ) { this . userData = this . getAll ( ) ; } return Object . prototype . hasOwnProperty . call ( this . userData , key ) ; } param key param value setItem ( key , value ) { this . userData [ key ] = value ; let uuid = this . getUID ( ) ; cc . sys . localStorage . setItem ( uuid + "" , JSON . stringify ( this . userData ) ) ; } /**
     * 获取本地存储的所有的持久化数据
     */ getAll ( ) { let uuid = this . getUID ( ) ; let reson = cc . sys . localStorage . getItem ( uuid + "" ) ; if ( reson ) { return JSON . parse ( reson ) ; } else { return { } ; } } param key removeItem ( key ) { let reson = this . getAll ( ) ; if ( reson ) { delete reson [ key ] ; let uuid = this . getUID ( ) ; cc . sys . localStorage . setItem ( uuid + '' , JSON . stringify ( reson ) ) ; } } param key removeAll ( ) { let uuid = this . getUID ( ) ; cc . sys . localStorage . removeItem ( uuid + '' ) ; } }