[perf][bug] disable no-ssr and fix hCaptcha rendering in SSR

This commit is contained in:
Andrea 2022-02-13 23:19:06 +01:00
parent e8823c320a
commit ebb408ae8d
4 changed files with 17 additions and 17 deletions

View File

@ -1,5 +1,5 @@
<template>
<div style="height: 73px"></div>
<div style="height: 73px" @click="render"></div>
</template>
<script>
@ -11,19 +11,19 @@
value: {},
},
async mounted() {
if (!process.client) {
return false;
}
await this.$loadScript('hcaptcha', 'https://js.hcaptcha.com/1/api.js');
if (!process.client) { return; }
await this.$loadScript('hcaptcha', `https://js.hcaptcha.com/1/api.js?hl=${this.config.locale}`);
setTimeout(() => { this.render() }, 500);
},
methods: {
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,
});
},
methods: {
solved(token) {
this.$emit('input', token);
},

View File

@ -24,7 +24,7 @@
<Icon v="info-circle"/>
<T>captcha.reason</T>
</p>
<Captcha class="h-captcha" v-model="captchaToken"/>
<Captcha v-model="captchaToken"/>
<button class="btn btn-primary mt-3 d-none d-md-block" :disabled="!canInit">
<Icon v="sign-in"/>
<T>user.login.action</T>

View File

@ -51,7 +51,7 @@
sorter();
if (process.env.NODE_ENV === 'production') {
//this.monkeyPatchBlockTrackers(['google-analytics.com', 'tkr.arc.io', 'browser.sentry-cdn.com',]);
this.monkeyPatchBlockTrackers(['google-analytics.com', 'tkr.arc.io', 'browser.sentry-cdn.com',]);
this.$loadScript('arc', 'https://arc.io/widget.min.js#yHdNYRkC');
}

View File

@ -14,8 +14,8 @@ const isBrowser = (userAgent) => {
}
export default function(req, res, next) {
if (process.env.NODE_ENV === 'production' && !req.url.startsWith('/card/@')) {
res.spa = isBrowser(req.headers['user-agent']) || isHighLoadTime(process.env.LOCALE);
}
// if (process.env.NODE_ENV === 'production' && !req.url.startsWith('/card/@')) {
// res.spa = isBrowser(req.headers['user-agent']) || isHighLoadTime(process.env.LOCALE);
// }
next();
}