
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
	})
}