[perf][bug] disable no-ssr and fix hCaptcha rendering in SSR
This commit is contained in:
parent
e8823c320a
commit
ebb408ae8d
|
@ -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');
|
||||
|
||||
window.hcaptcha.render(this.$el, {
|
||||
sitekey: process.env.HCAPTCHA_SITEKEY,
|
||||
theme: this.detectDark() ? 'dark' : 'light',
|
||||
callback: this.solved,
|
||||
});
|
||||
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,
|
||||
});
|
||||
},
|
||||
solved(token) {
|
||||
this.$emit('input', token);
|
||||
},
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Reference in New Issue