router.beforeEach((to, from, next) => {if (to.meta.title) {document.title = "xxxxx" + to.meta.title;}let token = window.sessionStorage.getItem('userInfo');// 如果没有token 并且没有任何响应 就要去action中自动登录if (!token) {const loginForm = {username: "admin",password: "admin123",rememberMe: false,code: "",uuid: ""}store.dispatch("Login", loginForm).then(() => {router.push({ path: "/" }).catch(()=>{});const userInfo = {username:loginForm.username}sessionStorage.setItem('userInfo',JSON.stringify(userInfo))}).catch(() => {});} else { // 其他情况可以放行next();}
})