
//存储localStorage
export function setStorage(key, value) {
    const data = typeof value === 'object' ? JSON.stringify(value) : value;
	window.localStorage.setItem(key, data);
}
//获取localStorage
export function getStorage(key) {
    const data = window.localStorage.getItem(key);
    try {
        return JSON.parse(data);
    } catch {
        return data;
    }
}
//获取localStorage
export function getPromiseStorage(key) {
    return new Promise((resolve, reject) => {
        const data = window.localStorage.getItem(key);
        try {
            resolve(JSON.parse(data));
        } catch {
            reject(data);
        }
    });
}
// 删除特定的localStorage项
export function clearStorage(key) {
    if (key) {
        window.localStorage.removeItem(key);
    }
}
