# storage

本地存储工具函数，自动处理 JSON 序列化，支持 TypeScript 类型推断

## Functions

### setLocal

设置 LocalStorage

```ts
function setLocal<T>(key: string, content: T): void
```

### getLocal

获取 LocalStorage

```ts
function getLocal<T>(key: string): T
```

### removeLocal

删除 LocalStorage

```ts
function removeLocal(key: string): void
```

### clearLocal

清空 LocalStorage

```ts
function clearLocal(): void
```

### setSession

设置 SessionStorage

```ts
function setSession<T>(key: string, content: T): void
```

### getSession

获取 SessionStorage

```ts
function getSession<T>(key: string): T
```

### removeSession

删除 SessionStorage

```ts
function removeSession(key: string): void
```

### clearSession

清空 SessionStorage

```ts
function clearSession(): void
```

### setStore

设置本地存储

```ts
function setStore<T>(key: string, value: T, type?: 'local' | 'session'): void
```

### getStore

获取本地存储

```ts
function getStore<T>(key: string, type?: 'local' | 'session'): T
```

### removeStore

删除本地存储

```ts
function removeStore(key: string, type?: 'local' | 'session'): void
```

## Example

```ts
import { setLocal, getLocal, setSession, getSession } from '@allkit/shared'

// LocalStorage
setLocal('token', '123')
const token = getLocal<string>('token') // '123'
removeLocal('token')

// SessionStorage
setSession('userInfo', { name: '张三', age: 18 })
const userInfo = getSession<{ name: string; age: number }>('userInfo')
removeSession('userInfo')

// 通用方法
setStore('token', '123', 'local')
const token2 = getStore<string>('token', 'local')
```
