fix:调整菜单,增加根目录路径获取

pull/180/head
Layne Cai 4 years ago
parent 36c1732428
commit 142bba8f75

@ -21,6 +21,11 @@ public class RouterVo
*/ */
private String path; private String path;
/**
* ,
*/
private Boolean top;
/** /**
* true * true
*/ */
@ -76,6 +81,14 @@ public class RouterVo
this.path = path; this.path = path;
} }
public Boolean getTop() {
return top;
}
public void setTop(Boolean top) {
this.top = top;
}
public boolean getHidden() public boolean getHidden()
{ {
return hidden; return hidden;

@ -157,6 +157,7 @@ public class SysMenuServiceImpl implements ISysMenuService
if (!cMenus.isEmpty() && cMenus.size() > 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType())) if (!cMenus.isEmpty() && cMenus.size() > 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType()))
{ {
router.setAlwaysShow(true); router.setAlwaysShow(true);
router.setTop(true);
router.setRedirect("noRedirect"); router.setRedirect("noRedirect");
router.setChildren(buildMenus(cMenus)); router.setChildren(buildMenus(cMenus));
} }

@ -31,7 +31,7 @@ export const constantRoutes = [
hidden: true, hidden: true,
children: [ children: [
{ {
path: '/redirect/:path(.*)', path: baseDir+'/redirect/:path(.*)',
component: () => import('@/views/redirect/index.vue') component: () => import('@/views/redirect/index.vue')
} }
] ]
@ -57,12 +57,12 @@ export const constantRoutes = [
hidden: true hidden: true
}, },
{ {
path: baseDir+'', path: baseDir+'/',
component: Layout, component: Layout,
redirect: baseDir+'/index', redirect: baseDir+'/index',
children: [ children: [
{ {
path: '/index', path: baseDir+'/index',
component: () => import('@/views/index'), component: () => import('@/views/index'),
name: 'Index', name: 'Index',
meta: { title: '首页', icon: 'dashboard', affix: true } meta: { title: '首页', icon: 'dashboard', affix: true }
@ -76,7 +76,7 @@ export const constantRoutes = [
redirect: 'noredirect', redirect: 'noredirect',
children: [ children: [
{ {
path: 'profile', path: baseDir+'profile',
component: () => import('@/views/system/user/profile/index'), component: () => import('@/views/system/user/profile/index'),
name: 'Profile', name: 'Profile',
meta: { title: '个人中心', icon: 'user' } meta: { title: '个人中心', icon: 'user' }
@ -89,7 +89,7 @@ export const constantRoutes = [
hidden: true, hidden: true,
children: [ children: [
{ {
path: 'role/:userId(\\d+)', path: baseDir+'role/:userId(\\d+)',
component: () => import('@/views/system/user/authRole'), component: () => import('@/views/system/user/authRole'),
name: 'AuthRole', name: 'AuthRole',
meta: { title: '分配角色', activeMenu: '/system/user' } meta: { title: '分配角色', activeMenu: '/system/user' }
@ -102,7 +102,7 @@ export const constantRoutes = [
hidden: true, hidden: true,
children: [ children: [
{ {
path: 'user/:roleId(\\d+)', path: baseDir+'user/:roleId(\\d+)',
component: () => import('@/views/system/role/authUser'), component: () => import('@/views/system/role/authUser'),
name: 'AuthUser', name: 'AuthUser',
meta: { title: '分配用户', activeMenu: '/system/role' } meta: { title: '分配用户', activeMenu: '/system/role' }
@ -115,7 +115,7 @@ export const constantRoutes = [
hidden: true, hidden: true,
children: [ children: [
{ {
path: 'index/:dictId(\\d+)', path: baseDir+'index/:dictId(\\d+)',
component: () => import('@/views/system/dict/data'), component: () => import('@/views/system/dict/data'),
name: 'Data', name: 'Data',
meta: { title: '字典数据', activeMenu: '/system/dict' } meta: { title: '字典数据', activeMenu: '/system/dict' }
@ -123,12 +123,12 @@ export const constantRoutes = [
] ]
}, },
{ {
path: '/monitor/job-log', path: baseDir+'/monitor/job-log',
component: Layout, component: Layout,
hidden: true, hidden: true,
children: [ children: [
{ {
path: 'index', path: baseDir+'index',
component: () => import('@/views/monitor/job/log'), component: () => import('@/views/monitor/job/log'),
name: 'JobLog', name: 'JobLog',
meta: { title: '调度日志', activeMenu: '/monitor/job' } meta: { title: '调度日志', activeMenu: '/monitor/job' }
@ -136,12 +136,12 @@ export const constantRoutes = [
] ]
}, },
{ {
path: '/tool/gen-edit', path: baseDir+'/tool/gen-edit',
component: Layout, component: Layout,
hidden: true, hidden: true,
children: [ children: [
{ {
path: 'index/:tableId(\\d+)', path: baseDir+'index/:tableId(\\d+)',
component: () => import('@/views/tool/gen/editTable'), component: () => import('@/views/tool/gen/editTable'),
name: 'GenEdit', name: 'GenEdit',
meta: { title: '修改生成配置', activeMenu: '/tool/gen' } meta: { title: '修改生成配置', activeMenu: '/tool/gen' }
@ -162,4 +162,12 @@ const router = createRouter({
}, },
}); });
let fora = function (routes) {
routes.forEach((r)=>{
debugger
console.log(r.path);
if (r.children !=undefined && r.children.length > 0) fora(r.children);
})
}
export default router; export default router;

@ -6,6 +6,7 @@ import InnerLink from '@/layout/components/InnerLink'
// 匹配views里面所有的.vue文件 // 匹配views里面所有的.vue文件
const modules = import.meta.glob('./../../views/**/*.vue') const modules = import.meta.glob('./../../views/**/*.vue')
const baseDir = import.meta.env.VITE_APP_BASE_DIR;
const permission = { const permission = {
state: { state: {
@ -56,6 +57,9 @@ const permission = {
// 遍历后台传来的路由字符串,转换为组件对象 // 遍历后台传来的路由字符串,转换为组件对象
function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) { function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
return asyncRouterMap.filter(route => { return asyncRouterMap.filter(route => {
if (route.top){//一级路由带上目录
route.path = baseDir + route.path;
}
if (type && route.children) { if (type && route.children) {
route.children = filterChildren(route.children) route.children = filterChildren(route.children)
} }

@ -94,6 +94,7 @@ const captchaOnOff = ref(true);
// //
const register = ref(false); const register = ref(false);
const redirect = ref(undefined); const redirect = ref(undefined);
const baseDir = import.meta.env.VITE_APP_BASE_DIR;
function handleLogin() { function handleLogin() {
proxy.$refs.loginRef.validate(valid => { proxy.$refs.loginRef.validate(valid => {
@ -112,7 +113,7 @@ function handleLogin() {
} }
// action // action
store.dispatch("Login", loginForm.value).then(() => { store.dispatch("Login", loginForm.value).then(() => {
router.push({ path: redirect.value || "/" }); router.push({ path: redirect.value || baseDir + "/"});
}).catch(() => { }).catch(() => {
loading.value = false; loading.value = false;
// //

Loading…
Cancel
Save