feat: adjust internationalization errors and the positions of global … (#7767)

This commit is contained in:
ssongliu
2025-01-24 11:00:07 +08:00
committed by GitHub
parent d6b21f4ab5
commit 8283cd7d02
159 changed files with 1110 additions and 1438 deletions
+2 -3
View File
@@ -5,7 +5,6 @@ import (
"fmt"
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
"github.com/1Panel-dev/1Panel/agent/constant"
"github.com/1Panel-dev/1Panel/agent/global"
"github.com/gin-gonic/gin"
)
@@ -17,12 +16,12 @@ func Certificate() gin.HandlerFunc {
return
}
if !c.Request.TLS.HandshakeComplete || len(c.Request.TLS.PeerCertificates) == 0 {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, errors.New("no such tls peer certificates"))
helper.InternalServer(c, errors.New("no such tls peer certificates"))
return
}
cert := c.Request.TLS.PeerCertificates[0]
if cert.Subject.CommonName != "panel_client" {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, fmt.Errorf("err certificate"))
helper.InternalServer(c, fmt.Errorf("err certificate"))
return
}
c.Next()
+1 -2
View File
@@ -6,7 +6,6 @@ import (
"github.com/1Panel-dev/1Panel/agent/app/dto"
"github.com/1Panel-dev/1Panel/agent/buserr"
"github.com/1Panel-dev/1Panel/agent/constant"
"github.com/gin-gonic/gin"
)
@@ -51,7 +50,7 @@ func DemoHandle() gin.HandlerFunc {
c.JSON(http.StatusInternalServerError, dto.Response{
Code: http.StatusInternalServerError,
Message: buserr.New(constant.ErrDemoEnvironment).Error(),
Message: buserr.New("ErrDemoEnvironment").Error(),
})
c.Abort()
}
+4 -3
View File
@@ -1,9 +1,10 @@
package middleware
import (
"net/http"
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
"github.com/1Panel-dev/1Panel/agent/app/repo"
"github.com/1Panel-dev/1Panel/agent/constant"
"github.com/gin-gonic/gin"
)
@@ -12,11 +13,11 @@ func GlobalLoading() gin.HandlerFunc {
settingRepo := repo.NewISettingRepo()
status, err := settingRepo.Get(settingRepo.WithByKey("SystemStatus"))
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
helper.InternalServer(c, err)
return
}
if status.Value != "Free" {
helper.ErrorWithDetail(c, constant.CodeGlobalLoading, status.Value, err)
helper.ErrorWithDetail(c, http.StatusProxyAuthRequired, status.Value, err)
return
}
c.Next()