菜单找开方式内嵌
This commit is contained in:
parent
1668d7a10b
commit
76c04ec199
@ -27,23 +27,20 @@ export const ErrorPageRoute: AppRouteRecordRaw = {
|
|||||||
|
|
||||||
|
|
||||||
export const AboutPageRoute: AppRouteRecordRaw ={
|
export const AboutPageRoute: AppRouteRecordRaw ={
|
||||||
path: '/about',
|
path: '/monitorJob',
|
||||||
name: 'about',
|
name: 'monitorJob',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
meta: {
|
meta: {
|
||||||
sort: 12,
|
sort: 12,
|
||||||
isRoot: true,
|
isRoot: true,
|
||||||
activeMenu: 'about_index',
|
|
||||||
alwaysShow: true,
|
|
||||||
icon: renderIcon(ProjectOutlined),
|
icon: renderIcon(ProjectOutlined),
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: 'index',
|
path: 'log',
|
||||||
name: `about_index`,
|
name: `monitorJob`,
|
||||||
meta: {
|
meta: {
|
||||||
title: '关于项目',
|
title: '关于项目',
|
||||||
activeMenu: 'about_index',
|
|
||||||
},
|
},
|
||||||
component: () => import('@/views/about/index.vue'),
|
component: () => import('@/views/about/index.vue'),
|
||||||
},
|
},
|
||||||
|
@ -20,22 +20,32 @@ LayoutMap.set('IFRAME', Iframe);
|
|||||||
*/
|
*/
|
||||||
export const routerGenerator = (routerMap, parent?): any[] => {
|
export const routerGenerator = (routerMap, parent?): any[] => {
|
||||||
return routerMap.map((item) => {
|
return routerMap.map((item) => {
|
||||||
|
const names = /http(s)?:/.test(item.path)?item.path:item.path.replaceAll('/','')
|
||||||
item.meta = {
|
item.meta = {
|
||||||
title:item.name,
|
title:item.parentId==0 && item.children.length==0?'':item.name,
|
||||||
icon:item.icon,
|
icon:item.icon,
|
||||||
sort:item.sort,
|
sort:item.sort,
|
||||||
permissions:item.permission,
|
permissions:item.permission,
|
||||||
hidden: item.hide?true:false,
|
hidden: item.hide?true:false,
|
||||||
|
isRoot:item.parentId==0 && item.children.length==0?true:false,
|
||||||
|
alwaysShow: item.parentId==0 && item.children.length==0?true:false,
|
||||||
|
frameSrc: item.target==1?item.component:'',
|
||||||
|
}
|
||||||
|
let components = ''
|
||||||
|
if(item.parentId==0 && item.children.length==0) {
|
||||||
|
components ='LAYOUT'
|
||||||
|
} else if(item.target==0) {
|
||||||
|
components = item.component
|
||||||
|
} else if(item.target==1) {
|
||||||
|
components ='IFRAME'
|
||||||
}
|
}
|
||||||
const components =''
|
|
||||||
const names = /http(s)?:/.test(item.path)?item.path:item.path.replaceAll('/','')
|
|
||||||
const currentRouter: any = {
|
const currentRouter: any = {
|
||||||
// 路由地址 动态拼接生成如 /dashboard/workplace
|
// 路由地址 动态拼接生成如 /dashboard/workplace
|
||||||
path: `${item.path}`,
|
path: item.target!=2?item.path:'',
|
||||||
// 路由名称,建议唯一
|
// 路由名称,建议唯一
|
||||||
name: names,
|
name: names,
|
||||||
// 该路由对应页面的 组件
|
// 该路由对应页面的 组件
|
||||||
component: item.component,
|
component: components,
|
||||||
// meta: 页面标题, 菜单图标, 页面权限(供指令权限用,可去掉)
|
// meta: 页面标题, 菜单图标, 页面权限(供指令权限用,可去掉)
|
||||||
meta: {
|
meta: {
|
||||||
...item.meta,
|
...item.meta,
|
||||||
@ -44,9 +54,8 @@ export const routerGenerator = (routerMap, parent?): any[] => {
|
|||||||
permissions: item.meta.permissions || null,
|
permissions: item.meta.permissions || null,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// 为了防止出现后端返回结果不规范,处理有可能出现拼接出两个 反斜杠
|
// 为了防止出现后端返回结果不规范,处理有可能出现拼接出两个 反斜杠
|
||||||
currentRouter.path = currentRouter.path.replace('//', '/');
|
// currentRouter.path = currentRouter.path.replace('//', '/');
|
||||||
// 重定向
|
// 重定向
|
||||||
item.redirect && (currentRouter.redirect = item.redirect);
|
item.redirect && (currentRouter.redirect = item.redirect);
|
||||||
// 是否有子菜单,并递归处理
|
// 是否有子菜单,并递归处理
|
||||||
@ -55,6 +64,31 @@ export const routerGenerator = (routerMap, parent?): any[] => {
|
|||||||
!item.redirect && (currentRouter.redirect = `${item.children[0].path}`);
|
!item.redirect && (currentRouter.redirect = `${item.children[0].path}`);
|
||||||
// Recursion
|
// Recursion
|
||||||
currentRouter.children = routerGenerator(item.children, currentRouter);
|
currentRouter.children = routerGenerator(item.children, currentRouter);
|
||||||
|
} else {
|
||||||
|
if(item.parentId==0 && item.children.length==0) {
|
||||||
|
currentRouter.children =[]
|
||||||
|
if(item.target==1){
|
||||||
|
currentRouter.children.push({
|
||||||
|
path: item.path,
|
||||||
|
name: names,
|
||||||
|
meta: {
|
||||||
|
title: item.name,
|
||||||
|
frameSrc: item.component,
|
||||||
|
},
|
||||||
|
component: 'IFRAME',
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
currentRouter.children.push({
|
||||||
|
path: item.path,
|
||||||
|
name: names,
|
||||||
|
meta: {
|
||||||
|
title: item.name,
|
||||||
|
activeMenu: names,
|
||||||
|
},
|
||||||
|
component: item.component,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return currentRouter;
|
return currentRouter;
|
||||||
});
|
});
|
||||||
@ -69,6 +103,7 @@ export const generatorDynamicRouter = (): Promise<RouteRecordRaw[]> => {
|
|||||||
adminMenus()
|
adminMenus()
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
const routeList = routerGenerator(result);
|
const routeList = routerGenerator(result);
|
||||||
|
console.log(routeList)
|
||||||
asyncImportRoute(routeList);
|
asyncImportRoute(routeList);
|
||||||
resolve(routeList);
|
resolve(routeList);
|
||||||
})
|
})
|
||||||
|
@ -41,7 +41,7 @@ const setting = {
|
|||||||
//折叠
|
//折叠
|
||||||
collapsed: false,
|
collapsed: false,
|
||||||
//手风琴
|
//手风琴
|
||||||
uniqueOpened: false,
|
uniqueOpened: true,
|
||||||
},
|
},
|
||||||
//面包屑
|
//面包屑
|
||||||
crumbsSetting: {
|
crumbsSetting: {
|
||||||
|
@ -55,14 +55,15 @@
|
|||||||
<IconPicker class="flex-1" v-model="formData.icon"/>
|
<IconPicker class="flex-1" v-model="formData.icon"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item
|
<el-form-item
|
||||||
label="是否外链"
|
label="打开方式"
|
||||||
prop="target"
|
prop="target"
|
||||||
v-if="formData.type==0"
|
v-if="formData.type==0"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<el-radio-group v-model="formData.target">
|
<el-radio-group v-model="formData.target">
|
||||||
<el-radio :label="1">是</el-radio>
|
<el-radio :label="0">组件</el-radio>
|
||||||
<el-radio :label="0">否</el-radio>
|
<el-radio :label="1">内链</el-radio>
|
||||||
|
<el-radio :label="2">外链</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
<div class="form-tips">
|
<div class="form-tips">
|
||||||
选择外链,则新窗口打开页面
|
选择外链,则新窗口打开页面
|
||||||
@ -82,15 +83,15 @@
|
|||||||
clearable
|
clearable
|
||||||
/>
|
/>
|
||||||
<div class="form-tips">
|
<div class="form-tips">
|
||||||
访问的路由地址,如:`admin`,如外网地址需内链访问则以`http(s)://`开头
|
访问的路由地址
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item
|
<el-form-item
|
||||||
v-if="formData.type == 0 && formData.target ==0 && formData.parentId!=0"
|
v-if="formData.type == 0 && (formData.target ==0 || formData.target ==1)"
|
||||||
label="组件路径"
|
label="组件路径"
|
||||||
prop="component"
|
prop="component"
|
||||||
:rules="{ required: true, message: '请输入组件路径', trigger: 'blur' }"
|
:rules="{ required: true, message: '请输入组件路径', trigger: 'blur' }"
|
||||||
>
|
>
|
||||||
<div class="flex-1">
|
<div class="flex-1">
|
||||||
<el-autocomplete
|
<el-autocomplete
|
||||||
@ -101,7 +102,7 @@
|
|||||||
placeholder="请输入组件路径"
|
placeholder="请输入组件路径"
|
||||||
/>
|
/>
|
||||||
<div class="form-tips">
|
<div class="form-tips">
|
||||||
访问的组件路径,如:`permission/admin/index`,默认在`views`目录下
|
访问的组件路径,如:`permission/admin/index`,默认在`views`目录下,如外网地址需内链访问则以`http(s)://`开头
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
Loading…
Reference in New Issue
Block a user