From 351c86589eaf09beb02b0c5ee9cbe195f827b9c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9B=AE=E6=A3=83?= Date: Tue, 12 Mar 2024 20:08:07 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=20ck=20=E5=B9=B6=E8=8E=B7=E5=8F=96=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=20#99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/config/tc-userBadge.vue | 1 + src/utils/TGClient.ts | 31 ++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/components/config/tc-userBadge.vue b/src/components/config/tc-userBadge.vue index 210c7e50..49ab732f 100644 --- a/src/components/config/tc-userBadge.vue +++ b/src/components/config/tc-userBadge.vue @@ -218,6 +218,7 @@ async function getTokenWeb(cookie: string): Promise { text: "登录成功!", color: "success", }); + console.log("cookieUser", cookieUser); } async function refreshUser() { diff --git a/src/utils/TGClient.ts b/src/utils/TGClient.ts index f24874a8..10ea5b92 100644 --- a/src/utils/TGClient.ts +++ b/src/utils/TGClient.ts @@ -440,6 +440,30 @@ class TGClient { await invoke("execute_js", { label: "mhy_client", js: executeJS }); } + /** + * @func loadSignIn + * @since Beta v0.4.4 + * @desc 自动检测登录ck + * @returns {Promise} + */ + async loadSignIn(): Promise { + const executeJS = `javascript:(async function() { + let isLogin = false; + while(!isLogin) { + var ck = document.cookie; + if(ck.includes("login_ticket")) { + const arg = { + method: 'teyvat_sign_in', + payload: ck, + } + await window.__TAURI__.event.emit('post_mhy_client',JSON.stringify(arg)); + isLogin = true; + } + } + })();`; + await invoke("execute_js", { label: "mhy_client", js: executeJS }); + } + /** * @func nullCallback * @since Beta v0.3.9 @@ -453,7 +477,7 @@ class TGClient { /** * @func open - * @since Beta v0.4.3 + * @since Beta v0.4.4 * @desc 打开米游社客户端 * @param {string} func - 方法名 * @param {string} url - url @@ -468,6 +492,9 @@ class TGClient { await this.window?.show(); await this.window?.setFocus(); await this.loadJSBridge(); + if (func === "config_sign_in") { + await this.loadSignIn(); + } } /* JSBridge 回调处理 */ @@ -669,7 +696,7 @@ class TGClient { } const data = { "user-agent": TGConstant.BBS.UA_MOBILE, - "x-rpc-client_type": "5", + "x-rpc-client_type": "2", "x-rpc-device_id": deviceInfo.device_id, "x-rpc-app_version": TGConstant.BBS.VERSION, "x-rpc-device_fp": deviceInfo.device_fp,