| |
| if (typeof window !== 'undefined' && !window.localStorage) { |
| const storage: Record<string, string> = {}; |
| window.localStorage = { |
| getItem: (key: string) => storage[key] || null, |
| setItem: (key: string, value: string) => { |
| storage[key] = value; |
| }, |
| removeItem: (key: string) => { |
| delete storage[key]; |
| }, |
| clear: () => { |
| Object.keys(storage).forEach((key) => delete storage[key]); |
| }, |
| get length() { |
| return Object.keys(storage).length; |
| }, |
| key: (index: number) => { |
| const keys = Object.keys(storage); |
| return keys[index] || null; |
| }, |
| } as Storage; |
| } else if (typeof window !== 'undefined' && window.localStorage && !window.localStorage.getItem) { |
| |
| const storage: Record<string, string> = {}; |
| window.localStorage = { |
| getItem: (key: string) => storage[key] || null, |
| setItem: (key: string, value: string) => { |
| storage[key] = value; |
| }, |
| removeItem: (key: string) => { |
| delete storage[key]; |
| }, |
| clear: () => { |
| Object.keys(storage).forEach((key) => delete storage[key]); |
| }, |
| get length() { |
| return Object.keys(storage).length; |
| }, |
| key: (index: number) => { |
| const keys = Object.keys(storage); |
| return keys[index] || null; |
| }, |
| } as Storage; |
| } |
|
|
| |
| if (typeof window !== 'undefined' && !window.matchMedia) { |
| window.matchMedia = (query: string) => |
| ({ |
| matches: false, |
| media: query, |
| onchange: null, |
| addEventListener: () => {}, |
| removeEventListener: () => {}, |
| addListener: () => {}, |
| removeListener: () => {}, |
| dispatchEvent: () => false, |
| }) as MediaQueryList; |
| } |
|
|