asd uha
This commit is contained in:
+7
-5
@@ -1,5 +1,6 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
|
import store from '@/store/store'
|
||||||
|
|
||||||
const domain = ""
|
const domain = ""
|
||||||
// import themeConfig from '@/../themeConfig.js'
|
// import themeConfig from '@/../themeConfig.js'
|
||||||
@@ -8,6 +9,7 @@ const noAthUrl =["/register/form",
|
|||||||
"/auth/register",
|
"/auth/register",
|
||||||
"/pages/error-404",
|
"/pages/error-404",
|
||||||
"/pages/error-403",
|
"/pages/error-403",
|
||||||
|
"/register/form",
|
||||||
"/auth/forgot-password"]
|
"/auth/forgot-password"]
|
||||||
const token = sessionStorage.getItem("accessToken") || sessionStorage.accessToken || null
|
const token = sessionStorage.getItem("accessToken") || sessionStorage.accessToken || null
|
||||||
const headers = {
|
const headers = {
|
||||||
@@ -26,8 +28,8 @@ myax.interceptors.request.use(
|
|||||||
function (config) {
|
function (config) {
|
||||||
// Do something before request is sent
|
// Do something before request is sent
|
||||||
if (process.browser) {
|
if (process.browser) {
|
||||||
if (!sessionStorage.getItem("accessToken") && !noAthUrl.includes(router.currentRoute.fullPath)) {
|
if (!sessionStorage.getItem("accessToken") && !noAthUrl.includes(store.state.route.route)) {
|
||||||
console.log("router req::::",router.currentRoute)
|
console.log("router req::::",store.state.route.route)
|
||||||
router.push('/auth/login');
|
router.push('/auth/login');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,11 +66,11 @@ myax.interceptors.response.use(
|
|||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
function ({response}) {
|
function ({response}) {
|
||||||
if (response.status === 401 && !noAthUrl.includes(router.currentRoute.fullPath)) {
|
if (response.status === 401 && !noAthUrl.includes(store.state.route.route)) {
|
||||||
console.log("router response::::",router.currentRoute)
|
console.log("router response::::",store.state.route.route)
|
||||||
router.push({path:'/auth/login'});
|
router.push({path:'/auth/login'});
|
||||||
}
|
}
|
||||||
if(response.status === 403 && router.currentRoute.fullPath !== '/error-403'){
|
if(response.status === 403 && store.state.route.route !== '/error-403'){
|
||||||
console.log('403333333333333')
|
console.log('403333333333333')
|
||||||
router.push({path:'/error-403'});
|
router.push({path:'/error-403'});
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -1,6 +1,7 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import Router from 'vue-router'
|
import Router from 'vue-router'
|
||||||
import 'firebase/auth'
|
import 'firebase/auth'
|
||||||
|
import store from "./store/store";
|
||||||
|
|
||||||
Vue.use(Router)
|
Vue.use(Router)
|
||||||
|
|
||||||
@@ -151,16 +152,17 @@ const router = new Router({
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
router.afterEach(() => {
|
router.afterEach((to) => {
|
||||||
const appLoading = document.getElementById('loading-bg')
|
const appLoading = document.getElementById('loading-bg')
|
||||||
if (appLoading) {
|
if (appLoading) {
|
||||||
appLoading.style.display = "none";
|
appLoading.style.display = "none";
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach(async (to, from, next) => {
|
||||||
// return next();
|
// return next();
|
||||||
let isLogin = sessionStorage.getItem('accessToken');
|
let isLogin = sessionStorage.getItem('accessToken');
|
||||||
|
await store.commit('route/SET_ROUTE',to.path)
|
||||||
//console.log("to.path ==> ", to.path);
|
//console.log("to.path ==> ", to.path);
|
||||||
if (
|
if (
|
||||||
to.path === "/register/form" ||
|
to.path === "/register/form" ||
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
const state = {
|
||||||
|
route: '/register/form',
|
||||||
|
}
|
||||||
|
const mutations = {
|
||||||
|
SET_ROUTE(state, route) {
|
||||||
|
state.route = route
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
namespaced: true,
|
||||||
|
state,
|
||||||
|
mutations,
|
||||||
|
}
|
||||||
+3
-1
@@ -43,6 +43,7 @@ import badadv from './badadv/badadv'
|
|||||||
import points from './point/points'
|
import points from './point/points'
|
||||||
import transaction from './transaction/transaction'
|
import transaction from './transaction/transaction'
|
||||||
import price from './price/price'
|
import price from './price/price'
|
||||||
|
import route from './route'
|
||||||
|
|
||||||
export default new Vuex.Store({
|
export default new Vuex.Store({
|
||||||
getters,
|
getters,
|
||||||
@@ -70,7 +71,8 @@ export default new Vuex.Store({
|
|||||||
transaction:transaction,
|
transaction:transaction,
|
||||||
price:price,
|
price:price,
|
||||||
variantAdd:variantAdd,
|
variantAdd:variantAdd,
|
||||||
advModel:advModel
|
advModel:advModel,
|
||||||
|
route:route,
|
||||||
},
|
},
|
||||||
strict: process.env.NODE_ENV !== 'production'
|
strict: process.env.NODE_ENV !== 'production'
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user