UNPKG

minix-template

Version:

minix template

219 lines (218 loc) 4.82 kB
/* * @Description: * @Autor: tangsj * @Date: 2022-05-12 19:08:11 * @LastEditTime: 2022-05-23 15:47:57 */ import router from '@system.router' import prompt from '@system.prompt' export default { data: { cacheList:[ { name:'setMiniAppCache', // url:'pages/base/canlUse/index', describe:'设置当前插件的内存缓存和磁盘缓存' }, { name:'getMiniAppCache', // url:'pages/base/log/index', describe:'获取当前插件指定键的局部缓存数据' }, { name:'deleteMiniAppCache', // url:'pages/base/canlUse/index', describe:'当前插件删除指定key值指定存储类型的缓存数据' }, { name:'setGlobalAppCache', // url:'pages/base/log/index', describe:'设置指定键的全局缓存,可以设置到内存中,还可以内存和磁盘中都保存' }, { name:'getGlobalAppCache', // url:'pages/base/log/index', describe:'获取指定键全局缓存,先从内存中获取' }, { name:'deleteGlobalAppCache', // url:'pages/base/canlUse/index', describe:'删除指定键指定存储类型的全局缓存' } ] }, goRouter(url){ router.push({ uri: url, }) }, /** * @description: 设置当前插件的内存缓存和磁盘缓存 * @param {*} * @return {*} */ setMiniAppCache(){ const params = { "type": "0", "params": { name:'midea' } } this.$app.$def.bridge.setMiniAppCache(params) .then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: 获取当前插件指定键的局部缓存数据 * @param {*} * @return {*} */ getMiniAppCache(){ const params = { "keys": [ 'name' ] } this.$app.$def.bridge.getMiniAppCache(params) .then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: 当前插件删除指定key值指定存储类型的缓存数据 * @param {*} * @return {*} */ deleteMiniAppCache(){ const params = { "keys": [ 'name' ] } this.$app.$def.bridge.deleteMiniAppCache(params) .then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: 设置指定键的全局缓存,可以设置到内存中 * @param {*} * @return {*} */ setGlobalAppCache(){ const params = { "type": "0", "params": { name:'midea' } } this.$app.$def.bridge.setGlobalAppCache(params) .then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description:获取指定键全局缓存 * @param {*} * @return {*} */ getGlobalAppCache(){ const params = { "keys": [ 'name' ] } this.$app.$def.bridge.getGlobalAppCache(params) .then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: 定位周边地址 * @param {*} * @return {*} */ deleteGlobalAppCache(){ prompt.showToast({ message: params, duration: 200, }) this.$app.$def.bridge.deleteGlobalAppCache(params) .then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, testBridge(name){ switch(name){ case 'setMiniAppCache': this.setMiniAppCache() break; case 'getMiniAppCache': this.getMiniAppCache() break; case 'deleteMiniAppCache': this.deleteMiniAppCache() break; case 'setGlobalAppCache': this.setGlobalAppCache() break; case 'getGlobalAppCache': this.getGlobalAppCache() break; case 'deleteGlobalAppCache': this.deleteGlobalAppCache() break; default: break; } } }