Skip to content

Commit 8854ad2

Browse files
author
haoxiuwen
committed
Modify Web UIKit
1 parent c86b124 commit 8854ad2

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

docs/docs/uikit/chatuikit/web/chatuikit_integrated_react.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
开始前,确保你的开发环境满足如下条件:
1010

11-
- React 16.8.0 或以上版本;
11+
- React 16.8.0 或以上版本(暂不支持 React 19)
1212
- React DOM 16.8.0 或以上版本;
1313
- [已创建项目并获取 App ID](https://im.shengwang.cn/docs/sdk/web/enable_im.html)
1414

docs/docs/uikit/chatuikit/web/chatuikit_quickstart.md

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
开启单群聊 UIKit 服务前,需确保已经具备以下条件:
1010

11-
- React 16.8.0 或以上版本;
11+
- React 16.8.0 或以上版本(暂不支持 React 19)
1212
- React DOM 16.8.0 或以上版本;
13-
- 已在[声网控制台](https://console.shengwnag.com/user/login)[创建了有效的即时通讯 IM 开发者账号](/docs/sdk/web/enable_im.html#_1-登录声网控制台),并[获取了 App ID](/docs/sdk/web/enable_im.html#_3-获取-app-id)
13+
- 已在[声网控制台](https://console.shengwang.com/user/login)[创建了有效的即时通讯 IM 开发者账号](/docs/sdk/web/enable_im.html#_1-登录声网控制台),并[获取了 App ID](/docs/sdk/web/enable_im.html#_3-获取-app-id)
1414

1515
## 支持的浏览器
1616

@@ -52,23 +52,23 @@ cd my-app
5252
└── yarn.lock
5353
```
5454

55-
### 第二步 集成 shengwnag-chat-uikit
55+
### 第二步 集成 shengwang-chat-uikit
5656

57-
#### 安装 shengwnag-chat-uikit
57+
#### 安装 shengwang-chat-uikit
5858

5959
- 若通过 npm 安装,运行以下命令:
6060

6161
```bash
62-
npm install shengwnag-chat-uikit
62+
npm install shengwang-chat-uikit
6363
```
6464

6565
- 若通过 yarn 安装,运行以下命令:
6666

6767
```bash
68-
yarn add shengwnag-chat-uikit
68+
yarn add shengwang-chat-uikit
6969
```
7070

71-
#### 使用 shengwnag-chat-uikit 组件构建应用
71+
#### 使用 shengwang-chat-uikit 组件构建应用
7272

7373
[声网控制台](https://console.shengwang.cn/overview)按照如下步骤创建用户:
7474

@@ -90,28 +90,33 @@ yarn add shengwnag-chat-uikit
9090

9191
在开发环境中,你需要从你的 App Server 获取用户 token,详见[使用 Token 鉴权](/docs/sdk/server-side/token_authentication.html)
9292

93-
`shengwnag-chat-uikit` 库导入你的代码中:
93+
`shengwang-chat-uikit` 库导入你的代码中:
9494

9595
```javascript
9696
// App.js
9797
import React, { Component, useEffect } from "react";
9898
import {
99-
Provider,
99+
UIKitProvider,
100100
Chat,
101101
ConversationList,
102102
useClient,
103103
rootStore,
104-
} from "shengwnag-chat-uikit";
105-
import "shengwnag-chat-uikit/style.css";
104+
} from "shengwang-chat-uikit";
105+
import "shengwang-chat-uikit/style.css";
106+
107+
// 注意:在使用 UIKit 前,请先设置 userId, accessToken 和 appId。
108+
const userId = "userId";
109+
const accessToken = "accessToken";
110+
const appId = "your appId";
106111

107112
const ChatApp = () => {
108113
const client = useClient();
109114
useEffect(() => {
110115
client &&
111116
client
112117
.open({
113-
user: "",
114-
accessToken: "",
118+
user: userId,
119+
accessToken: accessToken,
115120
})
116121
.then((res) => {
117122
// 创建会话
@@ -121,12 +126,15 @@ const ChatApp = () => {
121126
name: "用户1", // 单聊为对端用户昵称,群聊为群组名称。
122127
lastMessage: {},
123128
});
129+
})
130+
.catch((err) => {
131+
console.log("登录失败", err);
124132
});
125133
}, [client]);
126134

127135
return (
128136
<div style={{ display: "flex", height: "100vh" }}>
129-
<div style={{ width: "350px" }}>
137+
<div style={{ width: "350px", borderRight: "1px solid #ddd" }}>
130138
<ConversationList />
131139
</div>
132140
<div style={{ flex: "1" }}>
@@ -135,17 +143,16 @@ const ChatApp = () => {
135143
</div>
136144
);
137145
};
138-
139146
class App extends Component {
140147
render() {
141148
return (
142-
<Provider
149+
<UIKitProvider
143150
initConfig={{
144-
appId: "your appId",
151+
appId: appId,
145152
}}
146153
>
147154
<ChatApp />
148-
</Provider>
155+
</UIKitProvider>
149156
);
150157
}
151158
}

0 commit comments

Comments
 (0)