mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-12 09:18:14 +08:00
🔥 移除 geetest 相关代码
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
/**
|
||||
* @file component func geetest.ts
|
||||
* @description 封装自定义 geetest 组件,通过函数调用的方式,简化 geetest 的使用,使用时需要在 main.ts 中引入 geetest.js
|
||||
* @since Beta v0.3.3
|
||||
*/
|
||||
|
||||
import { h, render } from "vue";
|
||||
import type { ComponentInternalInstance, VNode } from "vue";
|
||||
|
||||
import geetest from "./geetest.vue";
|
||||
|
||||
const geetestId = "tg-func-geetest";
|
||||
|
||||
/**
|
||||
* @description 自定义 geetest 组件
|
||||
* @since Beta v0.3.3
|
||||
* @extends ComponentInternalInstance
|
||||
* @property {Function} exposeProxy.displayBox 弹出 geetest 验证
|
||||
* @return GeetestInstance
|
||||
*/
|
||||
interface GeetestInstance extends ComponentInternalInstance {
|
||||
exposeProxy: {
|
||||
displayBox: () => boolean;
|
||||
};
|
||||
}
|
||||
|
||||
const renderBox = (): VNode => {
|
||||
const container = document.createElement("div");
|
||||
container.id = geetestId;
|
||||
const boxVNode: VNode = h(geetest);
|
||||
render(boxVNode, container);
|
||||
document.body.appendChild(container);
|
||||
return boxVNode;
|
||||
};
|
||||
|
||||
let geetestInstance: VNode;
|
||||
|
||||
async function showGeetest(): Promise<boolean> {
|
||||
if (geetestInstance !== undefined) {
|
||||
const boxVue = <GeetestInstance>geetestInstance.component;
|
||||
return boxVue.exposeProxy.displayBox();
|
||||
} else {
|
||||
geetestInstance = renderBox();
|
||||
return await showGeetest();
|
||||
}
|
||||
}
|
||||
|
||||
export default showGeetest;
|
||||
@@ -1,185 +0,0 @@
|
||||
<template>
|
||||
<transition name="func-geetest-outer">
|
||||
<div v-show="show || showOuter" class="geetest-overlay" @click.self.prevent>
|
||||
<transition name="func-geetest-inner">
|
||||
<div v-show="showInner" class="geetest-box">
|
||||
<div class="geetest-top">
|
||||
<div class="geetest-title">请完成如下极验测试</div>
|
||||
</div>
|
||||
<div id="verify" class="geetest-mid">
|
||||
<div id="geetest" ref="geetestRef"></div>
|
||||
</div>
|
||||
</div>
|
||||
</transition>
|
||||
</div>
|
||||
</transition>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from "vue";
|
||||
|
||||
import showSnackbar from "./snackbar";
|
||||
import { useUserStore } from "../../store/modules/user";
|
||||
import TGRequest from "../../web/request/TGRequest";
|
||||
|
||||
const show = ref<boolean>(false);
|
||||
const showOuter = ref<boolean>(false);
|
||||
const showInner = ref<boolean>(false);
|
||||
|
||||
const userStore = useUserStore();
|
||||
|
||||
const geetestRef = ref<HTMLElement>(<HTMLElement>document.getElementById("geetest"));
|
||||
|
||||
watch(show, () => {
|
||||
if (show.value) {
|
||||
showOuter.value = true;
|
||||
setTimeout(() => {
|
||||
showInner.value = true;
|
||||
}, 100);
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
showInner.value = false;
|
||||
}, 100);
|
||||
setTimeout(() => {
|
||||
showOuter.value = false;
|
||||
}, 300);
|
||||
}
|
||||
});
|
||||
|
||||
async function displayBox(): Promise<void> {
|
||||
const cookieGet = userStore.getCookieGroup3();
|
||||
const resGet = await TGRequest.User.verification.get(cookieGet.ltoken, cookieGet.ltuid);
|
||||
if ("retcode" in resGet) {
|
||||
showSnackbar({
|
||||
text: `[${resGet.retcode}]${resGet.message}`,
|
||||
color: "error",
|
||||
});
|
||||
return;
|
||||
}
|
||||
show.value = true;
|
||||
initGeetest(
|
||||
{
|
||||
gt: resGet.gt,
|
||||
challenge: resGet.challenge,
|
||||
offline: false,
|
||||
new_captcha: true,
|
||||
product: "custom",
|
||||
area: "#verify",
|
||||
width: "250px",
|
||||
},
|
||||
(captchaObj: TGApp.BBS.Geetest.GeetestCaptcha) => {
|
||||
geetestRef.value.innerHTML = "";
|
||||
captchaObj.appendTo("#geetest");
|
||||
captchaObj.onSuccess(async () => {
|
||||
const validate = captchaObj.getValidate();
|
||||
const cookie = {
|
||||
account_id: userStore.cookie.account_id,
|
||||
cookie_token: userStore.cookie.cookie_token,
|
||||
ltoken: userStore.cookie.ltoken,
|
||||
ltuid: userStore.cookie.ltuid,
|
||||
};
|
||||
const resVerify = await TGRequest.User.verification.verify(cookie, validate);
|
||||
if (resVerify.retcode !== 0) {
|
||||
showSnackbar({
|
||||
text: `[${resVerify.retcode}]${resVerify.message}`,
|
||||
color: "error",
|
||||
});
|
||||
}
|
||||
});
|
||||
captchaObj.onClose(() => {
|
||||
show.value = false;
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
displayBox,
|
||||
});
|
||||
</script>
|
||||
<style lang="css" scoped>
|
||||
.func-geetest-outer-enter-active,
|
||||
.func-geetest-outer-leave-active,
|
||||
.func-geetest-inner-enter-active {
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.func-geetest-inner-leave-active {
|
||||
transition: all 0.5s ease-in-out;
|
||||
}
|
||||
|
||||
.func-geetest-inner-enter-from {
|
||||
opacity: 0;
|
||||
transform: scale(1.5);
|
||||
}
|
||||
|
||||
.func-geetest-inner-enter-to,
|
||||
.func-geetest-inner-leave-from {
|
||||
opacity: 1;
|
||||
transform: scale(1);
|
||||
}
|
||||
|
||||
.func-geetest-outer-enter-to,
|
||||
.func-geetest-outer-leave-from {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.func-geetest-outer-enter-from,
|
||||
.func-geetest-outer-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.func-geetest-inner-leave-to {
|
||||
opacity: 0;
|
||||
transform: scale(0);
|
||||
}
|
||||
|
||||
.geetest-overlay {
|
||||
position: fixed;
|
||||
z-index: 100;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
backdrop-filter: blur(20px);
|
||||
background: rgb(0 0 0 / 50%);
|
||||
}
|
||||
|
||||
.geetest-box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: var(--box-bg-1);
|
||||
color: var(--app-page-content);
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.geetest-top {
|
||||
border-bottom: 1px solid var(--common-shadow-4);
|
||||
font-family: var(--font-title);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.geetest-title {
|
||||
color: var(--common-text-title);
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.geetest-mid {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
background: var(--box-bg-2);
|
||||
}
|
||||
|
||||
#verify {
|
||||
width: 256px;
|
||||
height: 320px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file main.ts
|
||||
* @description Main entry
|
||||
* @since Beta v0.3.3
|
||||
* @since Beta v0.3.4
|
||||
*/
|
||||
|
||||
import { createApp } from "vue";
|
||||
@@ -14,7 +14,6 @@ import store from "./store";
|
||||
import "@mdi/font/css/materialdesignicons.css";
|
||||
import "vuetify/styles";
|
||||
import "./assets/index.css";
|
||||
import "https://static.geetest.com/static/js/gt.0.4.9.js";
|
||||
|
||||
if (import.meta.env.MODE === "development") {
|
||||
await import("@vue/devtools").then((i) => {
|
||||
|
||||
@@ -13,10 +13,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h1>极验测试</h1>
|
||||
<div class="btn-list">
|
||||
<v-btn class="test-btn" @click="getGC">获取极验</v-btn>
|
||||
</div>
|
||||
<h1>窗口建立测试</h1>
|
||||
<div class="btn-list">
|
||||
<v-btn class="test-btn" @click="tryNewWindow('sign_in')">SignIn</v-btn>
|
||||
@@ -27,7 +23,6 @@
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, ref } from "vue";
|
||||
|
||||
import showGeetest from "../../components/func/geetest";
|
||||
import mhyClient from "../../utils/TGClient";
|
||||
|
||||
const visible = ref<boolean>(false);
|
||||
@@ -37,10 +32,6 @@ onMounted(async () => {
|
||||
await mhyClient.run();
|
||||
});
|
||||
|
||||
async function getGC(): Promise<void> {
|
||||
await showGeetest();
|
||||
}
|
||||
|
||||
async function tryNewWindow(func: string): Promise<void> {
|
||||
await mhyClient.open(func);
|
||||
}
|
||||
|
||||
115
src/types/BBS/Geetest.d.ts
vendored
115
src/types/BBS/Geetest.d.ts
vendored
@@ -1,115 +0,0 @@
|
||||
/**
|
||||
* @file types BBS Geetest.d.ts
|
||||
* @description BBS 极验相关类型定义文件
|
||||
* @since Beta v0.3.3
|
||||
*/
|
||||
|
||||
declare namespace TGApp.BBS.Geetest {
|
||||
/**
|
||||
* @description 获取极验验证的响应数据
|
||||
* @since Alpha v0.2.2
|
||||
* @extends TGApp.BBS.Response.Base
|
||||
* @interface getResponse
|
||||
* @property {getData} data - 极验验证的响应数据
|
||||
* @return getGeetest
|
||||
*/
|
||||
export interface getResponse extends TGApp.BBS.Response.Base {
|
||||
data: getData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 极验验证的响应数据
|
||||
* @since Alpha v0.2.2
|
||||
* @interface getData
|
||||
* @property {string} gt - 极验验证 gt
|
||||
* @property {string} challenge - 极验验证 challenge
|
||||
* @property {number} new_captcha - 极验验证 new_captcha
|
||||
* @property {number} success - 极验验证 success
|
||||
* @return getData
|
||||
*/
|
||||
export interface getData {
|
||||
gt: string;
|
||||
challenge: string;
|
||||
new_captcha: number;
|
||||
success: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 极验验证的请求数据
|
||||
* @since Alpha v0.2.2
|
||||
* @interface postData
|
||||
* @property {string} challenge - 极验验证 challenge
|
||||
* @property {string} validate - 极验验证 validate
|
||||
* @return postData
|
||||
*/
|
||||
export interface postData {
|
||||
challenge: string;
|
||||
validate: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 极验验证的请求方法-请求参数
|
||||
* @since Beta v0.3.3
|
||||
* @interface InitGeetestParams
|
||||
* @property {string} gt - 极验验证 gt
|
||||
* @property {string} challenge - 极验验证 challenge
|
||||
* @property {boolean} offline - 极验验证 offline
|
||||
* @property {boolean} new_captcha - 极验验证 new_captcha
|
||||
* @property {string} product - 极验验证 product
|
||||
* @property {string} width - 极验验证 width
|
||||
* @property {string} area - 极验验证 area
|
||||
* @return InitGeetestParams
|
||||
*/
|
||||
export interface InitGeetestParams {
|
||||
gt: string;
|
||||
challenge: string;
|
||||
offline: boolean;
|
||||
new_captcha: boolean;
|
||||
product: string;
|
||||
width: string;
|
||||
area: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Geetest 插件 captchaObj
|
||||
* @since Beta v0.3.3
|
||||
* @interface GeetestCaptcha
|
||||
* @property {Function} appendTo
|
||||
* @property {Function} getValidate
|
||||
* @property {Function} onSuccess
|
||||
* @property {Function} onClose
|
||||
* @return GeetestCaptcha
|
||||
*/
|
||||
export interface GeetestCaptcha {
|
||||
appendTo: (selector: string) => void;
|
||||
getValidate: () => GeetestValidate;
|
||||
onSuccess: (callback: () => void) => void;
|
||||
onClose: (callback: () => void) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Geetest 插件 validate
|
||||
* @since Beta v0.3.3
|
||||
* @interface GeetestValidate
|
||||
* @property {string} geetest_challenge
|
||||
* @property {string} geetest_validate
|
||||
* @property {string} geetest_seccode
|
||||
* @return GeetestValidate
|
||||
*/
|
||||
export interface GeetestValidate {
|
||||
geetest_challenge: string;
|
||||
geetest_validate: string;
|
||||
geetest_seccode: string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 设置全局 initGeetest 方法
|
||||
* @param {TGApp.BBS.Geetest.InitGeetestParams} params 极验验证的请求方法-请求参数
|
||||
* @param callback 极验验证的请求方法-回调函数
|
||||
* @return {void}
|
||||
*/
|
||||
declare function initGeetest(
|
||||
params: TGApp.BBS.Geetest.InitGeetestParams,
|
||||
callback: (captchaObj: TGApp.BBS.Geetest.GeetestCaptcha) => void,
|
||||
): void;
|
||||
@@ -20,7 +20,6 @@ import getSyncAvatarDetail from "./getSyncAvatarDetail";
|
||||
import getSyncAvatarListAll from "./getSyncAvatarListAll";
|
||||
import { getTokensByLoginTicket } from "./getTokens";
|
||||
import { getUserInfoByCookie } from "./getUserInfo";
|
||||
import { getVerification, submitVerification } from "./operVerification";
|
||||
import { verifyLToken } from "./verifyLToken";
|
||||
|
||||
const TGRequest = {
|
||||
@@ -58,10 +57,6 @@ const TGRequest = {
|
||||
getSyncAvatarListAll,
|
||||
getSyncAvatarDetail,
|
||||
},
|
||||
verification: {
|
||||
get: getVerification,
|
||||
verify: submitVerification,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
/**
|
||||
* @file src web request operVerification.ts
|
||||
* @description 验证码操作请求函数
|
||||
* @since Beta v0.3.4
|
||||
*/
|
||||
|
||||
import { http } from "@tauri-apps/api";
|
||||
|
||||
import { getDeviceID } from "../../utils/toolFunc";
|
||||
import TGUtils from "../utils/TGUtils";
|
||||
|
||||
/**
|
||||
* @description 发起验证请求
|
||||
* @since Beta v0.3.3
|
||||
* @param {string} Ltoken ltoken
|
||||
* @param {string} Ltuid ltuid
|
||||
* @return {Promise<TGApp.Plugins.Geetest.getData|TGApp.BBS.Response.Base>} 验证码参数
|
||||
*/
|
||||
export async function getVerification(
|
||||
Ltoken: string,
|
||||
Ltuid: string,
|
||||
): Promise<TGApp.BBS.Geetest.getData | TGApp.BBS.Response.Base> {
|
||||
const url = "https://api-takumi-record.mihoyo.com/game_record/app/card/wapi/createVerification";
|
||||
const cookie = {
|
||||
ltoken: Ltoken,
|
||||
ltuid: Ltuid,
|
||||
};
|
||||
const params = { is_high: "true" };
|
||||
const header = TGUtils.User.getHeader(cookie, "GET", params, "common");
|
||||
return await http
|
||||
.fetch<TGApp.BBS.Geetest.getResponse>(url, {
|
||||
method: "GET",
|
||||
headers: header,
|
||||
query: params,
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.data.retcode !== 0) return res.data;
|
||||
return res.data.data;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 将验证完的参数提交给米游社
|
||||
* @since Beta v0.3.3
|
||||
* @todo 待测试
|
||||
* @param {Record<string, string>} cookie cookie
|
||||
* @param {TGApp.BBS.Geetest.GeetestValidate} validate 验证码参数
|
||||
* @return {Promise<TGApp.BBS.Response.Base>} 提交结果
|
||||
*/
|
||||
export async function submitVerification(
|
||||
cookie: Record<string, string>,
|
||||
validate: TGApp.BBS.Geetest.GeetestValidate,
|
||||
): Promise<TGApp.BBS.Response.Base> {
|
||||
const url = "https://api-takumi-record.mihoyo.com/game_record/app/card/wapi/verifyVerification";
|
||||
const data = {
|
||||
geetest_challenge: validate.geetest_challenge,
|
||||
geetest_validate: validate.geetest_validate,
|
||||
geetest_seccode: validate.geetest_seccode,
|
||||
};
|
||||
console.log(data);
|
||||
const header = TGUtils.User.getHeader(cookie, "POST", data, "common");
|
||||
const reqHeader = {
|
||||
...header,
|
||||
host: "api-takumi-record.mihoyo.com",
|
||||
origin: "https://webstatic.mihoyo.com",
|
||||
"sec-fetch-dest": "empty",
|
||||
"sec-fetch-mode": "cors",
|
||||
"sec-fetch-site": "same-site",
|
||||
"x-rpc-device_id": getDeviceID(),
|
||||
"x-rpc-page": "3.1.3_#/ys",
|
||||
};
|
||||
console.log(reqHeader);
|
||||
return await http
|
||||
.fetch<TGApp.BBS.Response.Base>(url, {
|
||||
method: "POST",
|
||||
headers: reqHeader,
|
||||
body: http.Body.json(data),
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res.data);
|
||||
return res.data;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user