Skip to content

Commit

Permalink
try cfturnstile-vue3
Browse files Browse the repository at this point in the history
  • Loading branch information
sudoskys committed May 13, 2024
1 parent 23933db commit 07e9821
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 21 deletions.
18 changes: 18 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
"preview": "vite preview"
},
"dependencies": {
"@astrianz/cfturnstile-vue3": "^0.0.6",
"@mcaptcha/core-glue": "^0.1.0-alpha-5",
"axios": "^1.6.8",
"cfturnstile-vue3": "^1.0.0",
"vue": "^3.4.21",
"vue-router": "^4.3.2",
"vue-tg": "^0.6.1",
Expand Down
24 changes: 9 additions & 15 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import {computed, reactive, ref, watch} from "vue";
import {useRoute} from 'vue-router';
import axios from 'axios';
import VueTurnstile from 'vue-turnstile';
import Turnstile from 'cfturnstile-vue3';
import Puzzles from "./components/Puzzles.vue";
import {useWebApp, useWebAppBiometricManager, useWebAppPopup} from "vue-tg";
import {useGyroscopeExists} from "./hook/useGyroscopeExists.ts";
Expand Down Expand Up @@ -240,6 +240,10 @@ const initBiometric = () => {
)
}
const verify_cloudflare = (token: string) => {
turnstile_token.value = token
}
// 逻辑区域
WebAppBiometricManager.onBiometricManagerUpdated(() => {
console.log('Biometric manager updated')
Expand Down Expand Up @@ -331,20 +335,10 @@ const imageSrc = `https://avatars.githubusercontent.com/u/${user}?s=300&v=4`
<v-card-text
v-if="isCloudflareFailed.show_turnstile"
>
<vue-turnstile
v-model="turnstile_token"
:site-key="cloudflareSiteKey"
@token="authCloudflare"
@error="(error) => {
isCloudflareFailed.status = true
isCloudflareFailed.message = `Cloudflare error: ${error}`
}"
@unsupported="() => {
isCloudflareFailed.status = true
isCloudflareFailed.message = 'Cloudflare not supported'
isCloudflareFailed.show_turnstile = false
}"
></vue-turnstile>
<Turnstile
:sitekey="cloudflareSiteKey"
@verify="verify_cloudflare"
/>
</v-card-text>
<v-card-text class="bg-surface-light pt-4" v-if="isCloudflareFailed.status">
{{ isCloudflareFailed.message }}
Expand Down
21 changes: 16 additions & 5 deletions frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,34 @@
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"lib": [
"ES2020",
"DOM",
"DOM.Iterable"
],
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",

"noImplicitAny": false,
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"],
"references": [{ "path": "./tsconfig.node.json" }]
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue"
],
"references": [
{
"path": "./tsconfig.node.json"
}
]
}
4 changes: 3 additions & 1 deletion frontend/tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@
"allowSyntheticDefaultImports": true,
"strict": true
},
"include": ["vite.config.ts"]
"include": [
"vite.config.ts"
]
}

0 comments on commit 07e9821

Please sign in to comment.