|
@ -20,7 +20,6 @@ const getItem = (key: string, storageType: StorageType): any => { |
|
|
try { |
|
|
try { |
|
|
const storage = getStorage(storageType); |
|
|
const storage = getStorage(storageType); |
|
|
const item = storage.getItem(key); |
|
|
const item = storage.getItem(key); |
|
|
debugger |
|
|
|
|
|
if (item) { |
|
|
if (item) { |
|
|
return JSON.parse(item); |
|
|
return JSON.parse(item); |
|
|
} |
|
|
} |
|
@ -69,7 +68,7 @@ const initializeStorage = (storageType: StorageType): void => { |
|
|
const storage = getStorage(storageType); |
|
|
const storage = getStorage(storageType); |
|
|
const keys = Object.keys(storage); |
|
|
const keys = Object.keys(storage); |
|
|
|
|
|
|
|
|
storageData.value = keys.map((key) => ({ |
|
|
storageData.value = keys.map(key => ({ |
|
|
key, |
|
|
key, |
|
|
value: getItem(key, storageType) |
|
|
value: getItem(key, storageType) |
|
|
})); |
|
|
})); |
|
@ -89,7 +88,7 @@ const useStorage = (storageType: StorageType) => { |
|
|
|
|
|
|
|
|
const removeUseStorage = (key: string) => { |
|
|
const removeUseStorage = (key: string) => { |
|
|
removeItem(key, storageType); |
|
|
removeItem(key, storageType); |
|
|
const index = storageData.value.findIndex((item) => item.key === key); |
|
|
const index = storageData.value.findIndex(item => item.key === key); |
|
|
if (index !== -1) { |
|
|
if (index !== -1) { |
|
|
storageData.value.splice(index, 1); |
|
|
storageData.value.splice(index, 1); |
|
|
} |
|
|
} |
|
|