diff --git a/ling_chair_http/index.html b/ling_chair_http/index.html index 1f2b2d6..b5a2eed 100644 --- a/ling_chair_http/index.html +++ b/ling_chair_http/index.html @@ -170,7 +170,7 @@ cloud_circle + n-input-ls="server" onblur="" />
account_circle diff --git a/ling_chair_http/index.js b/ling_chair_http/index.js index 50e4ae9..928a8e4 100644 --- a/ling_chair_http/index.js +++ b/ling_chair_http/index.js @@ -690,18 +690,28 @@ if (!localStorage.refreshToken || localStorage.refreshToken === "") localStorage.isSignIn = false let client +function setUpClient(server) { + if (server) + client = new io(server, { + auth: { + name: localStorage.isSignIn === "false" ? null : localStorage.userName + } + }) + else + client = new io({ + auth: { + name: localStorage.isSignIn === "false" ? null : localStorage.userName + } + }) + + client.on("connect", () => { + User.auth() + }) +} if (!localStorage.server || localStorage.server === "") - client = new io({ - auth: { - name: localStorage.isSignIn === "false" ? null : localStorage.userName - } - }) + setUpClient() else - client = new io(localStorage.server, { - auth: { - name: localStorage.isSignIn === "false" ? null : localStorage.userName - } - }) + setUpClient(localStorage.server) // 登录到账号 let dialogSignIn @@ -727,10 +737,6 @@ else { ContactsList.reloadList() - client.on("connect", () => { - User.auth() - }) - User.registerCallback() }