
let ZFile = new class {
	constructor(){
	}
	getLocal(key, defaultVal) {
		var result = cc.sys.localStorage.getItem(key);
		if (result === '' || result === null || result === undefined) {
			return defaultVal;
		}
		return result;
	}
	setLocal(key, value) {
		if (key === null || key === undefined) { return }
		if (value === null || value === undefined) {
			cc.sys.localStorage.removeItem(key);
		} else {
			cc.sys.localStorage.setItem(key, value);
		}
	}
	getLocalJson(key, defaultVal) {
		var result = cc.sys.localStorage.getItem(key);
		if (result === '' || result === null || result === undefined) {
			return defaultVal;
		}
		return JSON.parse(result);
	}
	setLocalJson(key, json) {
		if (key === null || key === undefined) { return }
		if (json === null || json === undefined) {
			cc.sys.localStorage.removeItem(key);
		} else {
			var value = JSON.stringify(json);
			cc.sys.localStorage.setItem(key, value);
		}
	}
}

window["ZFile"] = ZFile
