2021-04-22 15:29:33 +02:00
|
|
|
<template>
|
2022-01-04 13:16:41 +01:00
|
|
|
<div>
|
2021-04-22 15:29:33 +02:00
|
|
|
<FormSuspense :p="init">
|
2022-01-04 13:16:41 +01:00
|
|
|
<div class="_formRoot">
|
|
|
|
<FormRadios v-model="provider" class="_formBlock">
|
|
|
|
<option :value="null">{{ $ts.none }} ({{ $ts.notRecommended }})</option>
|
|
|
|
<option value="hcaptcha">hCaptcha</option>
|
|
|
|
<option value="recaptcha">reCAPTCHA</option>
|
|
|
|
</FormRadios>
|
2021-04-22 15:29:33 +02:00
|
|
|
|
2022-01-04 13:16:41 +01:00
|
|
|
<template v-if="provider === 'hcaptcha'">
|
|
|
|
<FormInput v-model="hcaptchaSiteKey" class="_formBlock">
|
|
|
|
<template #prefix><i class="fas fa-key"></i></template>
|
|
|
|
<template #label>{{ $ts.hcaptchaSiteKey }}</template>
|
|
|
|
</FormInput>
|
|
|
|
<FormInput v-model="hcaptchaSecretKey" class="_formBlock">
|
|
|
|
<template #prefix><i class="fas fa-key"></i></template>
|
|
|
|
<template #label>{{ $ts.hcaptchaSecretKey }}</template>
|
|
|
|
</FormInput>
|
|
|
|
<FormSlot class="_formBlock">
|
|
|
|
<template #label>{{ $ts.preview }}</template>
|
2021-04-22 15:29:33 +02:00
|
|
|
<MkCaptcha provider="hcaptcha" :sitekey="hcaptchaSiteKey || '10000000-ffff-ffff-ffff-000000000001'"/>
|
2022-01-04 13:16:41 +01:00
|
|
|
</FormSlot>
|
|
|
|
</template>
|
|
|
|
<template v-else-if="provider === 'recaptcha'">
|
|
|
|
<FormInput v-model="recaptchaSiteKey" class="_formBlock">
|
|
|
|
<template #prefix><i class="fas fa-key"></i></template>
|
|
|
|
<template #label>{{ $ts.recaptchaSiteKey }}</template>
|
|
|
|
</FormInput>
|
|
|
|
<FormInput v-model="recaptchaSecretKey" class="_formBlock">
|
|
|
|
<template #prefix><i class="fas fa-key"></i></template>
|
|
|
|
<template #label>{{ $ts.recaptchaSecretKey }}</template>
|
|
|
|
</FormInput>
|
|
|
|
<FormSlot v-if="recaptchaSiteKey" class="_formBlock">
|
|
|
|
<template #label>{{ $ts.preview }}</template>
|
2021-04-22 15:29:33 +02:00
|
|
|
<MkCaptcha provider="recaptcha" :sitekey="recaptchaSiteKey"/>
|
2022-01-04 13:16:41 +01:00
|
|
|
</FormSlot>
|
|
|
|
</template>
|
2021-04-22 15:29:33 +02:00
|
|
|
|
2022-01-04 13:16:41 +01:00
|
|
|
<FormButton primary @click="save"><i class="fas fa-save"></i> {{ $ts.save }}</FormButton>
|
|
|
|
</div>
|
2021-04-22 15:29:33 +02:00
|
|
|
</FormSuspense>
|
2022-01-04 13:16:41 +01:00
|
|
|
</div>
|
2021-04-22 15:29:33 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineAsyncComponent, defineComponent } from 'vue';
|
2022-01-04 13:16:41 +01:00
|
|
|
import FormRadios from '@/components/form/radios.vue';
|
|
|
|
import FormInput from '@/components/form/input.vue';
|
|
|
|
import FormButton from '@/components/ui/button.vue';
|
|
|
|
import FormSuspense from '@/components/form/suspense.vue';
|
|
|
|
import FormSlot from '@/components/form/slot.vue';
|
2021-11-11 18:02:25 +01:00
|
|
|
import * as os from '@/os';
|
|
|
|
import * as symbols from '@/symbols';
|
2022-02-28 19:51:31 +01:00
|
|
|
import { fetchInstance } from '@/instance';
|
2021-04-22 15:29:33 +02:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
|
|
|
FormRadios,
|
|
|
|
FormInput,
|
|
|
|
FormButton,
|
|
|
|
FormSuspense,
|
2022-01-04 13:16:41 +01:00
|
|
|
FormSlot,
|
2021-11-11 18:02:25 +01:00
|
|
|
MkCaptcha: defineAsyncComponent(() => import('@/components/captcha.vue')),
|
2021-04-22 15:29:33 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
emits: ['info'],
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
[symbols.PAGE_INFO]: {
|
|
|
|
title: this.$ts.botProtection,
|
|
|
|
icon: 'fas fa-shield-alt'
|
|
|
|
},
|
|
|
|
provider: null,
|
|
|
|
enableHcaptcha: false,
|
|
|
|
hcaptchaSiteKey: null,
|
|
|
|
hcaptchaSecretKey: null,
|
|
|
|
enableRecaptcha: false,
|
|
|
|
recaptchaSiteKey: null,
|
|
|
|
recaptchaSecretKey: null,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async init() {
|
|
|
|
const meta = await os.api('meta', { detail: true });
|
|
|
|
this.enableHcaptcha = meta.enableHcaptcha;
|
|
|
|
this.hcaptchaSiteKey = meta.hcaptchaSiteKey;
|
|
|
|
this.hcaptchaSecretKey = meta.hcaptchaSecretKey;
|
|
|
|
this.enableRecaptcha = meta.enableRecaptcha;
|
|
|
|
this.recaptchaSiteKey = meta.recaptchaSiteKey;
|
|
|
|
this.recaptchaSecretKey = meta.recaptchaSecretKey;
|
|
|
|
|
|
|
|
this.provider = this.enableHcaptcha ? 'hcaptcha' : this.enableRecaptcha ? 'recaptcha' : null;
|
|
|
|
|
|
|
|
this.$watch(() => this.provider, () => {
|
|
|
|
this.enableHcaptcha = this.provider === 'hcaptcha';
|
|
|
|
this.enableRecaptcha = this.provider === 'recaptcha';
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
save() {
|
|
|
|
os.apiWithDialog('admin/update-meta', {
|
|
|
|
enableHcaptcha: this.enableHcaptcha,
|
|
|
|
hcaptchaSiteKey: this.hcaptchaSiteKey,
|
|
|
|
hcaptchaSecretKey: this.hcaptchaSecretKey,
|
|
|
|
enableRecaptcha: this.enableRecaptcha,
|
|
|
|
recaptchaSiteKey: this.recaptchaSiteKey,
|
|
|
|
recaptchaSecretKey: this.recaptchaSecretKey,
|
|
|
|
}).then(() => {
|
2022-02-28 19:51:31 +01:00
|
|
|
fetchInstance();
|
2021-04-22 15:29:33 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|