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 31 32
| getCacheSize() { plus.cache.calculate((size) => { const sizeInt = parseInt(size) if (sizeInt < 1024) { this.cacheSize = '0KB' } else if (sizeInt < 1048576) { this.cacheSize = `${(sizeInt / 1024).toFixed(2)}KB` } else { this.cacheSize = `${(sizeInt / 1048576).toFixed(2)}MB` } }) }
clearCache() { uni.showModal({ title: '确认清除?', content: '清除缓存将清空登录信息,需要重新启动应用进行登录', success: (res) => { if (res.confirm) { plus.cache.clear(() => { this.getCacheSize() plus.runtime.restart() }) } }, }) }
|