2021-04-22 16:29:33 +03:00
|
|
|
<template>
|
2022-01-04 14:16:41 +02:00
|
|
|
<div>
|
2021-04-22 16:29:33 +03:00
|
|
|
<FormSuspense :p="init">
|
2023-01-06 06:40:17 +02:00
|
|
|
<div class="_gaps_m">
|
2023-01-05 14:04:56 +02:00
|
|
|
<FormRadios v-model="provider">
|
2022-07-20 16:24:26 +03:00
|
|
|
<option :value="null">{{ i18n.ts.none }} ({{ i18n.ts.notRecommended }})</option>
|
2022-01-04 14:16:41 +02:00
|
|
|
<option value="hcaptcha">hCaptcha</option>
|
|
|
|
<option value="recaptcha">reCAPTCHA</option>
|
2022-10-13 03:19:57 +03:00
|
|
|
<option value="turnstile">Turnstile</option>
|
2022-01-04 14:16:41 +02:00
|
|
|
</FormRadios>
|
2021-04-22 16:29:33 +03:00
|
|
|
|
2022-01-04 14:16:41 +02:00
|
|
|
<template v-if="provider === 'hcaptcha'">
|
2023-01-05 14:04:56 +02:00
|
|
|
<FormInput v-model="hcaptchaSiteKey">
|
2022-12-19 12:01:30 +02:00
|
|
|
<template #prefix><i class="ti ti-key"></i></template>
|
2022-07-20 16:24:26 +03:00
|
|
|
<template #label>{{ i18n.ts.hcaptchaSiteKey }}</template>
|
2022-01-04 14:16:41 +02:00
|
|
|
</FormInput>
|
2023-01-05 14:04:56 +02:00
|
|
|
<FormInput v-model="hcaptchaSecretKey">
|
2022-12-19 12:01:30 +02:00
|
|
|
<template #prefix><i class="ti ti-key"></i></template>
|
2022-07-20 16:24:26 +03:00
|
|
|
<template #label>{{ i18n.ts.hcaptchaSecretKey }}</template>
|
2022-01-04 14:16:41 +02:00
|
|
|
</FormInput>
|
2023-01-05 14:04:56 +02:00
|
|
|
<FormSlot>
|
2022-07-20 16:24:26 +03:00
|
|
|
<template #label>{{ i18n.ts.preview }}</template>
|
2021-04-22 16:29:33 +03:00
|
|
|
<MkCaptcha provider="hcaptcha" :sitekey="hcaptchaSiteKey || '10000000-ffff-ffff-ffff-000000000001'"/>
|
2022-01-04 14:16:41 +02:00
|
|
|
</FormSlot>
|
|
|
|
</template>
|
|
|
|
<template v-else-if="provider === 'recaptcha'">
|
2023-01-05 14:04:56 +02:00
|
|
|
<FormInput v-model="recaptchaSiteKey">
|
2022-12-19 12:01:30 +02:00
|
|
|
<template #prefix><i class="ti ti-key"></i></template>
|
2022-07-20 16:24:26 +03:00
|
|
|
<template #label>{{ i18n.ts.recaptchaSiteKey }}</template>
|
2022-01-04 14:16:41 +02:00
|
|
|
</FormInput>
|
2023-01-05 14:04:56 +02:00
|
|
|
<FormInput v-model="recaptchaSecretKey">
|
2022-12-19 12:01:30 +02:00
|
|
|
<template #prefix><i class="ti ti-key"></i></template>
|
2022-07-20 16:24:26 +03:00
|
|
|
<template #label>{{ i18n.ts.recaptchaSecretKey }}</template>
|
2022-01-04 14:16:41 +02:00
|
|
|
</FormInput>
|
2023-01-05 14:04:56 +02:00
|
|
|
<FormSlot v-if="recaptchaSiteKey">
|
2022-07-20 16:24:26 +03:00
|
|
|
<template #label>{{ i18n.ts.preview }}</template>
|
2021-04-22 16:29:33 +03:00
|
|
|
<MkCaptcha provider="recaptcha" :sitekey="recaptchaSiteKey"/>
|
2022-01-04 14:16:41 +02:00
|
|
|
</FormSlot>
|
|
|
|
</template>
|
2022-10-13 03:19:57 +03:00
|
|
|
<template v-else-if="provider === 'turnstile'">
|
2023-01-05 14:04:56 +02:00
|
|
|
<FormInput v-model="turnstileSiteKey">
|
2022-12-19 12:01:30 +02:00
|
|
|
<template #prefix><i class="ti ti-key"></i></template>
|
2022-10-13 03:19:57 +03:00
|
|
|
<template #label>{{ i18n.ts.turnstileSiteKey }}</template>
|
|
|
|
</FormInput>
|
2023-01-05 14:04:56 +02:00
|
|
|
<FormInput v-model="turnstileSecretKey">
|
2022-12-19 12:01:30 +02:00
|
|
|
<template #prefix><i class="ti ti-key"></i></template>
|
2022-10-13 03:19:57 +03:00
|
|
|
<template #label>{{ i18n.ts.turnstileSecretKey }}</template>
|
|
|
|
</FormInput>
|
2023-01-05 14:04:56 +02:00
|
|
|
<FormSlot>
|
2022-10-13 03:19:57 +03:00
|
|
|
<template #label>{{ i18n.ts.preview }}</template>
|
|
|
|
<MkCaptcha provider="turnstile" :sitekey="turnstileSiteKey || '1x00000000000000000000AA'"/>
|
|
|
|
</FormSlot>
|
|
|
|
</template>
|
2021-04-22 16:29:33 +03:00
|
|
|
|
2023-01-06 02:41:14 +02:00
|
|
|
<MkButton primary @click="save"><i class="ti ti-device-floppy"></i> {{ i18n.ts.save }}</MkButton>
|
2022-01-04 14:16:41 +02:00
|
|
|
</div>
|
2021-04-22 16:29:33 +03:00
|
|
|
</FormSuspense>
|
2022-01-04 14:16:41 +02:00
|
|
|
</div>
|
2021-04-22 16:29:33 +03:00
|
|
|
</template>
|
|
|
|
|
2022-05-14 15:34:50 +03:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { defineAsyncComponent } from 'vue';
|
2022-01-04 14:16:41 +02:00
|
|
|
import FormRadios from '@/components/form/radios.vue';
|
|
|
|
import FormInput from '@/components/form/input.vue';
|
2023-01-06 02:41:14 +02:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2022-01-04 14:16:41 +02:00
|
|
|
import FormSuspense from '@/components/form/suspense.vue';
|
|
|
|
import FormSlot from '@/components/form/slot.vue';
|
2021-11-11 19:02:25 +02:00
|
|
|
import * as os from '@/os';
|
2022-02-28 20:51:31 +02:00
|
|
|
import { fetchInstance } from '@/instance';
|
2022-07-20 16:24:26 +03:00
|
|
|
import { i18n } from '@/i18n';
|
2021-04-22 16:29:33 +03:00
|
|
|
|
2022-08-30 18:24:33 +03:00
|
|
|
const MkCaptcha = defineAsyncComponent(() => import('@/components/MkCaptcha.vue'));
|
2021-04-22 16:29:33 +03:00
|
|
|
|
2022-05-14 17:24:45 +03:00
|
|
|
let provider = $ref(null);
|
2022-05-14 15:34:50 +03:00
|
|
|
let hcaptchaSiteKey: string | null = $ref(null);
|
|
|
|
let hcaptchaSecretKey: string | null = $ref(null);
|
|
|
|
let recaptchaSiteKey: string | null = $ref(null);
|
|
|
|
let recaptchaSecretKey: string | null = $ref(null);
|
2022-10-13 03:19:57 +03:00
|
|
|
let turnstileSiteKey: string | null = $ref(null);
|
|
|
|
let turnstileSecretKey: string | null = $ref(null);
|
2021-04-22 16:29:33 +03:00
|
|
|
|
2022-05-14 15:34:50 +03:00
|
|
|
async function init() {
|
|
|
|
const meta = await os.api('admin/meta');
|
|
|
|
hcaptchaSiteKey = meta.hcaptchaSiteKey;
|
|
|
|
hcaptchaSecretKey = meta.hcaptchaSecretKey;
|
|
|
|
recaptchaSiteKey = meta.recaptchaSiteKey;
|
|
|
|
recaptchaSecretKey = meta.recaptchaSecretKey;
|
2022-10-13 03:19:57 +03:00
|
|
|
turnstileSiteKey = meta.turnstileSiteKey;
|
|
|
|
turnstileSecretKey = meta.turnstileSecretKey;
|
2021-04-22 16:29:33 +03:00
|
|
|
|
2022-10-13 03:19:57 +03:00
|
|
|
provider = meta.enableHcaptcha ? 'hcaptcha' : meta.enableRecaptcha ? 'recaptcha' : meta.enableTurnstile ? 'turnstile' : null;
|
2022-05-14 15:34:50 +03:00
|
|
|
}
|
2021-04-22 16:29:33 +03:00
|
|
|
|
2022-05-14 15:34:50 +03:00
|
|
|
function save() {
|
|
|
|
os.apiWithDialog('admin/update-meta', {
|
2022-07-04 17:17:07 +03:00
|
|
|
enableHcaptcha: provider === 'hcaptcha',
|
2022-05-14 15:34:50 +03:00
|
|
|
hcaptchaSiteKey,
|
|
|
|
hcaptchaSecretKey,
|
2022-07-04 17:17:07 +03:00
|
|
|
enableRecaptcha: provider === 'recaptcha',
|
2022-05-14 15:34:50 +03:00
|
|
|
recaptchaSiteKey,
|
|
|
|
recaptchaSecretKey,
|
2022-10-13 03:19:57 +03:00
|
|
|
enableTurnstile: provider === 'turnstile',
|
|
|
|
turnstileSiteKey,
|
|
|
|
turnstileSecretKey,
|
2022-05-14 15:34:50 +03:00
|
|
|
}).then(() => {
|
|
|
|
fetchInstance();
|
|
|
|
});
|
|
|
|
}
|
2021-04-22 16:29:33 +03:00
|
|
|
</script>
|