Re-did list components
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
<LandingBanner />
|
<LandingBanner />
|
||||||
|
|
||||||
<div v-for="list in lists">
|
<div v-for="list in lists">
|
||||||
<list-header :title="list.title" :link="'/list/' + list.route" />
|
<list-header :title="list.title" :link="list.route" />
|
||||||
|
|
||||||
<results-list :results="list.data" :shortList="true" />
|
<results-list :results="list.data" :shortList="true" />
|
||||||
<loader v-if="!list.data.length" />
|
<loader v-if="!list.data.length" />
|
||||||
@@ -36,22 +36,22 @@ export default {
|
|||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
title: "Requests",
|
title: "Requests",
|
||||||
route: "request",
|
route: "/requests",
|
||||||
data: this.requests
|
data: this.requests
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Now playing",
|
title: "Now playing",
|
||||||
route: "now_playing",
|
route: "/list/now_playing",
|
||||||
data: this.nowplaying
|
data: this.nowplaying
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Upcoming",
|
title: "Upcoming",
|
||||||
route: "upcoming",
|
route: "/list/upcoming",
|
||||||
data: this.upcoming
|
data: this.upcoming
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Popular",
|
title: "Popular",
|
||||||
route: "popular",
|
route: "/list/popular",
|
||||||
data: this.popular
|
data: this.popular
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
<template>
|
<template>
|
||||||
<header :class="{ 'sticky': sticky }">
|
<header :class="{ sticky: sticky }">
|
||||||
<h2>{{ title }}</h2>
|
<h2>{{ title }}</h2>
|
||||||
|
|
||||||
<div v-if="info instanceof Array" class="flex flex-direction-column">
|
<div v-if="info instanceof Array" class="flex flex-direction-column">
|
||||||
<span v-for="item in info" class="info">{{ item }}</span>
|
<span v-for="item in info" class="info">{{ item }}</span>
|
||||||
</div>
|
</div>
|
||||||
<span v-else class="info">{{ info }}</span>
|
<span v-else class="info">{{ info }}</span>
|
||||||
<router-link v-if="link" :to="link" class='view-more' :aria-label="`View all ${title}`">
|
<router-link
|
||||||
|
v-if="link"
|
||||||
|
:to="link"
|
||||||
|
class="view-more"
|
||||||
|
:aria-label="`View all ${title}`"
|
||||||
|
>
|
||||||
View All
|
View All
|
||||||
</router-link>
|
</router-link>
|
||||||
</header>
|
</header>
|
||||||
@@ -33,14 +38,13 @@ export default {
|
|||||||
required: false
|
required: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@import './src/scss/variables';
|
@import "./src/scss/variables";
|
||||||
@import './src/scss/media-queries';
|
@import "./src/scss/media-queries";
|
||||||
@import './src/scss/main';
|
@import "./src/scss/main";
|
||||||
|
|
||||||
header {
|
header {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -57,7 +61,7 @@ header {
|
|||||||
position: sticky;
|
position: sticky;
|
||||||
position: -webkit-sticky;
|
position: -webkit-sticky;
|
||||||
top: $header-size;
|
top: $header-size;
|
||||||
z-index: 4;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
@@ -72,10 +76,10 @@ header {
|
|||||||
.view-more {
|
.view-more {
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
letter-spacing: .5px;
|
letter-spacing: 0.5px;
|
||||||
color: $text-color-70;
|
color: $text-color-70;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
transition: color .5s ease;
|
transition: color 0.5s ease;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
&:after {
|
&:after {
|
||||||
@@ -89,18 +93,17 @@ header {
|
|||||||
.info {
|
.info {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
letter-spacing: .5px;
|
letter-spacing: 0.5px;
|
||||||
color: $text-color;
|
color: $text-color;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
@include tablet-min {
|
@include tablet-min {
|
||||||
padding-left: 1.25rem;;
|
padding-left: 1.25rem;
|
||||||
}
|
}
|
||||||
@include desktop-lg-min {
|
@include desktop-lg-min {
|
||||||
padding-left: 1.75rem;
|
padding-left: 1.75rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
@@ -1,105 +1,24 @@
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<ResultsSection :title="listName" :apiFunction="getTmdbMovieListByName" />
|
||||||
<list-header :title="listTitle" :info="info" :sticky="true" />
|
|
||||||
|
|
||||||
<results-list :results="results" v-if="results" />
|
|
||||||
|
|
||||||
<loader v-if="!results.length" />
|
|
||||||
|
|
||||||
<div v-if="page < totalPages" class="fullwidth-button">
|
|
||||||
<seasoned-button @click="loadMore">load more</seasoned-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ListHeader from '@/components/ListHeader'
|
import ResultsSection from "./ResultsSection";
|
||||||
import ResultsList from '@/components/ResultsList'
|
import { getTmdbMovieListByName } from "@/api";
|
||||||
import SeasonedButton from '@/components/ui/SeasonedButton'
|
|
||||||
import Loader from '@/components/ui/Loader'
|
|
||||||
import { getTmdbMovieListByName, getRequests } from '@/api'
|
|
||||||
import store from '@/store'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { ListHeader, ResultsList, SeasonedButton, Loader },
|
components: { ResultsSection },
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
legalTmdbLists: [ 'now_playing', 'upcoming', 'popular' ],
|
|
||||||
results: [],
|
|
||||||
page: 1,
|
|
||||||
totalPages: 0,
|
|
||||||
totalResults: 0,
|
|
||||||
loading: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
listTitle() {
|
listName() {
|
||||||
if (this.results.length === 0)
|
return this.$route.params.name;
|
||||||
return ''
|
|
||||||
|
|
||||||
const routeListName = this.$route.params.name
|
|
||||||
console.log('routelistname', routeListName)
|
|
||||||
return routeListName.includes('_') ? routeListName.split('_').join(' ') : routeListName
|
|
||||||
},
|
|
||||||
info() {
|
|
||||||
if (this.results.length === 0)
|
|
||||||
return [null, null]
|
|
||||||
return [this.pageCount, this.resultCount]
|
|
||||||
},
|
|
||||||
resultCount() {
|
|
||||||
const loadedResults = this.results.length
|
|
||||||
const totalResults = this.totalResults < 10000 ? this.totalResults : '∞'
|
|
||||||
return `${loadedResults} of ${totalResults} results`
|
|
||||||
},
|
|
||||||
pageCount() {
|
|
||||||
return `Page ${this.page} of ${this.totalPages}`
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadMore() {
|
getTmdbMovieListByName(page) {
|
||||||
console.log(this.$route)
|
return getTmdbMovieListByName(this.listName, page);
|
||||||
this.loading = true;
|
|
||||||
this.page++
|
|
||||||
|
|
||||||
window.history.replaceState({}, 'search', `/#/${this.$route.fullPath}?page=${this.page}`)
|
|
||||||
this.init()
|
|
||||||
},
|
|
||||||
init() {
|
|
||||||
const routeListName = this.$route.params.name
|
|
||||||
|
|
||||||
if (routeListName === 'request') {
|
|
||||||
getRequests(this.page)
|
|
||||||
.then(results => {
|
|
||||||
this.results = this.results.concat(...results.results)
|
|
||||||
this.page = results.page
|
|
||||||
this.totalPages = results.total_pages
|
|
||||||
this.totalResults = results.total_results
|
|
||||||
})
|
|
||||||
} else if (this.legalTmdbLists.includes(routeListName)) {
|
|
||||||
getTmdbMovieListByName(routeListName, this.page)
|
|
||||||
.then(results => {
|
|
||||||
this.results = this.results.concat(...results.results)
|
|
||||||
this.page = results.page
|
|
||||||
this.totalPages = results.total_pages
|
|
||||||
this.totalResults = results.total_results
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
// TODO handle if list is not found
|
|
||||||
console.log('404 this is not a tmdb list')
|
|
||||||
}
|
|
||||||
|
|
||||||
this.loading = false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
if (this.results.length === 0)
|
|
||||||
this.init()
|
|
||||||
|
|
||||||
store.dispatch('documentTitle/updateTitle', `${this.$router.history.current.name} ${this.$route.params.name}`)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ export default {
|
|||||||
if (this.movie.poster != null) {
|
if (this.movie.poster != null) {
|
||||||
this.poster = "https://image.tmdb.org/t/p/w500" + this.movie.poster;
|
this.poster = "https://image.tmdb.org/t/p/w500" + this.movie.poster;
|
||||||
} else {
|
} else {
|
||||||
this.poster = "/no-image.png";
|
this.poster = "/assets/no-image.png";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -117,7 +117,6 @@ export default {
|
|||||||
padding: 10px;
|
padding: 10px;
|
||||||
width: 50%;
|
width: 50%;
|
||||||
background-color: $background-color;
|
background-color: $background-color;
|
||||||
transition: background-color 0.5s ease;
|
|
||||||
|
|
||||||
@include tablet-min {
|
@include tablet-min {
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
|
|||||||
25
src/components/RequestPage.vue
Normal file
25
src/components/RequestPage.vue
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<template>
|
||||||
|
<ResultsSection title="Requests" :apiFunction="getRequests" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import ResultsSection from "./ResultsSection";
|
||||||
|
import { getRequests } from "@/api";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: { ResultsSection },
|
||||||
|
methods: {
|
||||||
|
getRequests: getRequests
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.fullwidth-button {
|
||||||
|
width: 100%;
|
||||||
|
margin: 1rem 0;
|
||||||
|
padding-bottom: 2rem;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -24,12 +24,11 @@ export default {
|
|||||||
default: false
|
default: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@import './src/scss/media-queries';
|
@import "./src/scss/media-queries";
|
||||||
|
|
||||||
.results {
|
.results {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -67,5 +66,4 @@ export default {
|
|||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
155
src/components/ResultsSection.vue
Normal file
155
src/components/ResultsSection.vue
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<list-header :title="prettify(title)" :info="info" :sticky="true" />
|
||||||
|
|
||||||
|
<div v-if="!loadedPages.includes(1)" class="load-button">
|
||||||
|
<seasoned-button @click="loadLess" :fullWidth="true"
|
||||||
|
>load previous</seasoned-button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<results-list :results="results" v-if="results" />
|
||||||
|
|
||||||
|
<loader v-if="!results.length" />
|
||||||
|
|
||||||
|
<div v-if="page < totalPages" class="load-button">
|
||||||
|
<seasoned-button @click="loadMore" :fullWidth="true"
|
||||||
|
>load more</seasoned-button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import ListHeader from "@/components/ListHeader";
|
||||||
|
import ResultsList from "@/components/ResultsList";
|
||||||
|
import SeasonedButton from "@/components/ui/SeasonedButton";
|
||||||
|
import Loader from "@/components/ui/Loader";
|
||||||
|
import store from "@/store";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
apiFunction: {
|
||||||
|
type: Function,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
components: { ListHeader, ResultsList, SeasonedButton, Loader },
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
results: [],
|
||||||
|
page: 1,
|
||||||
|
loadedPages: [],
|
||||||
|
totalPages: 0,
|
||||||
|
totalResults: 0,
|
||||||
|
loading: true
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
info() {
|
||||||
|
if (this.results.length === 0) return [null, null];
|
||||||
|
return [this.pageCount, this.resultCount];
|
||||||
|
},
|
||||||
|
resultCount() {
|
||||||
|
const loadedResults = this.results.length;
|
||||||
|
const totalResults = this.totalResults < 10000 ? this.totalResults : "∞";
|
||||||
|
return `${loadedResults} of ${totalResults} results`;
|
||||||
|
},
|
||||||
|
pageCount() {
|
||||||
|
return `Page ${this.page} of ${this.totalPages}`;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
prettify(listName) {
|
||||||
|
return listName.includes("_") ? listName.split("_").join(" ") : listName;
|
||||||
|
},
|
||||||
|
loadMore() {
|
||||||
|
this.loading = true;
|
||||||
|
let maxPage = [...this.loadedPages].slice(-1)[0];
|
||||||
|
console.log("maxPage:", maxPage);
|
||||||
|
if (maxPage == NaN) return;
|
||||||
|
this.page = maxPage + 1;
|
||||||
|
this.getListResults();
|
||||||
|
},
|
||||||
|
loadLess() {
|
||||||
|
this.loading = true;
|
||||||
|
const minPage = this.loadedPages[0];
|
||||||
|
if (minPage === 1) return;
|
||||||
|
|
||||||
|
this.page = minPage - 1;
|
||||||
|
this.getListResults(true);
|
||||||
|
},
|
||||||
|
updateQueryParams() {
|
||||||
|
let params = new URLSearchParams(window.location.search);
|
||||||
|
if (params.has("page")) {
|
||||||
|
params.set("page", this.page);
|
||||||
|
} else if (this.page > 1) {
|
||||||
|
params.append("page", this.page);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.history.replaceState(
|
||||||
|
{},
|
||||||
|
"search",
|
||||||
|
`${window.location.protocol}//${window.location.hostname}${
|
||||||
|
window.location.port ? `:${window.location.port}` : ""
|
||||||
|
}${window.location.pathname}${
|
||||||
|
params.toString().length ? `?${params}` : ""
|
||||||
|
}`
|
||||||
|
);
|
||||||
|
},
|
||||||
|
getPageFromQueryParams() {
|
||||||
|
return new URLSearchParams(window.location.search).get("page");
|
||||||
|
},
|
||||||
|
getListResults(front = false) {
|
||||||
|
this.apiFunction(this.page)
|
||||||
|
.then(results => {
|
||||||
|
if (front) this.results = results.results.concat(...this.results);
|
||||||
|
else this.results = this.results.concat(...results.results);
|
||||||
|
this.page = results.page;
|
||||||
|
this.loadedPages.push(this.page);
|
||||||
|
this.loadedPages = this.loadedPages.sort();
|
||||||
|
this.totalPages = results.total_pages;
|
||||||
|
this.totalResults = results.total_results;
|
||||||
|
})
|
||||||
|
.then(this.updateQueryParams)
|
||||||
|
.finally(() => (this.loading = false));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.page = this.getPageFromQueryParams() || this.page;
|
||||||
|
if (this.results.length === 0) this.getListResults();
|
||||||
|
|
||||||
|
store.dispatch(
|
||||||
|
"documentTitle/updateTitle",
|
||||||
|
`${this.$router.history.current.name} ${this.$route.params.name}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@import "./src/scss/media-queries";
|
||||||
|
|
||||||
|
.load-button {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
justify-content: center;
|
||||||
|
margin: 2rem 0;
|
||||||
|
|
||||||
|
@include mobile {
|
||||||
|
margin: 1rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:last-of-type {
|
||||||
|
margin-bottom: 4rem;
|
||||||
|
|
||||||
|
@include mobile {
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
109
src/routes.js
109
src/routes.js
@@ -1,61 +1,58 @@
|
|||||||
import Vue from 'vue'
|
import Vue from "vue";
|
||||||
import VueRouter from 'vue-router';
|
import VueRouter from "vue-router";
|
||||||
import store from '@/store'
|
import store from "@/store";
|
||||||
|
|
||||||
Vue.use(VueRouter)
|
|
||||||
|
|
||||||
|
Vue.use(VueRouter);
|
||||||
|
|
||||||
let routes = [
|
let routes = [
|
||||||
{
|
{
|
||||||
name: 'home',
|
name: "home",
|
||||||
path: '/',
|
path: "/",
|
||||||
component: (resolve) => require(['./components/Home.vue'], resolve)
|
component: resolve => require(["./components/Home.vue"], resolve)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'activity',
|
name: "activity",
|
||||||
path: '/activity',
|
path: "/activity",
|
||||||
meta: { requiresAuth: true },
|
meta: { requiresAuth: true },
|
||||||
component: (resolve) => require(['./components/ActivityPage.vue'], resolve)
|
component: resolve => require(["./components/ActivityPage.vue"], resolve)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'profile',
|
name: "profile",
|
||||||
path: '/profile',
|
path: "/profile",
|
||||||
meta: { requiresAuth: true },
|
meta: { requiresAuth: true },
|
||||||
component: (resolve) => require(['./components/Profile.vue'], resolve)
|
component: resolve => require(["./components/Profile.vue"], resolve)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'list',
|
name: "list",
|
||||||
path: '/list/:name',
|
path: "/list/:name",
|
||||||
component: (resolve) => require(['./components/ListPage.vue'], resolve)
|
component: resolve => require(["./components/ListPage.vue"], resolve)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'request',
|
name: "request",
|
||||||
path: '/request/all',
|
path: "/requests",
|
||||||
components: {
|
component: resolve => require(["./components/RequestPage.vue"], resolve)
|
||||||
'request-router-view': require('./components/ListPage.vue')
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'search',
|
name: "search",
|
||||||
path: '/search',
|
path: "/search",
|
||||||
component: (resolve) => require(['./components/Search.vue'], resolve)
|
component: resolve => require(["./components/Search.vue"], resolve)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'register',
|
name: "register",
|
||||||
path: '/register',
|
path: "/register",
|
||||||
component: (resolve) => require(['./components/Register.vue'], resolve)
|
component: resolve => require(["./components/Register.vue"], resolve)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'settings',
|
name: "settings",
|
||||||
path: '/settings',
|
path: "/settings",
|
||||||
meta: { requiresAuth: true },
|
meta: { requiresAuth: true },
|
||||||
component: (resolve) => require(['./components/Settings.vue'], resolve)
|
component: resolve => require(["./components/Settings.vue"], resolve)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'signin',
|
name: "signin",
|
||||||
path: '/signin',
|
path: "/signin",
|
||||||
alias: '/login',
|
alias: "/login",
|
||||||
component: (resolve) => require(['./components/Signin.vue'], resolve)
|
component: resolve => require(["./components/Signin.vue"], resolve)
|
||||||
},
|
},
|
||||||
// {
|
// {
|
||||||
// name: 'user-requests',
|
// name: 'user-requests',
|
||||||
@@ -65,50 +62,52 @@ let routes = [
|
|||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
{
|
{
|
||||||
name: '404',
|
name: "404",
|
||||||
path: '/404',
|
path: "/404",
|
||||||
component: (resolve) => require(['./components/404.vue'], resolve)
|
component: resolve => require(["./components/404.vue"], resolve)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'logout',
|
name: "logout",
|
||||||
path: '/logout',
|
path: "/logout",
|
||||||
component: {
|
component: {
|
||||||
template: '<div></div>',
|
template: "<div></div>",
|
||||||
created() {
|
created() {
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
this.$router.push({ name: 'home' });
|
this.$router.push({ name: "home" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '*',
|
path: "*",
|
||||||
redirect: '/'
|
redirect: "/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/request',
|
path: "/request",
|
||||||
redirect: '/'
|
redirect: "/"
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
const router = new VueRouter({
|
const router = new VueRouter({
|
||||||
mode: 'history',
|
mode: "history",
|
||||||
base: '/',
|
base: "/",
|
||||||
routes,
|
routes,
|
||||||
linkActiveClass: 'is-active'
|
linkActiveClass: "is-active"
|
||||||
});
|
});
|
||||||
|
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
store.dispatch('documentTitle/updateTitle', to.name)
|
store.dispatch("documentTitle/updateTitle", to.name);
|
||||||
|
|
||||||
// Toggle mobile nav
|
// Toggle mobile nav
|
||||||
if(document.querySelector('.nav__hamburger--active')){
|
if (document.querySelector(".nav__hamburger--active")) {
|
||||||
document.querySelector('.nav__hamburger').classList.remove('nav__hamburger--active');
|
document
|
||||||
document.querySelector('.nav__list').classList.remove('nav__list--active');
|
.querySelector(".nav__hamburger")
|
||||||
|
.classList.remove("nav__hamburger--active");
|
||||||
|
document.querySelector(".nav__list").classList.remove("nav__list--active");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to.matched.some(record => record.meta.requiresAuth)) {
|
if (to.matched.some(record => record.meta.requiresAuth)) {
|
||||||
if (localStorage.getItem('token') == null) {
|
if (localStorage.getItem("token") == null) {
|
||||||
next({ path: '/signin' });
|
next({ path: "/signin" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user