Эх сурвалжийг харах

登录后返回菜单正常

lcl 11 сар өмнө
parent
commit
00a21f8a13

+ 2 - 2
Controllers/Base/SysMenuController.cs

@@ -86,7 +86,7 @@ namespace Controllers
         /// 加载对应角色菜单列表树
         /// </summary>
         /// <param name="roleId"></param>
-        /// <returns></returns>        
+        /// <returns></returns>
         [HttpGet("roleMenuTreeselect/{roleId}")]
         public IActionResult RoleMenuTreeselect(int roleId)
         {
@@ -101,7 +101,7 @@ namespace Controllers
         }
 
         [Verify]
-        [HttpGet("/v1/skb/sysServer/menu")]
+        [HttpGet("/v1/skb/sysServer/menu/getUserMenu")]
         public IActionResult GetMenus()
         {
             long userId = HttpContext.GetUId();

+ 1 - 0
Filters/AuthorizationFilter.cs

@@ -71,6 +71,7 @@ namespace Filters
 
         public string Decrypt(string str)
         {
+            str = str.Trim('"');
             str = Encoding.UTF8.GetString(Convert.FromBase64String(str));
             return Dbconn.AesDecrypt(str, Base.GlobalConstant.ApiKey, Base.GlobalConstant.ApiIv);
         }

+ 13 - 0
Middleware/GlobalExceptionMiddleware.cs

@@ -33,6 +33,19 @@ namespace Middleware
         {
             try
             {
+                // 设置允许跨域的域名、方法等
+                context.Response.Headers.Add("Access-Control-Allow-Origin", "*");
+                context.Response.Headers.Add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
+                context.Response.Headers.Add("Access-Control-Allow-Headers", "DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization");
+
+                // 如果请求方法是预检请求(OPTIONS),则直接返回成功状态码
+                if (context.Request.Method == "OPTIONS")
+                {
+                    context.Response.StatusCode = 200;
+                    await context.Response.WriteAsync("OK");
+                    return;
+                }
+
                 await next(context);
             }
             catch (Exception ex)

+ 31 - 7
Model/Vo/Base/TreeSelectVo.cs

@@ -15,23 +15,40 @@ namespace Vo
         /// <summary>
         /// 节点名称
         /// </summary>
-        public string Label { get; set; }
-        public string Status { get; set; }
+        public string Name { get; set; }
+        public long ParentId { get; set; }
         public string MenuType { get; set; }
+        public string Path { get; set; }
+        public int SortOrder { get; set; }
+        public TreeSelectMeta Meta { get; set; }
+        public List<string> Permission { get; set; }
 
         public TreeSelectVo() { }
 
         public TreeSelectVo(SysMenu menu)
         {
             Id = menu.MenuId;
-            Label = menu.Name;
-            Status = menu.Visible;
+            Name = menu.Name;
+            ParentId = menu.ParentId;
             MenuType = menu.MenuType;
+            Path = menu.Path;
+            SortOrder = menu.SortOrder;
+            Meta = new TreeSelectMeta();
+            Meta.Title = menu.Name;
+            Meta.Icon = menu.Icon;
+            Permission = new List<string>();
 
             List<TreeSelectVo> child = new List<TreeSelectVo>();
             foreach (var item in menu.Children)
             {
-                child.Add(new TreeSelectVo(item));
+                if(item.MenuType == "0")
+                {
+                    child.Add(new TreeSelectVo(item));
+                }
+                else
+                {
+                    Permission.Add(item.Permission);
+                }
             }
 
             Children = child;
@@ -40,9 +57,8 @@ namespace Vo
         public TreeSelectVo(SysDept dept)
         {
             Id = dept.DeptId;
-            Label = dept.Name;
+            Name = dept.Name;
 
-            //menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); java写法
             List<TreeSelectVo> child = new List<TreeSelectVo>();
             foreach (var item in dept.children)
             {
@@ -55,4 +71,12 @@ namespace Vo
         [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
         public List<TreeSelectVo> Children { get; set; }
     }
+
+    public class TreeSelectMeta
+    {
+        public string Title { get; set; }
+        public string Icon { get; set; }
+        public List<string> Roles { get; set; }
+        public List<string> Auths { get; set; }
+    }
 }

+ 3 - 3
Properties/launchSettings.json

@@ -4,7 +4,7 @@
     "windowsAuthentication": false,
     "anonymousAuthentication": true,
     "iisExpress": {
-      "applicationUrl": "http://localhost:49293",
+      "applicationUrl": "http://192.168.1.151:49293",
       "sslPort": 44376
     }
   },
@@ -14,7 +14,7 @@
       "dotnetRunMessages": true,
       "launchBrowser": true,
       "launchUrl": "swagger",
-      "applicationUrl": "http://localhost:5296",
+      "applicationUrl": "http://192.168.1.151:5296",
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }
@@ -24,7 +24,7 @@
       "dotnetRunMessages": true,
       "launchBrowser": true,
       "launchUrl": "swagger",
-      "applicationUrl": "https://localhost:7096;http://localhost:5296",
+      "applicationUrl": "http://192.168.1.151:5296",
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }