diff --git a/ZR.Common/Tools.cs b/ZR.Common/Tools.cs
index 1215a39..eee60ab 100644
--- a/ZR.Common/Tools.cs
+++ b/ZR.Common/Tools.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
+using System.Text.RegularExpressions;
namespace ZR.Common
{
@@ -60,5 +61,23 @@ namespace ZR.Common
: (diffday / 7)) + 1 + (dayInMonth > firstWeekEndDay ? 1 : 0);
return weekNumInMonth;
}
+ ///
+ /// 判断一个字符串是否为url
+ ///
+ ///
+ ///
+ public static bool IsUrl(string str)
+ {
+ try
+ {
+ string Url = @"^http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?$";
+ return Regex.IsMatch(str, Url);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex.Message);
+ return false;
+ }
+ }
}
}
diff --git a/ZR.Model/System/UserConstants.cs b/ZR.Model/System/UserConstants.cs
index bc68af6..e0906f7 100644
--- a/ZR.Model/System/UserConstants.cs
+++ b/ZR.Model/System/UserConstants.cs
@@ -60,5 +60,15 @@ namespace ZR.Model.System
/** 校验返回结果码 */
public static string UNIQUE = "0";
public static string NOT_UNIQUE = "1";
+
+ ///
+ /// http请求
+ ///
+ public static string HTTP = "http://";
+
+ ///
+ /// https请求
+ ///
+ public static string HTTPS = "https://";
}
}
diff --git a/ZR.Service/System/SysMenuService.cs b/ZR.Service/System/SysMenuService.cs
index 1afff0b..c1eedda 100644
--- a/ZR.Service/System/SysMenuService.cs
+++ b/ZR.Service/System/SysMenuService.cs
@@ -8,6 +8,7 @@ using ZR.Model.Vo;
using ZR.Model.Vo.System;
using ZR.Repository.System;
using ZR.Service.System.IService;
+using ZR.Common;
namespace ZR.Service
{
@@ -359,17 +360,23 @@ namespace ZR.Service
/// 路由地址
public string GetRoutePath(SysMenu menu)
{
- string routePath = menu.path;
+ string routerPath = menu.path;
+ // 内链打开外网方式
+ //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))
+ if (0 == menu.parentId && UserConstants.TYPE_DIR.Equals(menu.menuType)
+ && UserConstants.NO_FRAME.Equals(menu.isFrame))
{
- routePath = "/" + menu.path;
+ routerPath = "/" + menu.path;
}
else if (IsMeunFrame(menu))// 非外链并且是一级目录(类型为菜单)
{
- routePath = "/";
+ routerPath = "/";
}
- return routePath;
+ return routerPath;
}
///
@@ -398,7 +405,18 @@ namespace ZR.Service
///
public bool IsMeunFrame(SysMenu menu)
{
- return menu.parentId == 0 && UserConstants.TYPE_MENU.Equals(menu.menuType) && menu.isFrame.Equals(UserConstants.NO_FRAME);
+ return menu.parentId == 0 && UserConstants.TYPE_MENU.Equals(menu.menuType)
+ && menu.isFrame.Equals(UserConstants.NO_FRAME);
+ }
+
+ ///
+ /// 是否为内链组件
+ ///
+ /// 菜单信息
+ /// 结果
+ public bool IsInnerLink(SysMenu menu)
+ {
+ return menu.isFrame.Equals(UserConstants.NO_FRAME) && Tools.IsUrl(menu.path);
}
///
@@ -411,7 +429,16 @@ namespace ZR.Service
{
return menu.parentId != 0 && UserConstants.TYPE_DIR.Equals(menu.menuType);
}
-
+ ///
+ /// 内链域名特殊字符替换
+ ///
+ /// param >
+ /// < returns > returns >
+ //public string innerLinkReplaceEach(string path)
+ //{
+ // return stringUtils.replaceEach(path, new String[] { Constants.HTTP, Constants.HTTPS },
+ // new String[] { "", "" });
+ //}
#endregion
}