Commit 0cd03291 by nlp97

删减

parent 971b0ed1
/*
* @Author: ninglupeng
* @Date: 2022-06-07 00:31:25
* @LastEditors: ninglupeng
* @LastEditTime: 2022-06-07 10:24:33
* @Description:
*/
import Vue from "vue"; import Vue from "vue";
import Router from "vue-router"; import Router from "vue-router";
import store from "@/store"; import store from "@/store";
import { getItem, clear } from "@/utils/auth"; import { getItem, clear } from "@/utils/auth";
import HelloWorld from "@/views/HelloWorld.vue"; import outseeQualityControl from "@/views/outseeQualityControl.vue";
import login from "@/views/login.vue"; import login from "@/views/login.vue";
Vue.use(Router); Vue.use(Router);
...@@ -13,42 +20,55 @@ const router = new Router({ ...@@ -13,42 +20,55 @@ const router = new Router({
path: "*", path: "*",
component: (resolve) => require(["@/components/404.vue"], resolve), component: (resolve) => require(["@/components/404.vue"], resolve),
}, },
// {
// path: "/login",
// name: "login",
// component: login,
// },
{ {
path: "/login", path: "/outseeQualityControl",
name: "login", name: "outseeQualityControl",
component: login, component: outseeQualityControl,
},
{
path: "/",
name: "home",
component: HelloWorld,
}, },
// {
// path: "/",
// name: "home",
// component: HelloWorld,
// },
// {
// path: "/",
// name: "home",
// component: HelloWorld,
// },
], ],
}); });
//路由跳转前判断(登录权限) //路由跳转前判断(登录权限)
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
//console.log(to, from, next);
const token = getItem("svToken"); //获取用户id
console.log(token);
if (token) {
//有登录权限
if (to.path == "/login") {
next("/");
} else {
//console.log(to);
next();
}
} else {
//没有登录权限
if (to.path == "/login") {
next(); next();
} else { //console.log(to, from, next);
//不然就跳转到登录; // const token = getItem("svToken"); //获取用户id
next("/login"); // console.log(token);
}
} // if (token) {
// //有登录权限
// if (to.path == "/login") {
// next("/");
// } else {
// //console.log(to);
// next();
// }
// } else {
// //没有登录权限
// if (to.path == "/login") {
// next();
// } else {
// //不然就跳转到登录;
// next("/login");
// }
// }
}); });
// router.beforeEach(async(to, from, next) => { // router.beforeEach(async(to, from, next) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment