diff --git a/src/background.js b/src/background.js index a8d7c1650e..45a798abb1 100644 --- a/src/background.js +++ b/src/background.js @@ -284,10 +284,10 @@ function createNewWindow(url, userAgent = "") { // Get QianWen bot's XSRF-TOKEN const token = await getCookie("XSRF-TOKEN"); mainWindow.webContents.send("QIANWEN-XSRF-TOKEN", token); - } else if (url.startsWith("https://neice.tiangong.cn/")) { + } else if (url.startsWith("https://chat.tiangong.cn/")) { // Get the tokens of SkyWork - const inviteToken = await getLocalStorage("formNatureQueueWaitToken"); - const token = await getLocalStorage("formNatureResearchToken"); + const inviteToken = await getLocalStorage("aiChatQueueWaitToken"); + const token = await getLocalStorage("aiChatResearchToken"); mainWindow.webContents.send("SKYWORK-TOKENS", { inviteToken, token }); } else if (url.startsWith("https://character.ai/")) { const token = await getLocalStorage("char_token"); diff --git a/src/bots/SkyWorkBot.js b/src/bots/SkyWorkBot.js index d017462841..e7672f8261 100644 --- a/src/bots/SkyWorkBot.js +++ b/src/bots/SkyWorkBot.js @@ -9,7 +9,7 @@ export default class SkyWorkBot extends Bot { static _className = "SkyWorkBot"; // Class name of the bot static _logoFilename = "skywork-logo.png"; // Place it in public/bots/ static _isDarkLogo = true; // The main color of logo is dark - static _loginUrl = "https://neice.tiangong.cn/"; + static _loginUrl = "https://chat.tiangong.cn/"; static _lock = new AsyncLock(); // AsyncLock for prompt requests currentPrompt = ""; // Used by createChatContext() only @@ -35,28 +35,11 @@ export default class SkyWorkBot extends Bot { let available = false; try { - const { data } = await axios.post( - "https://neice.tiangong.cn/api/v1/user/inviteVerify", - { data: {} }, - this.getAuthHeaders(), + const { data } = await axios.get( + "https://api.tiangong.cn/usercenter/v1/passport/check", + { headers: { "K-Client-Id": 200001 } }, ); - - if (data.code === 200) { - available = true; - } else if (data.code >= 60100) { - // Invite token expired, request a new one - const { data } = await axios.post( - "https://neice.tiangong.cn/api/v1/queue/waitAccess", - { data: { token: "" } }, - this.getAuthHeaders(), - ); - if (data.code === 200 && data.resp_data?.busy_now === false) { - await store.commit("setSkyWork", { - inviteToken: data.resp_data?.invite_token, - }); - available = true; - } - } + available = data.data?.is_login; } catch (err) { console.error("SkyWork login error:", err); } @@ -87,7 +70,7 @@ export default class SkyWorkBot extends Bot { if (!messageId) { await axios .post( - "https://neice.tiangong.cn/api/v1/chat/chat", + "https://api-chat.tiangong.cn/api/v1/chat/chat", { data: { content: prompt, session_id: context.sessionId } }, this.getAuthHeaders(), ) @@ -114,7 +97,7 @@ export default class SkyWorkBot extends Bot { await new Promise((resolve) => setTimeout(resolve, 1000)); await axios .post( - "https://neice.tiangong.cn/api/v1/chat/getMessage", + "https://api-chat.tiangong.cn/api/v1/chat/getMessage", { data: { message_id: messageId } }, this.getAuthHeaders(), ) @@ -152,7 +135,7 @@ export default class SkyWorkBot extends Bot { let context = null; await axios .post( - "https://neice.tiangong.cn/api/v1/session/newSession", + "https://api-chat.tiangong.cn/api/v1/session/newSession", { data: { content: this.currentPrompt } }, this.getAuthHeaders(), )