diff --git a/backend/app/api/v1/auth.go b/backend/app/api/v1/auth.go index 96796d9b7..8bc731f8f 100644 --- a/backend/app/api/v1/auth.go +++ b/backend/app/api/v1/auth.go @@ -120,6 +120,20 @@ func (b *BaseApi) CheckIsDemo(c *gin.Context) { helper.SuccessWithData(c, global.CONF.System.IsDemo) } +// @Tags Auth +// @Summary Load System Language +// @Description 获取系统语言设置 +// @Success 200 +// @Router /auth/language [get] +func (b *BaseApi) GetLanguage(c *gin.Context) { + settingInfo, err := settingService.GetSettingInfo() + if err != nil { + helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) + return + } + helper.SuccessWithData(c, settingInfo.Language) +} + func saveLoginLogs(c *gin.Context, err error) { var logs model.LoginLog if err != nil { diff --git a/backend/app/dto/auth.go b/backend/app/dto/auth.go index 6b9602fb3..85cf8d8c9 100644 --- a/backend/app/dto/auth.go +++ b/backend/app/dto/auth.go @@ -24,6 +24,7 @@ type Login struct { Captcha string `json:"captcha"` CaptchaID string `json:"captchaID"` AuthMethod string `json:"authMethod"` + Language string `json:"language"` } type MFALogin struct { diff --git a/backend/app/service/auth.go b/backend/app/service/auth.go index 421eaa26e..5b0a93a45 100644 --- a/backend/app/service/auth.go +++ b/backend/app/service/auth.go @@ -48,10 +48,12 @@ func (u *AuthService) Login(c *gin.Context, info dto.Login) (*dto.UserLoginInfo, if err != nil { return nil, err } + if err = settingRepo.Update("Language", info.Language); err != nil { + return nil, err + } if mfa.Value == "enable" { return &dto.UserLoginInfo{Name: nameSetting.Value, MfaStatus: mfa.Value}, nil } - return u.generateSession(c, info.Name, info.AuthMethod) } diff --git a/backend/router/ro_base.go b/backend/router/ro_base.go index 4ccb6aeb4..b2596675e 100644 --- a/backend/router/ro_base.go +++ b/backend/router/ro_base.go @@ -17,5 +17,6 @@ func (s *BaseRouter) InitBaseRouter(Router *gin.RouterGroup) { baseRouter.GET("/issafety", baseApi.CheckIsSafety) baseRouter.POST("/logout", baseApi.LogOut) baseRouter.GET("/demo", baseApi.CheckIsDemo) + baseRouter.GET("/language", baseApi.GetLanguage) } } diff --git a/cmd/server/docs/docs.go b/cmd/server/docs/docs.go index d951ca4ea..dbb857c23 100644 --- a/cmd/server/docs/docs.go +++ b/cmd/server/docs/docs.go @@ -882,6 +882,20 @@ const docTemplate = `{ } } }, + "/auth/language": { + "get": { + "description": "获取系统语言设置", + "tags": [ + "Auth" + ], + "summary": "Load System Language", + "responses": { + "200": { + "description": "OK" + } + } + } + }, "/auth/login": { "post": { "description": "用户登录", @@ -12541,6 +12555,9 @@ const docTemplate = `{ "ignoreCaptcha": { "type": "boolean" }, + "language": { + "type": "string" + }, "name": { "type": "string" }, diff --git a/cmd/server/docs/swagger.json b/cmd/server/docs/swagger.json index 3166bc9b6..d61f8b046 100644 --- a/cmd/server/docs/swagger.json +++ b/cmd/server/docs/swagger.json @@ -875,6 +875,20 @@ } } }, + "/auth/language": { + "get": { + "description": "获取系统语言设置", + "tags": [ + "Auth" + ], + "summary": "Load System Language", + "responses": { + "200": { + "description": "OK" + } + } + } + }, "/auth/login": { "post": { "description": "用户登录", @@ -12534,6 +12548,9 @@ "ignoreCaptcha": { "type": "boolean" }, + "language": { + "type": "string" + }, "name": { "type": "string" }, diff --git a/cmd/server/docs/swagger.yaml b/cmd/server/docs/swagger.yaml index 96abe232b..79981d707 100644 --- a/cmd/server/docs/swagger.yaml +++ b/cmd/server/docs/swagger.yaml @@ -1062,6 +1062,8 @@ definitions: type: string ignoreCaptcha: type: boolean + language: + type: string name: type: string password: @@ -4285,6 +4287,15 @@ paths: summary: Load safety status tags: - Auth + /auth/language: + get: + description: 获取系统语言设置 + responses: + "200": + description: OK + summary: Load System Language + tags: + - Auth /auth/login: post: consumes: diff --git a/frontend/src/api/modules/auth.ts b/frontend/src/api/modules/auth.ts index 120bdce47..937344d41 100644 --- a/frontend/src/api/modules/auth.ts +++ b/frontend/src/api/modules/auth.ts @@ -24,3 +24,7 @@ export const checkIsSafety = (code: string) => { export const checkIsDemo = () => { return http.get('/auth/demo'); }; + +export const getLanguage = () => { + return http.get(`/auth/language`); +}; diff --git a/frontend/src/views/login/components/login-form.vue b/frontend/src/views/login/components/login-form.vue index 4e94a0b1b..04d4ff840 100644 --- a/frontend/src/views/login/components/login-form.vue +++ b/frontend/src/views/login/components/login-form.vue @@ -39,8 +39,26 @@