fix: 修改只读模式提示

This commit is contained in:
yokowu
2025-07-24 19:40:04 +08:00
parent c7c4b2a750
commit 802b191f9b
3 changed files with 4 additions and 6 deletions

View File

@@ -12,7 +12,6 @@ var LocalFS embed.FS
var (
ErrPermission = web.NewBadRequestErr("err-permission")
ErrUserNotFound = web.NewBadRequestErr("err-user-not-found")
ErrReadOnly = web.NewBadRequestErr("err-read-only")
ErrPassword = web.NewBadRequestErr("err-password")
ErrInviteCodeInvalid = web.NewBadRequestErr("err-invite-code-invalid")
ErrEmailInvalid = web.NewBadRequestErr("err-email-invalid")

View File

@@ -1,9 +1,6 @@
[err-permission]
other = "无权操作"
[err-read-only]
other = "只读模式"
[err-user-not-found]
other = "用户不存在"

View File

@@ -6,7 +6,6 @@ import (
"github.com/labstack/echo/v4"
"github.com/chaitin/MonkeyCode/backend/config"
"github.com/chaitin/MonkeyCode/backend/errcode"
)
type ReadOnlyMiddleware struct {
@@ -21,7 +20,10 @@ func (m *ReadOnlyMiddleware) Guard() echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
if m.cfg.ReadOnly && c.Request().Method != http.MethodGet {
return errcode.ErrReadOnly
return c.JSON(http.StatusOK, echo.Map{
"code": -1,
"message": "只读模式下不支持该操作",
})
}
return next(c)
}