diff --git a/backend/app/api/v1/command.go b/backend/app/api/v1/command.go index c6f477216..3c9926111 100644 --- a/backend/app/api/v1/command.go +++ b/backend/app/api/v1/command.go @@ -30,21 +30,21 @@ func (b *BaseApi) CreateCommand(c *gin.Context) { } // @Tags Redis Command -// @Summary Create redis command -// @Description 创建 Redis 快速命令 +// @Summary Save redis command +// @Description 保存 Redis 快速命令 // @Accept json // @Param request body dto.RedisCommand true "request" // @Success 200 // @Security ApiKeyAuth // @Router /hosts/command/redis [post] -// @x-panel-log {"bodyKeys":["name","command"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建 redis 快捷命令 [name][command]","formatEN":"create quick command for redis [name][command]"} -func (b *BaseApi) CreateRedisCommand(c *gin.Context) { +// @x-panel-log {"bodyKeys":["name","command"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"保存 redis 快捷命令 [name][command]","formatEN":"save quick command for redis [name][command]"} +func (b *BaseApi) SaveRedisCommand(c *gin.Context) { var req dto.RedisCommand if err := helper.CheckBindAndValidate(&req, c); err != nil { return } - if err := commandService.CreateRedisCommand(req); err != nil { + if err := commandService.SaveRedisCommand(req); err != nil { helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) return } diff --git a/backend/app/repo/command.go b/backend/app/repo/command.go index 7c95b1f52..c68ad618a 100644 --- a/backend/app/repo/command.go +++ b/backend/app/repo/command.go @@ -21,7 +21,7 @@ type ICommandRepo interface { PageRedis(limit, offset int, opts ...DBOption) (int64, []model.RedisCommand, error) GetRedis(opts ...DBOption) (model.RedisCommand, error) GetRedisList(opts ...DBOption) ([]model.RedisCommand, error) - CreateRedis(command *model.RedisCommand) error + SaveRedis(command *model.RedisCommand) error DeleteRedis(opts ...DBOption) error } @@ -107,8 +107,8 @@ func (u *CommandRepo) Create(command *model.Command) error { return global.DB.Create(command).Error } -func (u *CommandRepo) CreateRedis(command *model.RedisCommand) error { - return global.DB.Create(command).Error +func (u *CommandRepo) SaveRedis(command *model.RedisCommand) error { + return global.DB.Save(command).Error } func (u *CommandRepo) Update(id uint, vars map[string]interface{}) error { diff --git a/backend/app/service/command.go b/backend/app/service/command.go index d8dafd8fe..3156ad7d1 100644 --- a/backend/app/service/command.go +++ b/backend/app/service/command.go @@ -2,6 +2,7 @@ package service import ( "github.com/1Panel-dev/1Panel/backend/app/dto" + "github.com/1Panel-dev/1Panel/backend/app/model" "github.com/1Panel-dev/1Panel/backend/constant" "github.com/jinzhu/copier" "github.com/pkg/errors" @@ -19,7 +20,7 @@ type ICommandService interface { SearchRedisCommandWithPage(search dto.SearchWithPage) (int64, interface{}, error) ListRedisCommand() ([]dto.RedisCommand, error) - CreateRedisCommand(commandDto dto.RedisCommand) error + SaveRedisCommand(commandDto dto.RedisCommand) error DeleteRedisCommand(ids []uint) error } @@ -153,15 +154,12 @@ func (u *CommandService) ListRedisCommand() ([]dto.RedisCommand, error) { return dtoCommands, err } -func (u *CommandService) CreateRedisCommand(commandDto dto.RedisCommand) error { - command, _ := commandRepo.GetRedis(commonRepo.WithByName(commandDto.Name)) - if command.ID != 0 { - return constant.ErrRecordExist - } +func (u *CommandService) SaveRedisCommand(commandDto dto.RedisCommand) error { + var command model.RedisCommand if err := copier.Copy(&command, &commandDto); err != nil { return errors.WithMessage(constant.ErrStructTransform, err.Error()) } - if err := commandRepo.CreateRedis(&command); err != nil { + if err := commandRepo.SaveRedis(&command); err != nil { return err } return nil diff --git a/backend/app/service/database.go b/backend/app/service/database.go index b27089bf8..f9f2a0835 100644 --- a/backend/app/service/database.go +++ b/backend/app/service/database.go @@ -275,6 +275,14 @@ func (u *DatabaseService) Update(req dto.DatabaseUpdate) error { }); err != nil { return err } + case constant.AppRedis: + if _, err := redis_client.NewRedisClient(redis_client.DBInfo{ + Address: req.Address, + Port: req.Port, + Password: req.Password, + }); err != nil { + return err + } case "mysql", "mariadb": if _, err := mysql.NewMysqlClient(client.DBInfo{ From: "remote", diff --git a/backend/router/ro_host.go b/backend/router/ro_host.go index fb34f9357..8a589ca86 100644 --- a/backend/router/ro_host.go +++ b/backend/router/ro_host.go @@ -57,7 +57,7 @@ func (s *HostRouter) InitRouter(Router *gin.RouterGroup) { hostRouter.POST("/command/update", baseApi.UpdateCommand) hostRouter.GET("/command/redis", baseApi.ListRedisCommand) - hostRouter.POST("/command/redis", baseApi.CreateRedisCommand) + hostRouter.POST("/command/redis", baseApi.SaveRedisCommand) hostRouter.POST("/command/redis/search", baseApi.SearchRedisCommand) hostRouter.POST("/command/redis/del", baseApi.DeleteRedisCommand) diff --git a/cmd/server/docs/docs.go b/cmd/server/docs/docs.go index ec76f6230..7cba0c304 100644 --- a/cmd/server/docs/docs.go +++ b/cmd/server/docs/docs.go @@ -7674,14 +7674,14 @@ const docTemplate = `{ "ApiKeyAuth": [] } ], - "description": "创建 Redis 快速命令", + "description": "保存 Redis 快速命令", "consumes": [ "application/json" ], "tags": [ "Redis Command" ], - "summary": "Create redis command", + "summary": "Save redis command", "parameters": [ { "description": "request", @@ -7704,8 +7704,8 @@ const docTemplate = `{ "name", "command" ], - "formatEN": "create quick command for redis [name][command]", - "formatZH": "创建 redis 快捷命令 [name][command]", + "formatEN": "save quick command for redis [name][command]", + "formatZH": "保存 redis 快捷命令 [name][command]", "paramKeys": [] } } diff --git a/cmd/server/docs/swagger.json b/cmd/server/docs/swagger.json index 50f3d8581..316edd325 100644 --- a/cmd/server/docs/swagger.json +++ b/cmd/server/docs/swagger.json @@ -7667,14 +7667,14 @@ "ApiKeyAuth": [] } ], - "description": "创建 Redis 快速命令", + "description": "保存 Redis 快速命令", "consumes": [ "application/json" ], "tags": [ "Redis Command" ], - "summary": "Create redis command", + "summary": "Save redis command", "parameters": [ { "description": "request", @@ -7697,8 +7697,8 @@ "name", "command" ], - "formatEN": "create quick command for redis [name][command]", - "formatZH": "创建 redis 快捷命令 [name][command]", + "formatEN": "save quick command for redis [name][command]", + "formatZH": "保存 redis 快捷命令 [name][command]", "paramKeys": [] } } diff --git a/cmd/server/docs/swagger.yaml b/cmd/server/docs/swagger.yaml index c425b1c0f..f704ceb81 100644 --- a/cmd/server/docs/swagger.yaml +++ b/cmd/server/docs/swagger.yaml @@ -10069,7 +10069,7 @@ paths: post: consumes: - application/json - description: 创建 Redis 快速命令 + description: 保存 Redis 快速命令 parameters: - description: request in: body @@ -10082,7 +10082,7 @@ paths: description: OK security: - ApiKeyAuth: [] - summary: Create redis command + summary: Save redis command tags: - Redis Command x-panel-log: @@ -10090,8 +10090,8 @@ paths: bodyKeys: - name - command - formatEN: create quick command for redis [name][command] - formatZH: 创建 redis 快捷命令 [name][command] + formatEN: save quick command for redis [name][command] + formatZH: 保存 redis 快捷命令 [name][command] paramKeys: [] /hosts/command/redis/del: post: diff --git a/frontend/src/api/modules/host.ts b/frontend/src/api/modules/host.ts index 768d1fe18..4eb6492c8 100644 --- a/frontend/src/api/modules/host.ts +++ b/frontend/src/api/modules/host.ts @@ -78,7 +78,7 @@ export const getRedisCommandList = () => { export const getRedisCommandPage = (params: SearchWithPage) => { return http.post>(`/hosts/command/redis/search`, params); }; -export const addRedisCommand = (params: Command.RedisCommand) => { +export const saveRedisCommand = (params: Command.RedisCommand) => { return http.post(`/hosts/command/redis`, params); }; export const deleteRedisCommand = (params: { ids: number[] }) => { diff --git a/frontend/src/global/form-rules.ts b/frontend/src/global/form-rules.ts index 4b65b2a0e..d05f36702 100644 --- a/frontend/src/global/form-rules.ts +++ b/frontend/src/global/form-rules.ts @@ -185,7 +185,7 @@ const checkSimplePassword = (rule: any, value: any, callback: any) => { if (value === '' || typeof value === 'undefined' || value == null) { callback(new Error(i18n.global.t('commons.rule.simplePassword'))); } else { - const reg = /^[a-zA-Z0-9]{1}[a-zA-Z0-9_]{5,29}$/; + const reg = /^[a-zA-Z0-9]{1}[a-zA-Z0-9_]{0,29}$/; if (!reg.test(value) && value !== '') { callback(new Error(i18n.global.t('commons.rule.simplePassword'))); } else { diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 049a6ab0b..3e01d59d8 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -171,7 +171,7 @@ const message = { 'Supports non-special characters starting with English, Chinese, numbers, .- and _, length 1-128', userName: 'Support English, Chinese, numbers and _ length 3-30', simpleName: 'Supports non-underscore starting, English, numbers, _, length 3-30', - simplePassword: 'Supports non-underscore starting, English, numbers, _, length 6-30', + simplePassword: 'Supports non-underscore starting, English, numbers, _, length 1-30', dbName: 'Supports non-special character starting, including English, Chinese, numbers, .-_, with a length of 1-64', imageName: 'Support English, numbers, :/.-_, length 1-150', volumeName: 'Support English, numbers, .-_, length 2-30', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index 5b7408487..3c6643e39 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -171,7 +171,7 @@ const message = { commonName: '支持非特殊字元開頭,英文、中文、數字、.-和_,長度1-128', userName: '支持英文、中文、數字和_,長度3-30', simpleName: '支持非底線開頭,英文、數字、_,長度3-30', - simplePassword: '支持非底線開頭,英文、數字、_,長度6-30', + simplePassword: '支持非底線開頭,英文、數字、_,長度1-30', dbName: '支持非特殊字符開頭,英文、中文、數字、.-_,長度1-64', imageName: '支持英文、數字、:/.-_,長度1-150', volumeName: '支持英文、數字、.-和_,長度2-30', @@ -1205,7 +1205,7 @@ const message = { sessionTimeoutError: '最小超時時間為 300 秒', sessionTimeoutHelper: '如果用戶超過 {0} 秒未操作面板,面板將自動退出登錄', systemIP: '伺服器地址', - proxy: '伺服器代理', + proxy: '代理伺服器', proxyHelper: '設置代理伺服器後,將在以下場景中生效:', proxyHelper1: '應用商店的安裝包下載和同步', proxyHelper2: '系統版本升級及獲取更新說明', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 5c68e514d..33372e9be 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -171,7 +171,7 @@ const message = { commonName: '支持非特殊字符开头,英文、中文、数字、.-和_,长度1-128', userName: '支持英文、中文、数字和_,长度3-30', simpleName: '支持非下划线开头,英文、数字、_,长度3-30', - simplePassword: '支持非下划线开头,英文、数字、_,长度6-30', + simplePassword: '支持非下划线开头,英文、数字、_,长度1-30', dbName: '支持非特殊字符开头,英文、中文、数字、.-_,长度1-64', imageName: '支持英文、数字、:/.-_,长度1-150', volumeName: '支持英文、数字、.-和_,长度2-30', @@ -1206,7 +1206,7 @@ const message = { sessionTimeoutError: '最小超时时间为 300 秒', sessionTimeoutHelper: '如果用户超过 {0} 秒未操作面板,面板将自动退出登录', systemIP: '服务器地址', - proxy: '服务器代理', + proxy: '代理服务器', proxyHelper: '设置代理服务器后,将在以下场景中生效:', proxyHelper1: '应用商店的安装包下载和同步', proxyHelper2: '系统版本升级及获取更新说明', diff --git a/frontend/src/views/container/image/pull/index.vue b/frontend/src/views/container/image/pull/index.vue index 69a3d1270..1b7df602b 100644 --- a/frontend/src/views/container/image/pull/index.vue +++ b/frontend/src/views/container/image/pull/index.vue @@ -92,6 +92,13 @@ const acceptParams = async (params: DialogProps): Promise => { form.fromRepo = true; form.imageName = ''; repos.value = params.repos; + form.repoID = 1; + for (const item of repos.value) { + if (item.name === 'Docker Hub' && item.downloadUrl === 'docker.io') { + form.repoID = item.id; + break; + } + } buttonDisabled.value = false; logInfo.value = ''; showLog.value = false; diff --git a/frontend/src/views/database/redis/command/index.vue b/frontend/src/views/database/redis/command/index.vue index ddf2a1660..90fdf80bb 100644 --- a/frontend/src/views/database/redis/command/index.vue +++ b/frontend/src/views/database/redis/command/index.vue @@ -21,22 +21,46 @@ @@ -55,7 +79,7 @@