import Vue from "vue"; import VueRouter from "vue-router"; const originalPush = VueRouter.prototype.push VueRouter.prototype.push = function push(location) { return originalPush.call(this, location).catch(err => err); } Vue.use(VueRouter); const routes = [ { path: "/", name: "login", meta:{ keepAlive:true }, component: ()=>import("../views/login/login.vue") }, { path: "/test", name: "test", component: ()=>import("../views/test/test.vue") }, { path: "/loginByPhone", name: "loginByPhone", meta:{ keepAlive:false }, component: ()=>import("../views/login/loginByPhone.vue") }, { path: "/loginByCode", name: "loginByCode", meta:{ keepAlive:false }, component: ()=>import("../views/login/loginByCode.vue") }, { path: "/sex", name: "sex", meta:{ keepAlive:true }, component: ()=>import("../views/info/sex.vue") }, { path: "/figure", name: "figure", meta:{ keepAlive:true }, component: ()=>import("../views/info/figure.vue") }, { path: "/datum", name: "datum", meta:{ keepAlive:true }, component: ()=>import("../views/info/datum.vue") }, { path: "/city", name: "city", meta:{ keepAlive:true }, component: ()=>import("../views/info/city.vue") }, { path: "/wechat", name: "wechat", meta:{ keepAlive:true }, component: ()=>import("../views/info/wechat.vue") }, { path: "/labels", name: "labels", meta:{ keepAlive:false }, component: ()=>import("../views/info/labels.vue") }, { path: "/user", name: "user", meta:{ keepAlive:true }, component: ()=>import("../views/friends/user.vue") }, { path: "/main", name: "main", meta:{ keepAlive:true }, component: ()=>import("../views/main/main.vue"), redirect: '/friends', children:[ { path: "/friends", name: "friends", meta:{ keepAlive:true }, component:()=>import("../views/friends/friends.vue"), }, { path: "/messages", name: "messages", meta:{ keepAlive:false }, component:()=>import("../views/messages/messages.vue"), }, { path: "/mine", name: "mine", meta:{ keepAlive:false }, component:()=>import("../views/mine/mine.vue"), }, ] }, { path: "/chatting", name: "chatting", meta:{ keepAlive:false }, component: ()=>import("../views/chatting/chatting.vue") }, { path: "/editCenter", name: "editCenter", meta:{ keepAlive:true }, component: ()=>import("../views/info/editCenter.vue") }, { path: "/guest", name: "guest", meta:{ keepAlive:false }, component: ()=>import("../views/mine/guest.vue") }, { path: "/search", name: "search", meta:{ keepAlive:true }, component: ()=>import("../views/search/search.vue") }, { path: "/album", name: "album", meta:{ keepAlive:true }, component: ()=>import("../views/mine/album.vue") }, { path: "/faceVideo", name: "faceVideo", meta:{ keepAlive:true }, component: ()=>import("../views/faceVideo/faceVideo.vue") }, { path: "/chooseImage", name: "chooseImage", meta:{ keepAlive:true }, component: ()=>import("../views/mine/chooseImage.vue") }, { path: "/authReady", name: "authReady", meta:{ keepAlive:true }, component: ()=>import("../views/mine/authReady.vue") }, { path: "/setting", name: "setting", meta:{ keepAlive:true }, component: ()=>import("../views/setting/setting.vue") }, { path: "/vip", name: "vip", meta:{ keepAlive:true }, component: ()=>import("../views/vip/vip.vue") }, { path: "/walletHome", name: "walletHome", component: () => import("../views/wallet/walletHome/index"), }, { path: "/ydDetail", name: "ydDetail", component: () => import("../views/wallet/ydDetail/index"), }, { path: "/walletWithdraw", name: "walletWithdraw", component: () => import("../views/wallet/walletWithdraw/index"), }, { path: "/boundAli", name: "boundAli", component: () => import("../views/wallet/boundAli/index"), }, { path: "/incomeDetail", name: "incomeDetail", component: () => import("../views/wallet/incomeDetail/index"), }, { path: "/exchange", name: "exchange", component: () => import("../views/wallet/exchange/index"), }, { path: "/exchangeSuccess", name: "exchangeSuccess", component: () => import("../views/wallet/exchangeSuccess/index"), }, { path: "/withdrawResult", name: "withdrawResult", component: () => import("../views/wallet/withdrawResult/index"), }, ]; const router = new VueRouter({ mode: "history", base: process.env.BASE_URL, routes, }); // router.beforeEach((to,from,next)=>{ // console.log(to,from) // if(to.name==='test'){ // next(); // } // if(!localStorage.getItem('user')){ // if(to.name==='login'||(from.name==='login'&&to.name==='loginByPhone')||(from.name==='loginByPhone'&&to.name==='loginByCode')){ // next(); // } // else { // next({path:'/'}); // } // } // else{ // next(); // } // }); export default router;