/**
* @param {to} 将要去的路由
* @param {from} 出发的路由
* @param {next} 执行下一步
*/
router.beforeEach((to, from, next) => {
var arr = JSON.parse(localStorage.getItem("name"));
var query = JSON.parse(localStorage.getItem('evalutaionData'));
// console.log('旧值',arr);
if( !arr ){
arr = [];
}
// console.log('倒数第二个',arr[arr.length-2],to.name);
if( arr[arr.length-2] == to.name){//to 是上一个页面
arr.pop();
query.pop();
// console.log(arr);
// console.log(query);
// return false;
// alert("返回");
localStorage.setItem('evalutaionData',JSON.stringify(query));
localStorage.setItem("name", JSON.stringify(arr));
next();
return false;
}
// console.log('旧值',query);
// console.log('旧值',arr);
if( !arr ){
arr = [];
}
if( !query ){
query = [];
}
if( query.length == 0 ){
query = [];
}
// console.log(query);
// console.log(arr);
var newName = to.name;
var newQuery = to.query;
// console.log('从哪里来',newQuery);
if( newName ){
arr.push(newName);
if(arr.length>=6){
arr.shift()
}
}
if( newQuery ){
query.push(newQuery);
if(query.length>=6){
query.shift();
}
}
// console.log('存志',arr);
localStorage.setItem('evalutaionData',JSON.stringify(query))
localStorage.setItem("name", JSON.stringify(arr));
// var query = JSON.parse(window.localStorage.getItem("query"));
// // query = [{id:1},{id:2}]
// console.log(query);
// query.push(from.query);
// window.localStorage.setItem("query", JSON.stringify(query));
// window.localStorage.setItem("query", JSON.stringify(from.query));
next();
})