前端导航栏更新

This commit is contained in:
橙子
2021-10-23 02:09:10 +08:00
parent 6bc67cbf06
commit eb15667d21
6 changed files with 45 additions and 49 deletions

View File

@@ -177,7 +177,7 @@ export default {
}); });
}, },
editItem(item) { editItem(item) {
this.editedIndex = this.desserts.indexOf(item); this.editedIndex = item.id;
this.editedItem = Object.assign({}, item); this.editedItem = Object.assign({}, item);
this.dialog = true; this.dialog = true;
}, },

View File

@@ -68,67 +68,65 @@ export default {
items: [ items: [
{ {
title: "首页", menu_name: "首页",
icon: "mdi-view-dashboard", icon: "mdi-view-dashboard",
to: "/", router: "/",
}, },
{ {
title: "用户角色管理", menu_name: "用户角色管理",
icon: "mdi-account", icon: "mdi-account",
to: "", router: "",
children: [ children: [
{ {
title: "用户管理", menu_name: "用户管理",
icon: "mdi-account", icon: "mdi-account",
to: "/admuser/", router: "/admuser/",
children: [ children: null,
],
}, },
{ {
title: "角色管理", menu_name: "角色管理",
icon: "mdi-account-tie", icon: "mdi-account-tie",
to: "/admrole/", router: "/admrole/",
children: [], children: null,
}, },
], ],
}, },
{ {
title: "菜单接口管理", menu_name: "菜单接口管理",
icon: "mdi-clipboard-outline", icon: "mdi-clipboard-outline",
to: "", router: "",
children: [ children: [
{ {
title: "菜单管理", menu_name: "菜单管理",
icon: "mdi-account", icon: "mdi-account",
to: "/admMenu/", router: "/admMenu/",
children: [], children: null,
}, },
{ {
title: "接口管理", menu_name: "接口管理",
icon: "mdi-account", icon: "mdi-account",
to: "/admMould/", router: "/admMould/",
children: [], children: null,
}, },
{ {
title: "角色菜单分配管理", menu_name: "角色菜单分配管理",
icon: "mdi-account", icon: "mdi-account",
to: "/admRoleMenu/", router: "/admRoleMenu/",
children: [], children: null,
}, },
], ],
}, },
{ {
title: "测试路由", menu_name: "测试路由",
icon: "mdi-clipboard-outline", icon: "mdi-clipboard-outline",
to: "", router: "",
children: [ children: [
{ {
title: "用户信息", menu_name: "用户信息",
icon: "mdi-account", icon: "mdi-account",
to: "/userinfo/", router: "/userinfo/",
children: [], children: null,
} },
], ],
}, },
], ],

View File

@@ -1,7 +1,7 @@
<template> <template>
<v-list-group <v-list-group
:group="group"
:prepend-icon="item.icon" :prepend-icon="item.icon"
eager eager
v-bind="$attrs" v-bind="$attrs"
@@ -19,20 +19,20 @@
<v-img :src="item.avatar" /> <v-img :src="item.avatar" />
</v-list-item-avatar> </v-list-item-avatar>
<v-list-item-content v-if="item.title"> <v-list-item-content v-if="item.menu_name">
<v-list-item-title v-text="item.title" /> <v-list-item-title v-text="item.menu_name" />
</v-list-item-content> </v-list-item-content>
</template> </template>
<template v-for="(child, i) in item.children"> <template v-for="(child, i) in item.children">
<default-list-group <default-list-group
v-if="child.items" v-if="child.children"
:key="`sub-group-${i}`" :key="`sub-group-${i}`"
:item="child" :item="child"
/> />
<default-list-item <default-list-item
v-if="!child.items" v-if="!child.children"
:key="`child-${i}`" :key="`child-${i}`"
:item="child" :item="child"
/> />
@@ -60,11 +60,11 @@
computed: { computed: {
// group () { group () {
// return this.genGroup(this.item.items) return this.genGroup(this.item.children)
// }, },
title () { title () {
const matches = this.item.title.match(/\b(\w)/g) const matches = this.item.menu_name.match(/\b(\w)/g)
return matches.join('') return matches.join('')
}, },
@@ -73,12 +73,12 @@
methods: { methods: {
genGroup (items) { genGroup (items) {
return items.reduce((acc, cur) => { return items.reduce((acc, cur) => {
if (!cur.to) return acc if (!cur.router) return acc
acc.push( acc.push(
cur.items cur.children
? this.genGroup(cur.items) ? this.genGroup(cur.children)
: cur.to.slice(1, -1), : cur.router.slice(1, -1),
) )
return acc return acc

View File

@@ -3,7 +3,7 @@
:href="item.href" :href="item.href"
:rel="item.href ? 'nofollow' : undefined" :rel="item.href ? 'nofollow' : undefined"
:target="item.href ? '_blank' : undefined" :target="item.href ? '_blank' : undefined"
:to="item.to" :to="item.router"
active-class="primary white--text" active-class="primary white--text"
link link
class="py-1" class="py-1"
@@ -28,8 +28,8 @@
<v-icon v-text="item.icon" /> <v-icon v-text="item.icon" />
</v-list-item-icon> </v-list-item-icon>
<v-list-item-content v-if="item.title"> <v-list-item-content v-if="item.menu_name">
<v-list-item-title v-text="item.title" /> <v-list-item-title v-text="item.menu_name" />
</v-list-item-content> </v-list-item-content>
</v-list-item> </v-list-item>
</template> </template>
@@ -47,7 +47,7 @@
computed: { computed: {
title () { title () {
const matches = this.item.title.match(/\b(\w)/g) const matches = this.item.menu_name.match(/\b(\w)/g)
return matches.join('') return matches.join('')
}, },

View File

@@ -5,13 +5,11 @@ function getUrl(menuList, menuStr) {
if (start) { if (start) {
for (var i = 0; i < menuList.length; i++) { for (var i = 0; i < menuList.length; i++) {
if (menuList[i].menu_name == menuStr) { if (menuList[i].menu_name == menuStr) {
alert(777)
start = false; start = false;
console.log(handUrl(menuList[i])) console.log(handUrl(menuList[i]))
return handUrl(menuList[i]) return handUrl(menuList[i])
} else { } else {
if (menuList[i].children != undefined && start) { if (menuList[i].children != undefined && start) {
alert(666)
getUrl(menuList[i].children, menuStr); getUrl(menuList[i].children, menuStr);
} }