Merge branch 'master' into deploy
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
<template>
|
||||
<router-view />
|
||||
</template>
|
||||
<template>
|
||||
<router-view />
|
||||
</template>
|
||||
@@ -12,7 +12,7 @@
|
||||
:collapse-transition="false"
|
||||
mode="vertical"
|
||||
>
|
||||
<sidebar-item v-for="route in permission_routers" :key="route.path" :item="route" :base-path="route.path" />
|
||||
<sidebar-item v-for="route in sidebarRouters" :key="route.path" :item="route" :base-path="route.path" />
|
||||
</el-menu>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
@@ -28,7 +28,7 @@ export default {
|
||||
components: { SidebarItem, Logo },
|
||||
computed: {
|
||||
...mapGetters([
|
||||
'permission_routers',
|
||||
'sidebarRouters',
|
||||
'sidebar'
|
||||
]),
|
||||
activeMenu() {
|
||||
|
||||
@@ -53,12 +53,17 @@ router.beforeEach((to, from, next) => {
|
||||
|
||||
export const loadMenus = (next, to) => {
|
||||
buildMenus().then(res => {
|
||||
const asyncRouter = filterAsyncRouter(res)
|
||||
asyncRouter.push({ path: '*', redirect: '/404', hidden: true })
|
||||
store.dispatch('GenerateRoutes', asyncRouter).then(() => { // 存储路由
|
||||
router.addRoutes(asyncRouter) // 动态添加可访问路由表
|
||||
const sdata = JSON.parse(JSON.stringify(res))
|
||||
const rdata = JSON.parse(JSON.stringify(res))
|
||||
const sidebarRoutes = filterAsyncRouter(sdata)
|
||||
const rewriteRoutes = filterAsyncRouter(rdata, true)
|
||||
rewriteRoutes.push({ path: '*', redirect: '/404', hidden: true })
|
||||
|
||||
store.dispatch('GenerateRoutes', rewriteRoutes).then(() => { // 存储路由
|
||||
router.addRoutes(rewriteRoutes) // 动态添加可访问路由表
|
||||
next({ ...to, replace: true })
|
||||
})
|
||||
store.dispatch('SetSidebarRouters', sidebarRoutes)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ const getters = {
|
||||
updateAvatarApi: state => state.api.updateAvatarApi,
|
||||
qiNiuUploadApi: state => state.api.qiNiuUploadApi,
|
||||
sqlApi: state => state.api.sqlApi,
|
||||
swaggerApi: state => state.api.swaggerApi
|
||||
swaggerApi: state => state.api.swaggerApi,
|
||||
sidebarRouters: state => state.permission.sidebarRouters
|
||||
}
|
||||
export default getters
|
||||
|
||||
@@ -1,41 +1,76 @@
|
||||
import { constantRouterMap } from '@/router/routers'
|
||||
import Layout from '@/layout/index'
|
||||
import ParentView from '@/components/ParentView'
|
||||
|
||||
const permission = {
|
||||
state: {
|
||||
routers: constantRouterMap,
|
||||
addRouters: []
|
||||
addRouters: [],
|
||||
sidebarRouters: []
|
||||
},
|
||||
mutations: {
|
||||
SET_ROUTERS: (state, routers) => {
|
||||
state.addRouters = routers
|
||||
state.routers = constantRouterMap.concat(routers)
|
||||
},
|
||||
SET_SIDEBAR_ROUTERS: (state, routers) => {
|
||||
state.sidebarRouters = routers
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
GenerateRoutes({ commit }, asyncRouter) {
|
||||
commit('SET_ROUTERS', asyncRouter)
|
||||
},
|
||||
SetSidebarRouters({ commit }, sidebarRouter) {
|
||||
commit('SET_SIDEBAR_ROUTERS', sidebarRouter)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const filterAsyncRouter = (routers) => { // 遍历后台传来的路由字符串,转换为组件对象
|
||||
export const filterAsyncRouter = (routers, isRewrite = false) => { // 遍历后台传来的路由字符串,转换为组件对象
|
||||
return routers.filter(router => {
|
||||
if (isRewrite && router.children) {
|
||||
router.children = filterChildren(router.children)
|
||||
}
|
||||
if (router.component) {
|
||||
if (router.component === 'Layout') { // Layout组件特殊处理
|
||||
router.component = Layout
|
||||
} else if (router.component === 'ParentView') {
|
||||
router.component = ParentView
|
||||
} else {
|
||||
const component = router.component
|
||||
router.component = loadView(component)
|
||||
}
|
||||
}
|
||||
if (router.children && router.children.length) {
|
||||
router.children = filterAsyncRouter(router.children)
|
||||
router.children = filterAsyncRouter(router.children, router, isRewrite)
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
function filterChildren(childrenMap) {
|
||||
var children = []
|
||||
childrenMap.forEach((el, index) => {
|
||||
if (el.children && el.children.length) {
|
||||
if (el.component === 'ParentView') {
|
||||
el.children.forEach(c => {
|
||||
c.path = el.path + '/' + c.path
|
||||
if (c.children && c.children.length) {
|
||||
children = children.concat(filterChildren(c.children, c))
|
||||
return
|
||||
}
|
||||
children.push(c)
|
||||
})
|
||||
childrenMap.splice(index, 1)
|
||||
return
|
||||
}
|
||||
}
|
||||
children = children.concat(el)
|
||||
})
|
||||
return children
|
||||
}
|
||||
|
||||
export const loadView = (view) => {
|
||||
return (resolve) => require([`@/views/${view}`], resolve)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import JSEncrypt from 'jsencrypt/bin/jsencrypt'
|
||||
import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'
|
||||
|
||||
// 密钥对生成 http://web.chacuo.net/netrsakeypair
|
||||
|
||||
|
||||
@@ -1,5 +1,36 @@
|
||||
<template>
|
||||
<div style="padding:30px;">
|
||||
<div class="app-container">
|
||||
<el-alert :closable="false" title="三级菜单1" type="success" />
|
||||
<el-form label-width="170px" style="margin-top: 20px">
|
||||
<el-form-item label="三级菜单缓存功能测试区">
|
||||
<el-input v-model="input" placeholder="请输入内容" style="width: 360px;" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div>
|
||||
<blockquote class="my-blockquote"> 三级菜单缓存配置教程</blockquote>
|
||||
<pre class="my-code">
|
||||
1、将前后端代码更新为最新版版本,或对照提交记录修改,点击查看-> <a href="https://gitee.com/elunez/eladmin/commit/43d1a63577f9d5347924355708429a2d210e29f7" target="_blank">提交(1)</a>、<a href="https://gitee.com/elunez/eladmin/commit/46393875148fcca5eaa327d4073f72edb3752f5c" target="_blank">提交(2)</a>、<a href="https://gitee.com/elunez/eladmin-web/commit/c93c99d8921abbb2c52afc806635f5ca08d6bda8" target="_blank">提交(3)</a>
|
||||
2、将 二级菜单 的 菜单类型 设置为 目录 级别,并且原有的 组件路径 需要清空
|
||||
3、将 三级菜单 的 菜单缓存 设置为 是,最后将 组件名称 填写正确
|
||||
4、具体设置可参考 菜单管理 的 多级菜单 配置进行进行相应的修改
|
||||
</pre>
|
||||
<blockquote class="my-blockquote">更多帮助</blockquote>
|
||||
<pre class="my-code">QQ交流群:一群:891137268、二群:947578238</pre>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: 'Test',
|
||||
data() {
|
||||
return {
|
||||
input: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.my-code a{
|
||||
color:#009688;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user