This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2021-08-07 03:03:49 -07:00
|
|
|
<template>
|
2022-02-13 14:19:06 -08:00
|
|
|
<div style="height: 73px" @click="render"></div>
|
2021-08-07 03:03:49 -07:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import dark from "../plugins/dark";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
mixins: [dark],
|
|
|
|
props: {
|
|
|
|
value: {},
|
|
|
|
},
|
2021-08-09 23:50:22 -07:00
|
|
|
async mounted() {
|
2022-02-13 14:19:06 -08:00
|
|
|
if (!process.client) { return; }
|
|
|
|
await this.$loadScript('hcaptcha', `https://js.hcaptcha.com/1/api.js?hl=${this.config.locale}`);
|
|
|
|
setTimeout(() => { this.render() }, 500);
|
2021-08-07 03:03:49 -07:00
|
|
|
},
|
2021-08-09 23:50:22 -07:00
|
|
|
methods: {
|
2022-02-13 14:19:06 -08:00
|
|
|
render() {
|
|
|
|
if (!window.hcaptcha || this.$el.innerHTML.length) { return; }
|
|
|
|
window.hcaptcha.render(this.$el, {
|
|
|
|
sitekey: process.env.HCAPTCHA_SITEKEY,
|
|
|
|
theme: this.detectDark() ? 'dark' : 'light',
|
|
|
|
callback: this.solved,
|
|
|
|
});
|
|
|
|
},
|
2021-08-09 23:50:22 -07:00
|
|
|
solved(token) {
|
|
|
|
this.$emit('input', token);
|
|
|
|
},
|
|
|
|
}
|
2021-08-07 03:03:49 -07:00
|
|
|
}
|
|
|
|
</script>
|