Authored by 毕凯

侧边栏导航

const normalMenus = [
{
title: 'Dashboard',
link: '/',
icon: 'ios-home',
isClassic: true
},
{
title: '缓存管理',
icon: 'document-text',
subMenus: [{
title: 'PageCahe清理',
link: '/page_cache/query',
isClassic: true
}, {
title: 'CDN清理',
link: '/cdn_cache/query',
isClassic: true
}, {
title: '商品清理',
link: '/product_cache/query',
isClassic: true
}, {
title: 'Memcached',
link: '/api_cache',
isClassic: true
}]
},
{
title: '降级配置',
icon: 'document-text',
link: '/degrade',
isClassic: true
},
{
title: '滥用防护',
icon: 'document-text',
subMenus: [{
title: 'IP黑名单',
link: '/crawler_black/ip',
isClassic: true
}, {
title: 'IP白名单',
link: '/crawler_white/ip',
isClassic: true
}, {
title: 'UA黑名单',
link: '/crawler_black/ua',
isClassic: true
}, {
title: 'UA白名单',
link: '/crawler_white/ua',
isClassic: true
}, {
title: '风险控制',
link: '/risk_management/risk_management',
isClassic: true
}]
},
{
title: '静态资源',
icon: 'document-text',
subMenus: [{
title: '活动上传',
link: '/files/page',
isClassic: true
}, {
title: '单文件上传',
link: '/files/single-file',
isClassic: true
}]
},
{
title: 'SEO管理',
icon: 'document-text',
subMenus: [{
title: '词根管理',
link: '/seo/rootwords',
isClassic: true
}, {
title: '关键词管理',
link: '/keywords/expand',
isClassic: true
}, {
title: 'TDK管理',
link: '/seo/tdk',
isClassic: true
}, {
title: '品类描述管理',
link: '/seo/category',
isClassic: true
}, {
title: '友链管理',
link: '/seo/friendlink',
isClassic: true
}, {
title: '定时任务管理',
link: '/seo/task',
isClassic: true
}]
},
{
title: '性能统计',
icon: 'document-text',
subMenus: [{
title: '浏览器排行榜',
link: '/profile/sort_client',
isClassic: true
}, {
title: '服务器路由排行榜',
link: '/profile/sort_route',
isClassic: true
}, {
title: 'api排行榜',
link: '/profile/sort_api',
isClassic: true
}, {
title: '错误信息统计',
link: '/profile/error',
isClassic: true
}]
},
{
title: '日志查询',
icon: 'document-text',
subMenus: [{
title: 'Node 日志',
link: '/logs/node'
}]
}
]
const masterMenus = [
{
title: '系统管理',
icon: 'document-text',
subMenus: [{
title: '服务器配置',
link: '/servers/setting',
isClassic: true
}, {
title: '用户管理',
link: '/users/setting',
isClassic: true
}, {
title: '操作记录',
link: '/operation/log',
isClassic: true
}]
}
]
const businessMenus = [
{
title: 'Dashboard',
link: '/',
icon: 'ios-home',
isClassic: true
},
{
title: 'CDN清理',
link: '/cdn_cache/query',
icon: 'ios-home',
isClassic: true
},
{
title: '活动上传',
link: '/files/page',
icon: 'ios-home',
isClassic: true
}
]
module.exports = {
normalMenus,
masterMenus,
businessMenus
}
\ No newline at end of file
... ...
<template>
<Menu class="sidebar-menu" active-name="1-2" theme="light" width="auto" :open-names="['1']">
<MenuItem name="1">
<a href="/">
<Icon type="ios-home"></Icon>
Dashboard
</a>
</MenuItem>
<Submenu name="2">
<template slot="title">
<Icon type="document-text"></Icon>
日志查询
</template>
<MenuItem name="2-1">
<router-link to="/logs/node">
Node 日志
<Menu class="sidebar-menu" theme="light" width="auto">
<template v-for="(menu, index) in menus">
<Submenu v-if="menu.subMenus" :name="index">
<template slot="title">
<Icon :type="menu.icon"></Icon>
{{menu.title}}
</template>
<template v-for="(subMenu, subIndex) in menu.subMenus">
<MenuItem :name="`${index}-${subIndex}`">
<a v-if="subMenu.isClassic" :href="subMenu.link">
<Icon :type="subMenu.icon"></Icon>
{{subMenu.title}}
</a>
<router-link v-else :to="subMenu.link">
{{subMenu.title}}
</router-link>
</MenuItem>
</template>
</Submenu>
<MenuItem v-else :name="index">
<a v-if="menu.isClassic" :href="menu.link">
<Icon :type="menu.icon"></Icon>
{{menu.title}}
</a>
<router-link v-else :to="menu.link">
<Icon :type="menu.icon"></Icon>
{{menu.title}}
</router-link>
</MenuItem>
</Submenu>
</template>
</Menu>
</template>
<script>
import {
normalMenus,
masterMenus,
businessMenus
} from '../../../../config/menus' // 考虑与原有业务复用
export default {
props: ['user']
props: ['user'],
computed: {
isMaster: function() {
return this.user.role === '1000'
},
isBusiness: function() {
return this.user.role === '3000'
},
menus: function() {
if (this.isBusiness) {
return businessMenus
}
if (this.isMaster) {
return [...normalMenus, ...masterMenus]
}
return normalMenus
}
}
}
</script>
... ...