<template>
  <div>
    <div v-for="(item,index) in items"
         :key="index">
       <div class="cItem" @click="onClickItem(item.name)">{{item.name}}</div>
    </div>
  </div>
</template>

<script>

import YxCache from "../../../../utils/cache/index"

export default {
  data () {
    return {
      items:[
        {name:'setStorage'},
        {name:'setStorageSync'},

        {name:'getStorage'},
        {name:'getStorageSync'},

        {name:'clearStorage'},
        {name:'clearStorageSync'},


        {name:'getStorageInfo'},
        {name:'getStorageInfoSync'},

        {name:'removeStorage'},
        {name:'removeStorageSync'}
      ],

      info:{
        name:'zhangwei',
        info:'man'
      },

      infoSync:{
        name:'zhangweiSync',
        info:'man'
      },

      key:"key",
      keySync:'keySync',
    }
  },

  components: {
  },

  methods: {
    onClickItem (name) {
       if(name == 'setStorage'){
         YxCache.setStorage(this.key, this.info,(flag)=>{
           var info = YxCache.getStorageSync(this.key)
           console.log(info)
         })
       }if(name == 'setStorageSync'){
        YxCache.setStorageSync(this.keySync, this.infoSync)
        var info = YxCache.getStorageSync(this.keySync)
        console.log(info)
      }else if(name == 'getStorage'){
         YxCache.getStorage(this.key,(info)=>{
           console.log(info)
         })
       }else if(name == 'getStorageSync'){
         var info = YxCache.getStorageSync(this.key)
         console.log(info)
       }else if(name == 'getStorageInfo'){
        YxCache.getStorageInfo((info)=>{
          console.log(info)
        })
      }else if(name == 'getStorageInfoSync'){
        var info = YxCache.getStorageInfoSync()
        console.log(info)
      }else if(name == 'removeStorage'){
        YxCache.removeStorage(this.keySync,(info)=>{
          console.log(info)
        })

      }else if(name == 'removeStorageSync'){
        YxCache.removeStorageSync(this.key)
        var info = YxCache.getStorageInfoSync()
        console.log(info)
      }else if(name == 'clearStorage'){
        YxCache.clearStorage(()=>{
          var info = YxCache.getStorageInfoSync()
          console.log(info)
        })

      }else if(name == 'clearStorageSync'){
        YxCache.clearStorageSync()
      }
    }
  },

  created () {
    // let app = getApp()
  }
}
</script>

<style scoped>
  .cItem{
     width: 100%;
     line-height: 40px;
     padding-left: 10px;
     border-bottom: solid 1px #959595;
  }
</style>
