feat:修改左侧导航及打开页面导航

This commit is contained in:
李晓鸽
2022-10-08 14:28:33 +08:00
parent 8cb03598cc
commit d9eb479a63
2 changed files with 47 additions and 29 deletions

View File

@@ -335,31 +335,46 @@ export default {
}
});
let openpages = store.state.openpages;
for (let i = 0; i < openpages.length; i++) {
openpages[i].active = false;
}
for (let i = 0; i < openpages.length; i++) {
openpages[i].active = false;
if (n.toLowerCase() === openpages[i].href) {
console.log("已存在", openpages[i]);
openpages[i].active = true;
break;
} else {
if (i === openpages.length - 1) {
let pagename = state.keysList.filter((a) => {
return a.href === n.toLowerCase();
});
if (pagename && pagename.length !== 0) {
let obj = {
pagename: pagename[0].pagename,
href: n.toLowerCase(),
active: true,
};
openpages.push(obj);
if (openpages.length === 0) {
let pagename = state.keysList.filter((a) => {
return a.href === n.toLowerCase();
});
if (pagename && pagename.length !== 0) {
let obj = {
pagename: pagename[0].pagename,
href: n.toLowerCase(),
active: true,
};
openpages.push(obj);
}
} else {
for (let i = 0; i < openpages.length; i++) {
openpages[i].active = false;
}
for (let i = 0; i < openpages.length; i++) {
openpages[i].active = false;
if (n.toLowerCase() === openpages[i].href) {
console.log("已存在", openpages[i]);
openpages[i].active = true;
break;
} else {
if (i === openpages.length - 1) {
let pagename = state.keysList.filter((a) => {
return a.href === n.toLowerCase();
});
if (pagename && pagename.length !== 0) {
let obj = {
pagename: pagename[0].pagename,
href: n.toLowerCase(),
active: true,
};
openpages.push(obj);
}
}
}
}
}
localStorage.setItem("openpages", JSON.stringify(openpages));
store.commit("chengeOpenpages", openpages);

View File

@@ -44,16 +44,19 @@ export default {
state.openList.map((item, key) => {
if (item.href === value.href) {
if (state.openList.length === 1) {
state.openList.splice(key, 1);
$router.push({ path: "/learningpath" });
} else {
if (key === state.openList.length - 1) {
$router.push({ path: state.openList[key - 1].href });
state.openList.splice(key, 1);
} else {
$router.push({ path: state.openList[key + 1].href });
if (state.openList[0].href !== "/learningpath") {
state.openList.splice(key, 1);
}
$router.push({ path: "/learningpath" });
} else {
if (value.active) {
if (key === state.openList.length - 1) {
$router.push({ path: state.openList[key - 1].href });
} else {
$router.push({ path: state.openList[key + 1].href });
}
}
state.openList.splice(key, 1);
}
}
});