1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-07 09:51:26 +00:00
Files
seahub/frontend/src/metadata/metadata-view/_basic/utils/local-storage.js
杨国璇 19f15c944f feat: sf metadata display (#6249)
* feat: sf metadata display

* feat: update code

* feat: update code

* feat: lock react version

* feat: bug

* feat: optimize code

* feat: update transalte

* feat: update transalte

* feat: rebase code

* Feat: update code

* Feat: update code

---------

Co-authored-by: 杨国璇 <ygx@192.168.1.5>
Co-authored-by: 杨国璇 <ygx@Hello-word.local>
Co-authored-by: 杨国璇 <ygx@192.168.1.13>
2024-06-29 17:58:27 +08:00

29 lines
572 B
JavaScript

class LocalStorage {
constructor(baseName) {
this.baseName = baseName || 'sf-metadata';
}
getStorage() {
try {
return JSON.parse(window.localStorage.getItem(this.baseName) || '{}');
} catch (error) {
return '';
}
}
setItem(key, value) {
const storage = this.getStorage();
const newValue = { ...storage, [key]: value };
return window.localStorage.setItem(this.baseName, JSON.stringify(newValue));
}
getItem(key) {
const storage = this.getStorage();
return storage[key];
}
}
export default LocalStorage;