前端导航栏更新

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) {
this.editedIndex = this.desserts.indexOf(item);
this.editedIndex = item.id;
this.editedItem = Object.assign({}, item);
this.dialog = true;
},

View File

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

View File

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

View File

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

View File

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