|
@@ -65,44 +65,44 @@ new Vue({
|
|
VueCookies.config('30d')
|
|
VueCookies.config('30d')
|
|
|
|
|
|
|
|
|
|
-router.beforeEach((to, from, next) => {
|
|
|
|
- if (to.matched.length === 0) {
|
|
|
|
- from.name ? next({
|
|
|
|
- name: from.name
|
|
|
|
- }) : next('/login');
|
|
|
|
- }
|
|
|
|
- if (to.meta.title) {
|
|
|
|
- document.title = to.meta.title
|
|
|
|
- }
|
|
|
|
- const requireAuth = to.meta.requireAuth
|
|
|
|
- // 判断该路由是否需要登录权限
|
|
|
|
- if (requireAuth) {
|
|
|
|
- var isLogin = VueCookies.get('tlogin')
|
|
|
|
- if (isLogin == "1") {
|
|
|
|
- var userinfo = VueCookies.get('teacherInfo')
|
|
|
|
- store.commit("update", ["isLogin", true]);
|
|
|
|
|
|
+// router.beforeEach((to, from, next) => {
|
|
|
|
+// if (to.matched.length === 0) {
|
|
|
|
+// from.name ? next({
|
|
|
|
+// name: from.name
|
|
|
|
+// }) : next('/login');
|
|
|
|
+// }
|
|
|
|
+// if (to.meta.title) {
|
|
|
|
+// document.title = to.meta.title
|
|
|
|
+// }
|
|
|
|
+// const requireAuth = to.meta.requireAuth
|
|
|
|
+// // 判断该路由是否需要登录权限
|
|
|
|
+// if (requireAuth) {
|
|
|
|
+// var isLogin = VueCookies.get('tlogin')
|
|
|
|
+// if (isLogin == "1") {
|
|
|
|
+// var userinfo = VueCookies.get('teacherInfo')
|
|
|
|
+// store.commit("update", ["isLogin", true]);
|
|
|
|
|
|
- // var info = JSON.parse(window.sessionStorage.getItem("userInfo"))
|
|
|
|
- store.commit("update", ["userInfo", userinfo]);
|
|
|
|
- store.state.luyou = store.state.luyou + 1
|
|
|
|
- store.commit("update", ["luyou", store.state.luyou]);
|
|
|
|
- next()
|
|
|
|
- } else {
|
|
|
|
- const loading = Loading.service({
|
|
|
|
- background: "rgba(255, 255, 255)",
|
|
|
|
- target: document.querySelector("body"),
|
|
|
|
- });
|
|
|
|
- store.commit("update", ["isLogin", false]);
|
|
|
|
- Message({
|
|
|
|
- message: '未登录,请登录',
|
|
|
|
- type: 'warning'
|
|
|
|
- });
|
|
|
|
- setTimeout(() => {
|
|
|
|
- loading.close();
|
|
|
|
- next('/login')
|
|
|
|
- }, 2000);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- next() // 确保一定要有next()被调用
|
|
|
|
- }
|
|
|
|
-})
|
|
|
|
|
|
+// // var info = JSON.parse(window.sessionStorage.getItem("userInfo"))
|
|
|
|
+// store.commit("update", ["userInfo", userinfo]);
|
|
|
|
+// store.state.luyou = store.state.luyou + 1
|
|
|
|
+// store.commit("update", ["luyou", store.state.luyou]);
|
|
|
|
+// next()
|
|
|
|
+// } else {
|
|
|
|
+// const loading = Loading.service({
|
|
|
|
+// background: "rgba(255, 255, 255)",
|
|
|
|
+// target: document.querySelector("body"),
|
|
|
|
+// });
|
|
|
|
+// store.commit("update", ["isLogin", false]);
|
|
|
|
+// // Message({
|
|
|
|
+// // message: '未登录,请登录',
|
|
|
|
+// // type: 'warning'
|
|
|
|
+// // });
|
|
|
|
+// setTimeout(() => {
|
|
|
|
+// loading.close();
|
|
|
|
+// // next('/login')
|
|
|
|
+// }, 2000);
|
|
|
|
+// }
|
|
|
|
+// } else {
|
|
|
|
+// next() // 确保一定要有next()被调用
|
|
|
|
+// }
|
|
|
|
+// })
|