Skip to content

Commit

Permalink
🚧 继续调试验证
Browse files Browse the repository at this point in the history
  • Loading branch information
BTMuli committed Oct 2, 2023
1 parent b3bbd4b commit 49c716f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/components/func/geetest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { h, render, type VNode } from "vue";
import geetest, { type GeetestParam } from "./geetest.vue";
import geetest from "./geetest.vue";

const geetestId = "tg-func-geetest";

Expand All @@ -20,13 +20,13 @@ const renderBox = (): VNode => {

let geetestInstance: VNode;

const showGeetest = async (props: GeetestParam): Promise<string | boolean> => {
const showGeetest = async (): Promise<boolean> => {
if (geetestInstance) {
const boxVue = geetestInstance.component;
return boxVue?.exposeProxy?.displayBox();
} else {
geetestInstance = renderBox();
return await showGeetest(props);
return await showGeetest();
}
};

Expand Down
8 changes: 2 additions & 6 deletions src/components/func/geetest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ const showInner = ref<boolean>(false);
const userStore = useUserStore();
export interface GeetestParam {
urlOri: string;
}
const geetestRef = ref<HTMLElement>(<HTMLElement>document.getElementById("geetest"));
watch(show, () => {
Expand All @@ -48,7 +44,7 @@ watch(show, () => {
}
});
async function displayBox(urlOri: string): Promise<boolean> {
async function displayBox(): Promise<boolean> {
const cookie = userStore.getCookieGroup3();
const res = await TGRequest.User.verification.get(cookie.ltoken, cookie.ltuid);
if ("retcode" in res) {
Expand Down Expand Up @@ -76,7 +72,7 @@ async function displayBox(urlOri: string): Promise<boolean> {
captchaObj.appendTo("#geetest");
captchaObj.onSuccess(async () => {
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);
});
captchaObj.onClose(() => {
Expand Down
11 changes: 7 additions & 4 deletions src/web/request/operVerification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import TGUtils from "../utils/TGUtils";
import { http } from "@tauri-apps/api";
import showSnackbar from "../../components/func/snackbar";
import TGConstant from "../constant/TGConstant";

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

0 comments on commit 49c716f

Please sign in to comment.