Ver código fonte

修改PCWEB菜单BUG

zhou.xiaoning 4 anos atrás
pai
commit
c00556d5dc
1 arquivos alterados com 28 adições e 22 exclusões
  1. 28 22
      controllers/common/menu.go

+ 28 - 22
controllers/common/menu.go

@@ -286,16 +286,19 @@ func createPCWebMenu(datas []interface{}, loginID int) []PCWebMenu {
 		data := v.(map[string]interface{})
 		if data["isshow"].(bool) {
 			// 判断权限
-			rulekey := data["rulekey"].(string)
-			requireAuth := rulekey != ""
-			if requireAuth {
-				// 判断是否有权限
-				funcMenuList, err := models.GetErmcpRoleFuncMenuLists(loginID, rulekey)
-				if err != nil {
-					continue
-				}
-				if len(funcMenuList) == 0 {
-					continue
+			rulekey := ""
+			if data["rulekey"] != nil {
+				rulekey = data["rulekey"].(string)
+				requireAuth := rulekey != ""
+				if requireAuth {
+					// 判断是否有权限
+					funcMenuList, err := models.GetErmcpRoleFuncMenuLists(loginID, rulekey)
+					if err != nil {
+						continue
+					}
+					if len(funcMenuList) == 0 {
+						continue
+					}
 				}
 			}
 
@@ -307,23 +310,26 @@ func createPCWebMenu(datas []interface{}, loginID int) []PCWebMenu {
 					am := a.(map[string]interface{})
 					if am["isshow"].(bool) {
 						// 判断权限
-						rulekey := am["rulekey"].(string)
-						requireAuth := rulekey != ""
-						if requireAuth {
-							// 判断是否有权限
-							funcMenuList, err := models.GetErmcpRoleFuncMenuLists(loginID, rulekey)
-							if err != nil {
-								continue
-							}
-							if len(funcMenuList) == 0 {
-								continue
+						rulekeySub := ""
+						if am["rulekey"] != nil {
+							rulekeySub = am["rulekey"].(string)
+							requireAuth := rulekeySub != ""
+							if requireAuth {
+								// 判断是否有权限
+								funcMenuList, err := models.GetErmcpRoleFuncMenuLists(loginID, rulekeySub)
+								if err != nil {
+									continue
+								}
+								if len(funcMenuList) == 0 {
+									continue
+								}
 							}
 						}
 
 						auth := PCWebMenuAuth{
 							Label:   am["label"].(string),
 							Code:    am["code"].(string),
-							Rulekey: am["rulekey"].(string),
+							Rulekey: rulekeySub,
 							IsShow:  am["isshow"].(bool),
 						}
 						if am["remark"] != nil {
@@ -340,7 +346,7 @@ func createPCWebMenu(datas []interface{}, loginID int) []PCWebMenu {
 				Path:      toString(data["path"]),
 				Component: toString(data["component"]),
 				Sort:      int(data["sort"].(float64)),
-				Rulekey:   toString(data["rulekey"]),
+				Rulekey:   rulekey,
 				IsShow:    data["isshow"].(bool),
 			}
 			if data["url"] != nil {