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.
Zaimki/layouts/default.vue

109 lines
3.5 KiB
Vue
Raw Permalink Normal View History

2020-07-22 13:19:23 -07:00
<template>
2021-12-17 07:38:19 -08:00
<div class="body">
<div class="flex-grow-1 vh">
2020-09-23 11:34:35 -07:00
<Header/>
2021-05-13 03:09:08 -07:00
<main class="container">
2021-05-03 07:15:48 -07:00
<Nuxt/>
<ScrollButton/>
</main>
2020-07-22 13:19:23 -07:00
</div>
2021-12-08 08:21:27 -08:00
<Footer/>
<DialogueBox ref="dialogue"/>
2021-01-06 06:21:20 -08:00
<Lightbox/>
2020-07-22 13:19:23 -07:00
</div>
</template>
2020-10-24 13:32:12 -07:00
<script>
import Vue from 'vue';
2021-06-15 03:57:50 -07:00
import dark from "../plugins/dark";
2021-06-18 08:33:25 -07:00
import sorter from "avris-sorter";
import {sleep} from "../src/helpers";
2020-10-24 13:32:12 -07:00
export default {
2021-06-15 03:57:50 -07:00
mixins: [dark],
2020-10-24 13:32:12 -07:00
mounted() {
Vue.prototype.$alert = (message, color='primary') => {
return new Promise((resolve, reject) => {
this.$refs.dialogue.show(false, message, color, resolve, reject);
});
};
Vue.prototype.$confirm = (message = '', color='primary') => {
console.log(this, this.$refs);
2020-10-24 13:32:12 -07:00
return new Promise((resolve, reject) => {
this.$refs.dialogue.show(true, message, color, resolve, reject);
2020-10-24 13:32:12 -07:00
});
};
Vue.prototype.$post = (url, data, options = {}, timeout = 30000) => {
return new Promise((resolve, reject) => {
this.$axios.$post(url, data, {...options, timeout})
.then(data => resolve(data))
.catch(async e => {
console.error(e);
await this.$alert(this.$t('error.generic'), 'danger');
reject();
});
});
2021-06-09 23:45:13 -07:00
};
this.setIsDark(this.detectDark());
2021-06-18 08:33:25 -07:00
2021-12-30 06:09:11 -08:00
if (!process.client) { return; }
sorter();
2021-07-10 10:02:08 -07:00
if (process.env.NODE_ENV === 'production') {
this.monkeyPatchBlockTrackers(['google-analytics.com', 'tkr.arc.io', 'browser.sentry-cdn.com',]);
2021-07-10 10:02:08 -07:00
this.$loadScript('arc', 'https://arc.io/widget.min.js#yHdNYRkC');
}
this.confirmAge();
2021-12-30 06:09:11 -08:00
},
methods: {
monkeyPatchBlockTrackers(trackers) {
const isTracker = (url) => trackers.filter(t => url.includes(t)).length > 0;
const origFetch = window.fetch;
window.fetch = async (...args) => {
if (isTracker(args[0])) { return; }
return await origFetch(...args);
};
const origInsertBefore = window.Node.prototype.insertBefore;
window.Node.prototype.insertBefore = function (...args) {
if (args[0] && args[0].tagName === 'SCRIPT' && isTracker(args[0].src)) { return; }
origInsertBefore.call(this, ...args);
};
},
async confirmAge() {
if (!this.$te('footer.ageLimit') || localStorage.getItem('ageConfirmed')) {
return;
}
while (this.$refs.dialogue === undefined) {
await sleep(100);
}
await this.$alert(this.$t('footer.ageLimit'));
localStorage.setItem('ageConfirmed', '1');
}
2021-12-30 06:09:11 -08:00
},
2020-10-24 13:32:12 -07:00
}
</script>
2020-07-22 13:19:23 -07:00
<style lang="scss">
@import "assets/style";
2021-06-18 08:55:50 -07:00
@import "~avris-sorter/dist/Sorter.min.css";
2021-07-10 07:46:29 -07:00
@include media-breakpoint-up('lg', $grid-breakpoints) {
.body {
margin-top: $header-margin;
}
.sticky-top {
top: $header-height - 1px;
}
}
2021-12-17 07:38:19 -08:00
.vh {
min-height: calc(100vh - #{$header-height});
}
2020-07-22 13:19:23 -07:00
</style>