🚧 继续调试验证

This commit is contained in:
BTMuli
2023-10-02 22:56:12 +08:00
parent b3bbd4bed7
commit 49c716f009
3 changed files with 12 additions and 13 deletions

View File

@@ -5,7 +5,7 @@
*/ */
import { h, render, type VNode } from "vue"; import { h, render, type VNode } from "vue";
import geetest, { type GeetestParam } from "./geetest.vue"; import geetest from "./geetest.vue";
const geetestId = "tg-func-geetest"; const geetestId = "tg-func-geetest";
@@ -20,13 +20,13 @@ const renderBox = (): VNode => {
let geetestInstance: VNode; let geetestInstance: VNode;
const showGeetest = async (props: GeetestParam): Promise<string | boolean> => { const showGeetest = async (): Promise<boolean> => {
if (geetestInstance) { if (geetestInstance) {
const boxVue = geetestInstance.component; const boxVue = geetestInstance.component;
return boxVue?.exposeProxy?.displayBox(); return boxVue?.exposeProxy?.displayBox();
} else { } else {
geetestInstance = renderBox(); geetestInstance = renderBox();
return await showGeetest(props); return await showGeetest();
} }
}; };

View File

@@ -26,10 +26,6 @@ const showInner = ref<boolean>(false);
const userStore = useUserStore(); const userStore = useUserStore();
export interface GeetestParam {
urlOri: string;
}
const geetestRef = ref<HTMLElement>(<HTMLElement>document.getElementById("geetest")); const geetestRef = ref<HTMLElement>(<HTMLElement>document.getElementById("geetest"));
watch(show, () => { watch(show, () => {
@@ -48,7 +44,7 @@ watch(show, () => {
} }
}); });
async function displayBox(urlOri: string): Promise<boolean> { async function displayBox(): Promise<boolean> {
const cookie = userStore.getCookieGroup3(); const cookie = userStore.getCookieGroup3();
const res = await TGRequest.User.verification.get(cookie.ltoken, cookie.ltuid); const res = await TGRequest.User.verification.get(cookie.ltoken, cookie.ltuid);
if ("retcode" in res) { if ("retcode" in res) {
@@ -76,7 +72,7 @@ async function displayBox(urlOri: string): Promise<boolean> {
captchaObj.appendTo("#geetest"); captchaObj.appendTo("#geetest");
captchaObj.onSuccess(async () => { captchaObj.onSuccess(async () => {
const validate = captchaObj.getValidate(); const validate = captchaObj.getValidate();
const res = TGRequest.User.verification.verify(urlOri, userStore.cookie, validate); const res = TGRequest.User.verification.verify(userStore.cookie, validate);
resolve(res); resolve(res);
}); });
captchaObj.onClose(() => { captchaObj.onClose(() => {

View File

@@ -7,6 +7,7 @@
import TGUtils from "../utils/TGUtils"; import TGUtils from "../utils/TGUtils";
import { http } from "@tauri-apps/api"; import { http } from "@tauri-apps/api";
import showSnackbar from "../../components/func/snackbar"; import showSnackbar from "../../components/func/snackbar";
import TGConstant from "../constant/TGConstant";
/** /**
* @description 发起验证请求 * @description 发起验证请求
@@ -41,13 +42,11 @@ export async function getVerification(
* @description 将验证完的参数提交给米游社 * @description 将验证完的参数提交给米游社
* @since Beta v0.3.3 * @since Beta v0.3.3
* @todo 待测试 * @todo 待测试
* @param {string} urlOri 原始 url
* @param {Record<string, string>} cookie cookie * @param {Record<string, string>} cookie cookie
* @param {TGApp.BBS.Geetest.GeetestValidate} validate 验证码参数 * @param {TGApp.BBS.Geetest.GeetestValidate} validate 验证码参数
* @return {Promise<boolean>} 提交结果 * @return {Promise<boolean>} 提交结果
*/ */
export async function submitVerification( export async function submitVerification(
urlOri: string,
cookie: Record<string, string>, cookie: Record<string, string>,
validate: TGApp.BBS.Geetest.GeetestValidate, validate: TGApp.BBS.Geetest.GeetestValidate,
): Promise<boolean> { ): Promise<boolean> {
@@ -59,13 +58,16 @@ export async function submitVerification(
}; };
const data = JSON.stringify(dataRaw); const data = JSON.stringify(dataRaw);
const header = TGUtils.User.getHeader(cookie, "POST", data, "common", false); const header = TGUtils.User.getHeader(cookie, "POST", data, "common", false);
header["x-rpc-client_type"] = "2";
const reqHeader = { const reqHeader = {
...header, ...header,
"x-rpc-challenge_game": "2", "x-rpc-app_id": TGConstant.BBS.APP_ID,
"x-rpc-challenge": validate.geetest_challenge, "x-rpc-challenge": validate.geetest_challenge,
"x-rpc-validate": validate.geetest_validate, "x-rpc-validate": validate.geetest_validate,
"x-rpc-seccode": validate.geetest_seccode, "x-rpc-seccode": validate.geetest_seccode,
"x-rpc-challenge_path": urlOri, "x-rpc-game_biz": "hk4e_cn",
"x-rpc-sdk_version": "1.3.1.2",
"x-rpc-device_id": "FA47BE878C143D2FE18785B660EF114A",
}; };
console.log(reqHeader); console.log(reqHeader);
return await http return await http
@@ -81,6 +83,7 @@ export async function submitVerification(
text: `[${res.data.retcode}] ${res.data.message}`, text: `[${res.data.retcode}] ${res.data.message}`,
color: "error", color: "error",
}); });
console.log(res.data);
return false; return false;
} }
return true; return true;