enhance: navigation optimization
This commit is contained in:
parent
04c01b6780
commit
12b1d08ea4
3 changed files with 13 additions and 4 deletions
|
@ -12,7 +12,14 @@ export async function abilityAndNavUpdate(to: any, from: any, next: any) {
|
||||||
let section = to.meta.section;
|
let section = to.meta.section;
|
||||||
let module = to.meta.module;
|
let module = to.meta.module;
|
||||||
|
|
||||||
if ((admin && ability.isAdmin()) || ability.can(type, section, module)) {
|
if (to.name == "admin-default") {
|
||||||
|
navigation.activeNavigation = "club";
|
||||||
|
navigation.activeLink = null;
|
||||||
|
navigation.updateTopLevel();
|
||||||
|
navigation.updateNavigation();
|
||||||
|
NProgress.done();
|
||||||
|
next();
|
||||||
|
} else if ((admin && ability.isAdmin()) || ability.can(type, section, module)) {
|
||||||
NProgress.done();
|
NProgress.done();
|
||||||
navigation.activeNavigation = to.name.split("-")[1];
|
navigation.activeNavigation = to.name.split("-")[1];
|
||||||
navigation.activeLink = to.name.split("-")[2];
|
navigation.activeLink = to.name.split("-")[2];
|
||||||
|
|
|
@ -15,7 +15,7 @@ const router = createRouter({
|
||||||
routes: [
|
routes: [
|
||||||
{
|
{
|
||||||
path: "/",
|
path: "/",
|
||||||
redirect: { name: "admin" },
|
redirect: { name: "admin-default" },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/login",
|
path: "/login",
|
||||||
|
@ -76,12 +76,13 @@ const router = createRouter({
|
||||||
path: "/admin",
|
path: "/admin",
|
||||||
name: "admin",
|
name: "admin",
|
||||||
component: () => import("@/views/admin/View.vue"),
|
component: () => import("@/views/admin/View.vue"),
|
||||||
beforeEnter: [isAuthenticated],
|
beforeEnter: [isAuthenticated, abilityAndNavUpdate],
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: "",
|
path: "",
|
||||||
name: "admin-default",
|
name: "admin-default",
|
||||||
component: () => import("@/views/admin/ViewSelect.vue"),
|
component: () => import("@/views/admin/ViewSelect.vue"),
|
||||||
|
beforeEnter: [abilityAndNavUpdate],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "club",
|
path: "club",
|
||||||
|
|
|
@ -147,7 +147,8 @@ export const useNavigationStore = defineStore("navigation", {
|
||||||
this.activeNavigationObject.main.findIndex((e) => e.key == this.activeLink) == -1 ||
|
this.activeNavigationObject.main.findIndex((e) => e.key == this.activeLink) == -1 ||
|
||||||
this.activeLink == "default"
|
this.activeLink == "default"
|
||||||
) {
|
) {
|
||||||
let link = this.activeNavigationObject.main[0].key;
|
let link = this.activeNavigationObject.main.filter((m) => !m.key.startsWith("divider"))[0].key;
|
||||||
|
this.activeLink = link;
|
||||||
router.push({ name: `admin-${this.activeNavigation}-${link}` });
|
router.push({ name: `admin-${this.activeNavigation}-${link}` });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue