mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2026-01-27 02:55:49 +08:00
优化代码
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"net/http"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
type LocationHelper struct {
|
||||
@@ -35,19 +34,19 @@ func (this *LocationHelper) BeforeAction(actionPtr actions.ActionWrapper) {
|
||||
|
||||
// 路径信息
|
||||
var currentLocationConfig *serverconfigs.HTTPLocationConfig = nil
|
||||
parentActionValue := reflect.ValueOf(actionPtr).Elem().FieldByName("ParentAction")
|
||||
if parentActionValue.IsValid() {
|
||||
parentAction, isOk := parentActionValue.Interface().(actionutils.ParentAction)
|
||||
if isOk {
|
||||
var locationId = action.ParamInt64("locationId")
|
||||
locationConfig, isOk := FindLocationConfig(&parentAction, locationId)
|
||||
if !isOk {
|
||||
return
|
||||
}
|
||||
action.Data["locationId"] = locationId
|
||||
action.Data["locationConfig"] = locationConfig
|
||||
currentLocationConfig = locationConfig
|
||||
parentActionValue, ok := actionPtr.(interface {
|
||||
Parent() *actionutils.ParentAction
|
||||
})
|
||||
if ok {
|
||||
var parentAction = parentActionValue.Parent()
|
||||
var locationId = action.ParamInt64("locationId")
|
||||
locationConfig, isOk := FindLocationConfig(parentAction, locationId)
|
||||
if !isOk {
|
||||
return
|
||||
}
|
||||
action.Data["locationId"] = locationId
|
||||
action.Data["locationConfig"] = locationConfig
|
||||
currentLocationConfig = locationConfig
|
||||
}
|
||||
|
||||
// 左侧菜单
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package locationutils
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
|
||||
@@ -30,7 +31,7 @@ func FindLocationConfig(parentAction *actionutils.ParentAction, locationId int64
|
||||
return
|
||||
}
|
||||
|
||||
err = locationConfig.Init(nil)
|
||||
err = locationConfig.Init(context.TODO())
|
||||
if err != nil {
|
||||
parentAction.ErrorPage(err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user