123456789101112131415161718192021222324252627282930313233343536373839 |
- const logLength=100;//缓存存储上限
- const name = 'log';//缓存名字
- export function addLog (data,content='') {
- let log = uni.getStorageSync(name)||[];
- log.unshift({
- title:data,
- content:content
- });
- uni.setStorageSync(name,log);
- initLog(log);
- }
- export function delLog () {
- return uni.setStorageSync(name,'');
- }
- export function getLog () {
- return uni.getStorageSync(name);
- }
- export function initLog (log) {
- if(log.length>logLength){
- const newarr = log.slice(log.length-logLength);
- uni.setStorageSync(name,newarr);
- }
- }
- export function showLog (log) {
-
- let str = '';
- uni.getStorageSync(name).forEach((e) => {
- str+=e.title+':'+JSON.stringify(e.content)
- })
- uni.showModal({
- title:"日志",
- content:str
- })
- }
|