diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2021-04-26 12:47:54 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2021-04-26 12:47:54 +0900 |
| commit | 77ccf3b929e46f6df1222f70fff936cab449fe21 (patch) | |
| tree | faba0cca66aeb041e1a8f12be6e9f88780f3bcce /src/client/components | |
| parent | Fix #7480 (diff) | |
| download | misskey-77ccf3b929e46f6df1222f70fff936cab449fe21.tar.gz misskey-77ccf3b929e46f6df1222f70fff936cab449fe21.tar.bz2 misskey-77ccf3b929e46f6df1222f70fff936cab449fe21.zip | |
Fix #7483
Diffstat (limited to 'src/client/components')
| -rw-r--r-- | src/client/components/captcha.vue | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/client/components/captcha.vue b/src/client/components/captcha.vue index 26215df09d..5da8ede3b9 100644 --- a/src/client/components/captcha.vue +++ b/src/client/components/captcha.vue @@ -6,7 +6,7 @@ </template> <script lang="ts"> -import { defineComponent } from 'vue'; +import { defineComponent, PropType } from 'vue'; type Captcha = { render(container: string | Node, options: { @@ -32,7 +32,7 @@ declare global { export default defineComponent({ props: { provider: { - type: String, + type: String as PropType<CaptchaProvider>, required: true, }, sitekey: { @@ -51,19 +51,25 @@ export default defineComponent({ }, computed: { - loaded() { - return !!window[this.provider as CaptchaProvider]; + variable(): string { + switch (this.provider) { + case 'hcaptcha': return 'hcaptcha'; + case 'recaptcha': return 'grecaptcha'; + } + }, + loaded(): boolean { + return !!window[this.variable]; }, - src() { + src(): string { const endpoint = ({ hcaptcha: 'https://hcaptcha.com/1', recaptcha: 'https://www.recaptcha.net/recaptcha', - } as Record<PropertyKey, unknown>)[this.provider]; + } as Record<CaptchaProvider, string>)[this.provider]; - return `${typeof endpoint == 'string' ? endpoint : 'about:invalid'}/api.js?render=explicit`; + return `${typeof endpoint === 'string' ? endpoint : 'about:invalid'}/api.js?render=explicit`; }, - captcha() { - return window[this.provider as CaptchaProvider] || {} as unknown as Captcha; + captcha(): Captcha { + return window[this.variable] || {} as unknown as Captcha; }, }, @@ -94,7 +100,7 @@ export default defineComponent({ methods: { reset() { - this.captcha?.reset(); + if (this.captcha?.reset) this.captcha.reset(); }, requestRender() { if (this.captcha.render && this.$refs.captcha instanceof Element) { |