Skip to content

Update quick start #1385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 5 additions & 25 deletions docs/document/web/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,11 @@ Easemob_quickstart<br>
<input type="text" placeholder="Username" id="userID">
</div>
<div class="input-field">
<label>Password</label>
<input type="password" placeholder="Password" id="password">
<label>Token</label>
<input type="text" placeholder="Token" id="token">
</div>
<div class="row">
<div>
<button type="button" id="register">register</button>
<button type="button" id="login">login</button>
<button type="button" id="logout">logout</button>
</div>
Expand Down Expand Up @@ -127,7 +126,7 @@ Easemob_quickstart<br>
import WebIM from 'easemob-websdk'
const appKey = "<Your app key>"

let username, password
let username, accessToken

// 初始化客户端。相关的参数配置,详见 API 参考中的 `Connection` 类。
WebIM.conn = new WebIM.connection({
Expand Down Expand Up @@ -155,31 +154,12 @@ WebIM.conn.addEventHandler('connection&message', {

// 按钮行为定义。
window.onload = function () {
// 注册。
document.getElementById("register").onclick = function(){
username = document.getElementById("userID").value.toString()
password = document.getElementById("password").value.toString()
WebIM.conn
.registerUser({ username, password })
.then((res) => {
document
.getElementById("log")
.appendChild(document.createElement("div"))
.append(`register user ${username} success`);
})
.catch((e) => {
document
.getElementById("log")
.appendChild(document.createElement("div"))
.append(`${username} already exists`);
});
}
// 登录。
document.getElementById("login").onclick = function () {
username = document.getElementById("userID").value.toString()
password = document.getElementById("password").value.toString()
accessToken = document.getElementById("token").value.toString()
WebIM.conn
.open({ user: username, pwd: password })
.open({ user: username, accessToken })
.then((res) => {
document
.getElementById("log")
Expand Down
16 changes: 9 additions & 7 deletions docs/uikit/chatroomuikit/web/roomuikit_quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,25 @@ const ChatroomApp = observer(() => {
if (client.addEventHandler) {
client.addEventHandler("chatroom", {
onConnected: () => {
console.log("登录成功");
console.log("已建立连接");
},
onDisconnected: () => {
console.log("连接已断开");
}
});
}
}, [client]);

const [userId, setUserId] = useState("");
const [password, setPassword] = useState("");
const [token, setToken] = useState("");
const login = () => {
client
.open({
user: userId,
pwd: password,
//accessToken: '',
accessToken: token,
})
.then((res) => {
console.log("获取token成功");
console.log("登录成功");
});
};
return (
Expand All @@ -128,10 +130,10 @@ const ChatroomApp = observer(() => {
></input>
</div>
<div>
<label>password</label>
<label>token</label>
<input
onChange={(e) => {
setPassword(e.target.value);
setToken(e.target.value);
}}
></input>
</div>
Expand Down