diff --git a/backend/app/api/v1/auth.go b/backend/app/api/v1/auth.go index 4437ae0ea..30f1e6c9f 100644 --- a/backend/app/api/v1/auth.go +++ b/backend/app/api/v1/auth.go @@ -121,6 +121,15 @@ func (b *BaseApi) CheckIsSafety(c *gin.Context) { helper.SuccessWithData(c, status) } +func (b *BaseApi) GetResponsePage(c *gin.Context) { + pageCode, err := authService.GetResponsePage() + if err != nil { + helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) + return + } + helper.SuccessWithData(c, pageCode) +} + // @Tags Auth // @Summary Check System isDemo // @Description 判断是否为demo环境 diff --git a/backend/app/dto/setting.go b/backend/app/dto/setting.go index fd82393a0..9788bc7aa 100644 --- a/backend/app/dto/setting.go +++ b/backend/app/dto/setting.go @@ -55,6 +55,7 @@ type SettingInfo struct { SnapshotIgnore string `json:"snapshotIgnore"` XpackHideMenu string `json:"xpackHideMenu"` + NoAuthSetting string `json:"noAuthSetting"` } type SettingUpdate struct { diff --git a/backend/app/service/auth.go b/backend/app/service/auth.go index b88a7aa1d..118ffd982 100644 --- a/backend/app/service/auth.go +++ b/backend/app/service/auth.go @@ -20,6 +20,7 @@ type AuthService struct{} type IAuthService interface { CheckIsSafety(code string) (string, error) + GetResponsePage() (string, error) VerifyCode(code string) (bool, error) Login(c *gin.Context, info dto.Login, entrance string) (*dto.UserLoginInfo, error) LogOut(c *gin.Context) error @@ -185,3 +186,11 @@ func (u *AuthService) CheckIsSafety(code string) (string, error) { } return "unpass", nil } + +func (u *AuthService) GetResponsePage() (string, error) { + pageCode, err := settingRepo.Get(settingRepo.WithByKey("NoAuthSetting")) + if err != nil { + return "", err + } + return pageCode.Value, nil +} diff --git a/backend/init/migration/migrate.go b/backend/init/migration/migrate.go index e9f1e5fcf..c0a6a532d 100644 --- a/backend/init/migration/migrate.go +++ b/backend/init/migration/migrate.go @@ -78,6 +78,7 @@ func Init() { migrations.AddXpackHideMenu, migrations.AddCronjobCommand, migrations.NewMonitorDB, + migrations.AddNoAuthSetting, }) if err := m.Migrate(); err != nil { global.LOG.Error(err) diff --git a/backend/init/migration/migrations/v_1_10.go b/backend/init/migration/migrations/v_1_10.go index 1ddec233c..62546c0ba 100644 --- a/backend/init/migration/migrations/v_1_10.go +++ b/backend/init/migration/migrations/v_1_10.go @@ -108,3 +108,13 @@ var NewMonitorDB = &gormigrate.Migration{ return nil }, } + +var AddNoAuthSetting = &gormigrate.Migration{ + ID: "20240328-add-no-auth-setting", + Migrate: func(tx *gorm.DB) error { + if err := tx.Create(&model.Setting{Key: "NoAuthSetting", Value: "200"}).Error; err != nil { + return err + } + return nil + }, +} diff --git a/backend/router/ro_base.go b/backend/router/ro_base.go index 0ea3808b1..21b28b2d0 100644 --- a/backend/router/ro_base.go +++ b/backend/router/ro_base.go @@ -18,5 +18,6 @@ func (s *BaseRouter) InitRouter(Router *gin.RouterGroup) { baseRouter.POST("/logout", baseApi.LogOut) baseRouter.GET("/demo", baseApi.CheckIsDemo) baseRouter.GET("/language", baseApi.GetLanguage) + baseRouter.GET("/respagecode", baseApi.GetResponsePage) } } diff --git a/frontend/src/api/interface/setting.ts b/frontend/src/api/interface/setting.ts index e31434d29..6e101e79f 100644 --- a/frontend/src/api/interface/setting.ts +++ b/frontend/src/api/interface/setting.ts @@ -47,6 +47,7 @@ export namespace Setting { dingVars: string; snapshotIgnore: string; xpackHideMenu: string; + noAuthSetting: string; } export interface SettingUpdate { key: string; diff --git a/frontend/src/api/modules/auth.ts b/frontend/src/api/modules/auth.ts index 937344d41..75837cd32 100644 --- a/frontend/src/api/modules/auth.ts +++ b/frontend/src/api/modules/auth.ts @@ -21,6 +21,10 @@ export const checkIsSafety = (code: string) => { return http.get(`/auth/issafety?code=${code}`); }; +export const getResponsePage = () => { + return http.get(`/auth/respagecode`); +}; + export const checkIsDemo = () => { return http.get('/auth/demo'); }; diff --git a/frontend/src/assets/images/error.svg b/frontend/src/assets/images/error.svg new file mode 100644 index 000000000..da80d0b46 --- /dev/null +++ b/frontend/src/assets/images/error.svg @@ -0,0 +1 @@ + diff --git a/frontend/src/components/error-message/error_code.vue b/frontend/src/components/error-message/error_code.vue new file mode 100644 index 000000000..ab1e2c6e1 --- /dev/null +++ b/frontend/src/components/error-message/error_code.vue @@ -0,0 +1,48 @@ + + + + + diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 9d36be702..6747bdaf6 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -1388,6 +1388,15 @@ const message = { sslDisable: 'Disable', sslDisableHelper: 'If the https service is disabled, you need to restart the panel for it to take effect. Do you want to continue?', + noAuthSetting: 'Unauthorized Setting', + responseSetting: 'Response Setting', + help200: '200 - Help Page', + error400: 'Bad Request', + error401: 'Unauthorized', + error403: 'Forbidden', + error404: 'Not Found', + error408: 'Request Timeout', + error416: 'Range Not Satisfiable', https: 'Setting up HTTPS protocol access for the panel can enhance the security of panel access.', certType: 'Certificate type', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index 2abeb148c..2a39d3288 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -1335,6 +1335,15 @@ const message = { sslChangeHelper: 'https 設置修改需要重啟服務,是否繼續?', sslDisable: '禁用', sslDisableHelper: '禁用 https 服務,需要重啟面板才能生效,是否繼續?', + noAuthSetting: '未认证设置', + responseSetting: '响应设置', + help200: '200 - 幫助頁面', + error400: '錯誤請求', + error401: '未授權', + error403: '禁止訪問', + error404: '未找到', + error408: '請求超時', + error416: '無效請求', https: '為面板設置 https 協議訪問,提升面板訪問安全性', certType: '證書類型', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index d57fd5ab8..2b1ce36d2 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -1336,6 +1336,15 @@ const message = { sslChangeHelper: 'https 设置修改需要重启服务,是否继续?', sslDisable: '禁用', sslDisableHelper: '禁用 https 服务,需要重启面板才能生效,是否继续?', + noAuthSetting: '未认证设置', + responseSetting: '响应设置', + help200: '200 - 帮助页面', + error400: '错误请求', + error401: '未授权', + error403: '禁止访问', + error404: '未找到', + error408: '请求超时', + error416: '无效请求', https: '为面板设置 https 协议访问,提升面板访问安全性', certType: '证书类型', diff --git a/frontend/src/views/login/entrance/index.vue b/frontend/src/views/login/entrance/index.vue index c25589d3e..9a1a8e354 100644 --- a/frontend/src/views/login/entrance/index.vue +++ b/frontend/src/views/login/entrance/index.vue @@ -15,27 +15,29 @@ -
+ +
+ +
+ +
-
- -
+ +