File tree 2 files changed +26
-1
lines changed
2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 1
1
VUE_APP_SELF_HOST = https://web-tech.tw/openchat
2
2
VUE_APP_OCJI_HOST = https://web-tech.tw/recv/openchat
3
3
4
+ VUE_APP_TURNSTILE_SITE_KEY = " 0x4AAAAAAAr6LY1hBUbTBkVA"
5
+
4
6
VUE_APP_SARA_INTE_HOST = https://web-tech.tw/sara
5
7
VUE_APP_SARA_RECV_HOST = https://web-tech.tw/recv/sara
6
8
VUE_APP_SARA_TOKEN_NAME = unified_token
Original file line number Diff line number Diff line change 39
39
</button >
40
40
</div >
41
41
</div >
42
+ <div v-show =" !accept" class =" checkbox my-3" >
43
+ <div id =" captcha" data-theme =" light" ></div >
44
+ </div >
42
45
<div class =" flex justify-end mt-4" >
43
46
<button
44
47
:disabled =" !ready"
@@ -76,10 +79,12 @@ export default {
76
79
description: null ,
77
80
url: null
78
81
},
82
+ captcha: null ,
79
83
secret: null ,
80
84
status: null ,
81
85
accept: false ,
82
- ready: true
86
+ ready: true ,
87
+ turnstileScript: null ,
83
88
}),
84
89
computed: {
85
90
icon () {
@@ -111,6 +116,7 @@ export default {
111
116
this .ready = false ;
112
117
const form = new URLSearchParams ();
113
118
form .set (' slug' , this .code );
119
+ form .set (' captcha' , this .captcha );
114
120
try {
115
121
const xhr = await this .$axios .post (' application' , form)
116
122
this .ready = true ;
@@ -129,7 +135,24 @@ export default {
129
135
}
130
136
}
131
137
},
138
+ mounted () {
139
+ document .head .appendChild (this .turnstileScript );
140
+ },
141
+ beforeDestroy () {
142
+ document .head .removeChild (this .turnstileScript );
143
+ },
132
144
created () {
145
+ const turnstileScriptUrl = " https://challenges.cloudflare.com/turnstile/v0/api.js?onload=loadTurnstile" ;
146
+ this .turnstileScript = document .createElement (" script" );
147
+ this .turnstileScript .setAttribute (" src" , turnstileScriptUrl);
148
+ window .loadTurnstile = () => {
149
+ window .turnstile .render (" #captcha" , {
150
+ sitekey: process .env .VUE_APP_TURNSTILE_SITE_KEY ,
151
+ callback : (token ) => {
152
+ this .captcha = token;
153
+ },
154
+ });
155
+ };
133
156
if (this .code in data) {
134
157
this .info = data[this .code ];
135
158
} else {
You can’t perform that action at this time.
0 commit comments