2021-04-22 22:29:33 +09:00
|
|
|
<template>
|
2022-01-04 21:16:41 +09:00
|
|
|
<div>
|
2021-04-22 22:29:33 +09:00
|
|
|
<FormSuspense :p="init">
|
2022-01-04 21:16:41 +09:00
|
|
|
<div class="_formRoot">
|
|
|
|
<FormRadios v-model="provider" class="_formBlock">
|
2022-07-20 22:24:26 +09:00
|
|
|
<option :value="null">{{ i18n.ts.none }} ({{ i18n.ts.notRecommended }})</option>
|
2022-01-04 21:16:41 +09:00
|
|
|
<option value="hcaptcha">hCaptcha</option>
|
|
|
|
<option value="recaptcha">reCAPTCHA</option>
|
|
|
|
</FormRadios>
|
2021-04-22 22:29:33 +09:00
|
|
|
|
2022-01-04 21:16:41 +09:00
|
|
|
<template v-if="provider === 'hcaptcha'">
|
|
|
|
<FormInput v-model="hcaptchaSiteKey" class="_formBlock">
|
|
|
|
<template #prefix><i class="fas fa-key"></i></template>
|
2022-07-20 22:24:26 +09:00
|
|
|
<template #label>{{ i18n.ts.hcaptchaSiteKey }}</template>
|
2022-01-04 21:16:41 +09:00
|
|
|
</FormInput>
|
|
|
|
<FormInput v-model="hcaptchaSecretKey" class="_formBlock">
|
|
|
|
<template #prefix><i class="fas fa-key"></i></template>
|
2022-07-20 22:24:26 +09:00
|
|
|
<template #label>{{ i18n.ts.hcaptchaSecretKey }}</template>
|
2022-01-04 21:16:41 +09:00
|
|
|
</FormInput>
|
|
|
|
<FormSlot class="_formBlock">
|
2022-07-20 22:24:26 +09:00
|
|
|
<template #label>{{ i18n.ts.preview }}</template>
|
2021-04-22 22:29:33 +09:00
|
|
|
<MkCaptcha provider="hcaptcha" :sitekey="hcaptchaSiteKey || '10000000-ffff-ffff-ffff-000000000001'"/>
|
2022-01-04 21:16:41 +09:00
|
|
|
</FormSlot>
|
|
|
|
</template>
|
|
|
|
<template v-else-if="provider === 'recaptcha'">
|
|
|
|
<FormInput v-model="recaptchaSiteKey" class="_formBlock">
|
|
|
|
<template #prefix><i class="fas fa-key"></i></template>
|
2022-07-20 22:24:26 +09:00
|
|
|
<template #label>{{ i18n.ts.recaptchaSiteKey }}</template>
|
2022-01-04 21:16:41 +09:00
|
|
|
</FormInput>
|
|
|
|
<FormInput v-model="recaptchaSecretKey" class="_formBlock">
|
|
|
|
<template #prefix><i class="fas fa-key"></i></template>
|
2022-07-20 22:24:26 +09:00
|
|
|
<template #label>{{ i18n.ts.recaptchaSecretKey }}</template>
|
2022-01-04 21:16:41 +09:00
|
|
|
</FormInput>
|
|
|
|
<FormSlot v-if="recaptchaSiteKey" class="_formBlock">
|
2022-07-20 22:24:26 +09:00
|
|
|
<template #label>{{ i18n.ts.preview }}</template>
|
2021-04-22 22:29:33 +09:00
|
|
|
<MkCaptcha provider="recaptcha" :sitekey="recaptchaSiteKey"/>
|
2022-01-04 21:16:41 +09:00
|
|
|
</FormSlot>
|
|
|
|
</template>
|
2021-04-22 22:29:33 +09:00
|
|
|
|
2022-07-20 22:24:26 +09:00
|
|
|
<FormButton primary @click="save"><i class="fas fa-save"></i> {{ i18n.ts.save }}</FormButton>
|
2022-01-04 21:16:41 +09:00
|
|
|
</div>
|
2021-04-22 22:29:33 +09:00
|
|
|
</FormSuspense>
|
2022-01-04 21:16:41 +09:00
|
|
|
</div>
|
2021-04-22 22:29:33 +09:00
|
|
|
</template>
|
|
|
|
|
2022-05-14 21:34:50 +09:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { defineAsyncComponent } from 'vue';
|
2022-01-04 21:16:41 +09: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-12 02:02:25 +09:00
|
|
|
import * as os from '@/os';
|
2022-03-01 03:51:31 +09:00
|
|
|
import { fetchInstance } from '@/instance';
|
2022-07-20 22:24:26 +09:00
|
|
|
import { i18n } from '@/i18n';
|
2021-04-22 22:29:33 +09:00
|
|
|
|
2022-05-14 21:34:50 +09:00
|
|
|
const MkCaptcha = defineAsyncComponent(() => import('@/components/captcha.vue'));
|
2021-04-22 22:29:33 +09:00
|
|
|
|
2022-05-14 23:24:45 +09:00
|
|
|
let provider = $ref(null);
|
2022-05-14 21:34:50 +09: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);
|
2021-04-22 22:29:33 +09:00
|
|
|
|
2022-05-14 21:34:50 +09:00
|
|
|
async function init() {
|
|
|
|
const meta = await os.api('admin/meta');
|
|
|
|
hcaptchaSiteKey = meta.hcaptchaSiteKey;
|
|
|
|
hcaptchaSecretKey = meta.hcaptchaSecretKey;
|
|
|
|
recaptchaSiteKey = meta.recaptchaSiteKey;
|
|
|
|
recaptchaSecretKey = meta.recaptchaSecretKey;
|
2021-04-22 22:29:33 +09:00
|
|
|
|
2022-07-04 23:17:07 +09:00
|
|
|
provider = meta.enableHcaptcha ? 'hcaptcha' : meta.enableRecaptcha ? 'recaptcha' : null;
|
2022-05-14 21:34:50 +09:00
|
|
|
}
|
2021-04-22 22:29:33 +09:00
|
|
|
|
2022-05-14 21:34:50 +09:00
|
|
|
function save() {
|
|
|
|
os.apiWithDialog('admin/update-meta', {
|
2022-07-04 23:17:07 +09:00
|
|
|
enableHcaptcha: provider === 'hcaptcha',
|
2022-05-14 21:34:50 +09:00
|
|
|
hcaptchaSiteKey,
|
|
|
|
hcaptchaSecretKey,
|
2022-07-04 23:17:07 +09:00
|
|
|
enableRecaptcha: provider === 'recaptcha',
|
2022-05-14 21:34:50 +09:00
|
|
|
recaptchaSiteKey,
|
|
|
|
recaptchaSecretKey,
|
|
|
|
}).then(() => {
|
|
|
|
fetchInstance();
|
|
|
|
});
|
|
|
|
}
|
2021-04-22 22:29:33 +09:00
|
|
|
</script>
|