feat:菜单新增内链打开外网方式

This commit is contained in:
不做码农 2022-06-16 20:51:18 +08:00
parent 42c4ec914c
commit d37a1ffbd5
3 changed files with 50 additions and 16 deletions

View File

@ -56,7 +56,8 @@ namespace ZR.Model.System
public static string LAYOUT = "Layout";
/** ParentView组件标识 */
public static string PARENT_VIEW = "ParentView";
/** InnerLink组件标识 */
public static string INNER_LINK = "InnerLink";
/** 校验返回结果码 */
public static string UNIQUE = "0";
public static string NOT_UNIQUE = "1";

View File

@ -39,19 +39,32 @@ namespace ZR.Model.System.Vo
/// </summary>
public bool NoCache { get; set; }
public string TitleKey { get; set; } = string.Empty;
public string Link { get; set; } = string.Empty;
public Meta(string title, string icon)
{
Title = title;
Icon = icon;
}
public Meta(string title, string icon, string path)
{
Title = title;
Icon = icon;
Link = path;
}
public Meta(string title, string icon, bool noCache)
{
Title = title;
Icon = icon;
NoCache = noCache;
}
public Meta(string title, string icon, bool noCache, string titleKey)
public Meta(string title, string icon, bool noCache, string titleKey, string path)
{
Title = title;
Icon = icon;
NoCache = noCache;
TitleKey = titleKey;
Link = path;
}
}
}

View File

@ -8,6 +8,7 @@ using ZR.Model.Vo.System;
using ZR.Repository.System;
using ZR.Service.System.IService;
using ZR.Common;
using Infrastructure.Extensions;
namespace ZR.Service
{
@ -281,13 +282,13 @@ namespace ZR.Service
foreach (var menu in menus)
{
RouterVo router = new RouterVo
RouterVo router = new()
{
Hidden = "1".Equals(menu.visible),
Name = GetRouteName(menu),
Path = GetRoutePath(menu),
Component = GetComponent(menu),
Meta = new Meta(menu.MenuName, menu.icon, "1".Equals(menu.isCache), menu.MenuNameKey)
Meta = new Meta(menu.MenuName, menu.icon, "1".Equals(menu.isCache), menu.MenuNameKey, menu.path)
};
List<SysMenu> cMenus = menu.children;
@ -300,17 +301,32 @@ namespace ZR.Service
}
else if (IsMeunFrame(menu))
{
List<RouterVo> childrenList = new List<RouterVo>();
RouterVo children = new RouterVo
router.Meta = null;
List<RouterVo> childrenList = new();
RouterVo children = new()
{
Path = menu.path,
Component = menu.component,
Name = string.IsNullOrEmpty(menu.path) ? "" : menu.path.ToLower(),
Meta = new Meta(menu.MenuName, menu.icon, "1".Equals(menu.isCache), menu.MenuNameKey)
Meta = new Meta(menu.MenuName, menu.icon, "1".Equals(menu.isCache), menu.MenuNameKey, menu.path)
};
childrenList.Add(children);
router.Children = childrenList;
}
else if (menu.parentId == 0 && IsInnerLink(menu))
{
router.Meta = new Meta(menu.MenuName, menu.icon);
router.Path = "/";
List<RouterVo> childrenList = new();
RouterVo children = new();
string routerPath = InnerLinkReplaceEach(menu.path);
children.Path = routerPath;
children.Component = UserConstants.INNER_LINK;
children.Name = routerPath.ToLower();
children.Meta = new Meta(menu.MenuName, menu.icon, menu.path);
childrenList.Add(children);
router.Children = childrenList;
}
routers.Add(router);
}
@ -384,10 +400,10 @@ namespace ZR.Service
{
string routerPath = menu.path;
// 内链打开外网方式
//if (menu.parentId != 0 && IsInnerLink(menu))
//{
// routerPath = innerLinkReplaceEach(routerPath);
//}
if (menu.parentId != 0 && IsInnerLink(menu))
{
routerPath = InnerLinkReplaceEach(routerPath);
}
// 非外链并且是一级目录(类型为目录)
if (0 == menu.parentId && UserConstants.TYPE_DIR.Equals(menu.menuType)
&& UserConstants.NO_FRAME.Equals(menu.isFrame))
@ -413,6 +429,10 @@ namespace ZR.Service
{
component = menu.component;
}
else if (menu.component.IsEmpty() && menu.parentId != 0 && IsInnerLink(menu))
{
component = UserConstants.INNER_LINK;
}
else if (string.IsNullOrEmpty(menu.component) && IsParentView(menu))
{
component = UserConstants.PARENT_VIEW;
@ -451,16 +471,16 @@ namespace ZR.Service
{
return menu.parentId != 0 && UserConstants.TYPE_DIR.Equals(menu.menuType);
}
/// <summary>
/// 内链域名特殊字符替换
/// </summary>
/// <param name = "path" ></ param >
/// < returns ></ returns >
//public string innerLinkReplaceEach(string path)
//{
// return stringUtils.replaceEach(path, new String[] { Constants.HTTP, Constants.HTTPS },
// new String[] { "", "" });
//}
public string InnerLinkReplaceEach(string path)
{
return path.IsNotEmpty() ? path.Replace(UserConstants.HTTP, "").Replace(UserConstants.HTTPS, "") : path;
}
#endregion
}