This commit is contained in:
archer
2023-07-20 10:01:45 +08:00
parent 62ee28b130
commit 75c8c42530
8 changed files with 33 additions and 20 deletions

View File

@@ -1,12 +1,13 @@
import axios from 'axios';
import { Obj2Query } from '../tools';
export const getClientToken = (googleVerKey: string) => {
if (typeof window.grecaptcha === 'undefined' || !window.grecaptcha?.ready) return '';
export const getClientToken = (googleClientVerKey?: string) => {
if (!googleClientVerKey || typeof window.grecaptcha === 'undefined' || !window.grecaptcha?.ready)
return '';
return new Promise<string>((resolve, reject) => {
window.grecaptcha.ready(async () => {
try {
const token = await window.grecaptcha.execute(googleVerKey, {
const token = await window.grecaptcha.execute(googleClientVerKey, {
action: 'submit'
});
resolve(token);