mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 23:57:12 +01:00
Imported libraries, removed next-basics.
This commit is contained in:
parent
31266cb1ac
commit
113022ed17
44 changed files with 361 additions and 180 deletions
21
src/lib/storage.ts
Normal file
21
src/lib/storage.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
export function setItem(key: string, data: any, session?: boolean): void {
|
||||
if (typeof window !== 'undefined' && data) {
|
||||
return (session ? sessionStorage : localStorage).setItem(key, JSON.stringify(data));
|
||||
}
|
||||
}
|
||||
|
||||
export function getItem(key: string, session?: boolean): any {
|
||||
if (typeof window !== 'undefined') {
|
||||
const value = (session ? sessionStorage : localStorage).getItem(key);
|
||||
|
||||
if (value !== 'undefined' && value !== null) {
|
||||
return JSON.parse(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function removeItem(key: string, session?: boolean): void {
|
||||
if (typeof window !== 'undefined') {
|
||||
return (session ? sessionStorage : localStorage).removeItem(key);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue