const CACHE_PREFIX = 'ibms';
export const getPrefixKey = (key : any) => {
	return `${CACHE_PREFIX}-${key}`
}

export const getLocalStorage = (key : any) => {
	return uni.getStorageSync(getPrefixKey(key))
}

export const setLocalStorage = (key : any, value : any) => {
	uni.setStorageSync(getPrefixKey(key), value)
}

export const deleteLocalStorage = (key : any) => {
	uni.removeStorageSync(getPrefixKey(key))
}

export const clearLocalStorage = () => {
	const { keys } = uni.getStorageInfoSync();
	for (let key of keys) {
		if (key.indexOf(CACHE_PREFIX) === 0) {
			uni.removeStorageSync(key)
		}
	}
}