Merge branch 'master' into deploy
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
<template>
|
<template>
|
||||||
<router-view />
|
<router-view />
|
||||||
</template>
|
</template>
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
:collapse-transition="false"
|
:collapse-transition="false"
|
||||||
mode="vertical"
|
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-menu>
|
||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
</div>
|
</div>
|
||||||
@@ -28,7 +28,7 @@ export default {
|
|||||||
components: { SidebarItem, Logo },
|
components: { SidebarItem, Logo },
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters([
|
...mapGetters([
|
||||||
'permission_routers',
|
'sidebarRouters',
|
||||||
'sidebar'
|
'sidebar'
|
||||||
]),
|
]),
|
||||||
activeMenu() {
|
activeMenu() {
|
||||||
|
|||||||
@@ -53,12 +53,17 @@ router.beforeEach((to, from, next) => {
|
|||||||
|
|
||||||
export const loadMenus = (next, to) => {
|
export const loadMenus = (next, to) => {
|
||||||
buildMenus().then(res => {
|
buildMenus().then(res => {
|
||||||
const asyncRouter = filterAsyncRouter(res)
|
const sdata = JSON.parse(JSON.stringify(res))
|
||||||
asyncRouter.push({ path: '*', redirect: '/404', hidden: true })
|
const rdata = JSON.parse(JSON.stringify(res))
|
||||||
store.dispatch('GenerateRoutes', asyncRouter).then(() => { // 存储路由
|
const sidebarRoutes = filterAsyncRouter(sdata)
|
||||||
router.addRoutes(asyncRouter) // 动态添加可访问路由表
|
const rewriteRoutes = filterAsyncRouter(rdata, true)
|
||||||
|
rewriteRoutes.push({ path: '*', redirect: '/404', hidden: true })
|
||||||
|
|
||||||
|
store.dispatch('GenerateRoutes', rewriteRoutes).then(() => { // 存储路由
|
||||||
|
router.addRoutes(rewriteRoutes) // 动态添加可访问路由表
|
||||||
next({ ...to, replace: true })
|
next({ ...to, replace: true })
|
||||||
})
|
})
|
||||||
|
store.dispatch('SetSidebarRouters', sidebarRoutes)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ const getters = {
|
|||||||
updateAvatarApi: state => state.api.updateAvatarApi,
|
updateAvatarApi: state => state.api.updateAvatarApi,
|
||||||
qiNiuUploadApi: state => state.api.qiNiuUploadApi,
|
qiNiuUploadApi: state => state.api.qiNiuUploadApi,
|
||||||
sqlApi: state => state.api.sqlApi,
|
sqlApi: state => state.api.sqlApi,
|
||||||
swaggerApi: state => state.api.swaggerApi
|
swaggerApi: state => state.api.swaggerApi,
|
||||||
|
sidebarRouters: state => state.permission.sidebarRouters
|
||||||
}
|
}
|
||||||
export default getters
|
export default getters
|
||||||
|
|||||||
@@ -1,41 +1,76 @@
|
|||||||
import { constantRouterMap } from '@/router/routers'
|
import { constantRouterMap } from '@/router/routers'
|
||||||
import Layout from '@/layout/index'
|
import Layout from '@/layout/index'
|
||||||
|
import ParentView from '@/components/ParentView'
|
||||||
|
|
||||||
const permission = {
|
const permission = {
|
||||||
state: {
|
state: {
|
||||||
routers: constantRouterMap,
|
routers: constantRouterMap,
|
||||||
addRouters: []
|
addRouters: [],
|
||||||
|
sidebarRouters: []
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
SET_ROUTERS: (state, routers) => {
|
SET_ROUTERS: (state, routers) => {
|
||||||
state.addRouters = routers
|
state.addRouters = routers
|
||||||
state.routers = constantRouterMap.concat(routers)
|
state.routers = constantRouterMap.concat(routers)
|
||||||
|
},
|
||||||
|
SET_SIDEBAR_ROUTERS: (state, routers) => {
|
||||||
|
state.sidebarRouters = routers
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
GenerateRoutes({ commit }, asyncRouter) {
|
GenerateRoutes({ commit }, asyncRouter) {
|
||||||
commit('SET_ROUTERS', 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 => {
|
return routers.filter(router => {
|
||||||
|
if (isRewrite && router.children) {
|
||||||
|
router.children = filterChildren(router.children)
|
||||||
|
}
|
||||||
if (router.component) {
|
if (router.component) {
|
||||||
if (router.component === 'Layout') { // Layout组件特殊处理
|
if (router.component === 'Layout') { // Layout组件特殊处理
|
||||||
router.component = Layout
|
router.component = Layout
|
||||||
|
} else if (router.component === 'ParentView') {
|
||||||
|
router.component = ParentView
|
||||||
} else {
|
} else {
|
||||||
const component = router.component
|
const component = router.component
|
||||||
router.component = loadView(component)
|
router.component = loadView(component)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (router.children && router.children.length) {
|
if (router.children && router.children.length) {
|
||||||
router.children = filterAsyncRouter(router.children)
|
router.children = filterAsyncRouter(router.children, router, isRewrite)
|
||||||
}
|
}
|
||||||
return true
|
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) => {
|
export const loadView = (view) => {
|
||||||
return (resolve) => require([`@/views/${view}`], resolve)
|
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
|
// 密钥对生成 http://web.chacuo.net/netrsakeypair
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,36 @@
|
|||||||
<template>
|
<template>
|
||||||
<div style="padding:30px;">
|
<div class="app-container">
|
||||||
<el-alert :closable="false" title="三级菜单1" type="success" />
|
<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>
|
</div>
|
||||||
</template>
|
</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