feat: 新增菜单支持主框架外展示配置
parent
50f64fdf08
commit
c322d00fde
|
@ -183,6 +183,7 @@ class Menu(CoreModel):
|
|||
component_name = models.CharField(max_length=50, verbose_name="组件名称", null=True, blank=True,
|
||||
help_text="组件名称")
|
||||
status = models.BooleanField(default=True, blank=True, verbose_name="菜单状态", help_text="菜单状态")
|
||||
frame_out = models.BooleanField(default=False, blank=True, verbose_name="是否主框架外", help_text="是否主框架外")
|
||||
cache = models.BooleanField(default=False, blank=True, verbose_name="是否页面缓存", help_text="是否页面缓存")
|
||||
visible = models.BooleanField(default=True, blank=True, verbose_name="侧边栏中是否显示",
|
||||
help_text="侧边栏中是否显示")
|
||||
|
|
|
@ -146,7 +146,7 @@ class WebRouterSerializer(CustomModelSerializer):
|
|||
class Meta:
|
||||
model = Menu
|
||||
fields = ('id', 'parent', 'icon', 'sort', 'path', 'name', 'title', 'is_link', 'is_catalog', 'web_path', 'component',
|
||||
'component_name', 'cache', 'visible', 'menuPermission')
|
||||
'component_name', 'cache', 'visible', 'menuPermission', 'frame_out')
|
||||
read_only_fields = ["id"]
|
||||
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import { uniqueId } from 'lodash'
|
||||
import { request } from '@/api/service'
|
||||
import XEUtils from 'xe-utils'
|
||||
import { frameInRoutes } from '@/router/routes'
|
||||
import { frameInRoutes, frameOutRoutes } from '@/router/routes'
|
||||
const _import = require('@/libs/util.import.' + process.env.NODE_ENV)
|
||||
const pluginImport = require('@/libs/util.import.plugin')
|
||||
/**
|
||||
|
@ -79,7 +79,11 @@ export const handleRouter = function (menuData) {
|
|||
cache: item.cache
|
||||
}
|
||||
}
|
||||
if (item.frame_out) {
|
||||
frameOutRoutes.push(obj)
|
||||
} else {
|
||||
result.push(obj)
|
||||
}
|
||||
} else {
|
||||
if (item.is_link === 0) {
|
||||
delete item.path
|
||||
|
@ -87,7 +91,7 @@ export const handleRouter = function (menuData) {
|
|||
}
|
||||
}
|
||||
frameInRoutes[0].children = [...result]
|
||||
return frameInRoutes
|
||||
return { routes: frameInRoutes, frameOut: frameOutRoutes }
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,7 +30,7 @@ VueRouter.prototype.replace = function replace (location) {
|
|||
}
|
||||
|
||||
Vue.use(VueRouter)
|
||||
|
||||
console.log(routes)
|
||||
// 导出路由 在 main.js 里使用
|
||||
const router = new VueRouter({
|
||||
routes
|
||||
|
@ -72,11 +72,17 @@ router.beforeEach(async (to, from, next) => {
|
|||
getMenu().then(ret => {
|
||||
// 校验路由是否有效
|
||||
ret = checkRouter(ret)
|
||||
const routes = handleRouter(ret)
|
||||
const { routes, frameOut } = handleRouter(ret)
|
||||
// 处理路由 得到每一级的路由设置
|
||||
store.commit('d2admin/page/init', routes)
|
||||
|
||||
router.addRoutes(routes)
|
||||
routes.map((r) => {
|
||||
router.addRoute(r)
|
||||
})
|
||||
frameOut.map((r) => {
|
||||
router.addRoute(r)
|
||||
router.options.routes.push(r)
|
||||
})
|
||||
console.log('router', router, routes, frameOut)
|
||||
// routes.forEach(route => router.addRoute(route))
|
||||
|
||||
const menu = handleAsideMenu(ret)
|
||||
|
|
|
@ -100,6 +100,7 @@ const errorPage = [{
|
|||
|
||||
// 导出需要显示菜单的
|
||||
export const frameInRoutes = frameIn
|
||||
export const frameOutRoutes = frameOut
|
||||
|
||||
// 重新组织后导出
|
||||
export default [
|
||||
|
|
|
@ -449,6 +449,32 @@ export const crudOptions = (vm) => {
|
|||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
title: '主框架外展示',
|
||||
key: 'frame_out',
|
||||
search: {
|
||||
disabled: false
|
||||
},
|
||||
width: 75,
|
||||
type: 'radio',
|
||||
dict: {
|
||||
data: vm.dictionary('button_whether_bool')
|
||||
},
|
||||
form: {
|
||||
value: false,
|
||||
component: {
|
||||
placeholder: '请选择主框架外展示'
|
||||
},
|
||||
rules: [ // 表单校验规则
|
||||
{ required: true, message: '主框架外展示必填项' }
|
||||
],
|
||||
helper: {
|
||||
render (h) {
|
||||
return (< el-alert title="是否显示在主框架外展示" type="warning" />
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
|
|
Loading…
Reference in New Issue