mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-26 19:46:40 +07:00
now user can login
This commit is contained in:
parent
e7960a6bf8
commit
e19001ca82
25 changed files with 493 additions and 32844 deletions
25
src/utils/storage.js
Normal file
25
src/utils/storage.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
const canStore = typeof window.localStorage !== 'undefined'
|
||||
|
||||
export const storeData = (key, data) => {
|
||||
if (!canStore) return;
|
||||
|
||||
const value = JSON.stringify(data);
|
||||
|
||||
localStorage.setItem(key, value);
|
||||
};
|
||||
|
||||
export const getData = key => {
|
||||
if (!canStore) return;
|
||||
|
||||
let result = null;
|
||||
|
||||
try {
|
||||
result = JSON.parse(localStorage.getItem(key));
|
||||
} catch(e) {
|
||||
result = null;
|
||||
}
|
||||
|
||||
if (!result) return;
|
||||
|
||||
return result;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue