Skip to content

Commit

Permalink
Merge pull request #645 from haoxiuwen/doc-v2
Browse files Browse the repository at this point in the history
Modify IM Web Quick Start Docs
  • Loading branch information
haoxiuwen authored Feb 23, 2024
2 parents 0cb38d0 + 848b2dc commit 8b4173d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/document/server-side/user_relationship.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ GET https://{host}/{org_name}/{app_name}/user/{username}/contacts?limit={N}&curs

| 字段 | 类型 | 描述 |
|:-------------------------|:-------|:---------------|
| `count` | Int | 当前用户的好友数量|
| `count` | Int | 当前页的好友数量|
| `data` | Object | 返回的好友列表对象。 |
| `data.contacts` | Array | 返回的好友列表数据。 |
| `data.contacts.remark` | String | 好友备注。 |
Expand Down
36 changes: 34 additions & 2 deletions docs/document/web/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,50 @@

## 引入 SDK

对于 JavaScript SDK,导入代码如下:
- 对于 JavaScript SDK,导入代码如下:

```javascript
import EC from "easemob-websdk";
```

对于 TypeScript SDK,导入代码如下, EasemobChat 是 SDK 类型的命名空间。
- 对于 TypeScript SDK,导入代码如下, EasemobChat 是 SDK 类型的命名空间。

```javascript
import EC, { EasemobChat } from "easemob-websdk";
```

- 对于服务端渲染框架, 如 Nuxt、Next 等,需要在客户端渲染阶段引入 SDK。

Nuxt 项目, 你可以在 mounted 生命周期动态导入 SDK:

```javascript
export default {
mounted: () => {
import("easemob-websdk").then((res) => {
const EC = res.default;
console.log(EC, "easemob websdk");
});
}
};
```

Next 项目, 要使用客户端组件,你可以在文件顶部的导入上方添加 `use client` 指令。

```tsx
'use client'

import { useEffect } from 'react'

export default function Home() {
useEffect(() => {
import('easemob-websdk').then((res)=>{
const EC = res.default;
console.log(EC, "easemob websdk");
})
}, [])
}
```

如果对 SDK 大小有要求,可根据功能按需导入 SDK 文件。

| 功能 | 导入文件 | 使用方式 |
Expand Down

0 comments on commit 8b4173d

Please sign in to comment.