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

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

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

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

@ -31,7 +31,7 @@ export const constantRoutes = [
hidden: true,
children: [
{
path: '/redirect/:path(.*)',
path: baseDir+'/redirect/:path(.*)',
component: () => import('@/views/redirect/index.vue')
}
]
@ -57,12 +57,12 @@ export const constantRoutes = [
hidden: true
},
{
path: baseDir+'',
path: baseDir+'/',
component: Layout,
redirect: baseDir+'/index',
children: [
{
path: '/index',
path: baseDir+'/index',
component: () => import('@/views/index'),
name: 'Index',
meta: { title: '首页', icon: 'dashboard', affix: true }
@ -76,7 +76,7 @@ export const constantRoutes = [
redirect: 'noredirect',
children: [
{
path: 'profile',
path: baseDir+'profile',
component: () => import('@/views/system/user/profile/index'),
name: 'Profile',
meta: { title: '个人中心', icon: 'user' }
@ -89,7 +89,7 @@ export const constantRoutes = [
hidden: true,
children: [
{
path: 'role/:userId(\\d+)',
path: baseDir+'role/:userId(\\d+)',
component: () => import('@/views/system/user/authRole'),
name: 'AuthRole',
meta: { title: '分配角色', activeMenu: '/system/user' }
@ -102,7 +102,7 @@ export const constantRoutes = [
hidden: true,
children: [
{
path: 'user/:roleId(\\d+)',
path: baseDir+'user/:roleId(\\d+)',
component: () => import('@/views/system/role/authUser'),
name: 'AuthUser',
meta: { title: '分配用户', activeMenu: '/system/role' }
@ -115,7 +115,7 @@ export const constantRoutes = [
hidden: true,
children: [
{
path: 'index/:dictId(\\d+)',
path: baseDir+'index/:dictId(\\d+)',
component: () => import('@/views/system/dict/data'),
name: 'Data',
meta: { title: '字典数据', activeMenu: '/system/dict' }
@ -123,12 +123,12 @@ export const constantRoutes = [
]
},
{
path: '/monitor/job-log',
path: baseDir+'/monitor/job-log',
component: Layout,
hidden: true,
children: [
{
path: 'index',
path: baseDir+'index',
component: () => import('@/views/monitor/job/log'),
name: 'JobLog',
meta: { title: '调度日志', activeMenu: '/monitor/job' }
@ -136,12 +136,12 @@ export const constantRoutes = [
]
},
{
path: '/tool/gen-edit',
path: baseDir+'/tool/gen-edit',
component: Layout,
hidden: true,
children: [
{
path: 'index/:tableId(\\d+)',
path: baseDir+'index/:tableId(\\d+)',
component: () => import('@/views/tool/gen/editTable'),
name: 'GenEdit',
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;

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

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

Loading…
Cancel
Save