From 70d710c9a9199c4ab017de065ec6e69400afc22a Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 16 May 2019 16:08:50 +0900 Subject: 管理画面でreCAPTCHAのプレビューを表示するように MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/app/admin/views/instance.vue | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src') diff --git a/src/client/app/admin/views/instance.vue b/src/client/app/admin/views/instance.vue index 3ac4d6d721..72ae3384b5 100644 --- a/src/client/app/admin/views/instance.vue +++ b/src/client/app/admin/views/instance.vue @@ -165,6 +165,10 @@ +
+
{{ $t('recaptcha-preview') }}
+
+
{{ $t('save') }}
@@ -376,6 +380,34 @@ export default Vue.extend({ }); }, + mounted() { + const renderRecaptchaPreview = () => { + if (!(window as any).grecaptcha) return; + if (!this.$refs.recaptcha) return; + if (!this.recaptchaSiteKey) return; + (window as any).grecaptcha.render(this.$refs.recaptcha, { + sitekey: this.recaptchaSiteKey + }); + }; + + window.onRecaotchaLoad = () => { + renderRecaptchaPreview(); + }; + + const head = document.getElementsByTagName('head')[0]; + const script = document.createElement('script'); + script.setAttribute('src', 'https://www.google.com/recaptcha/api.js?onload=onRecaotchaLoad'); + head.appendChild(script); + + this.$watch('enableRecaptcha', () => { + renderRecaptchaPreview(); + }); + + this.$watch('recaptchaSiteKey', () => { + renderRecaptchaPreview(); + }); + }, + methods: { invite() { this.$root.api('admin/invite').then(x => { -- cgit v1.2.3-freya