From ad6a1ac4655660474ce8bc1dd4538293560f2061 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Thu, 25 Apr 2024 19:07:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Docker=20=E9=85=8D=E7=BD=AE=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E8=BF=87=E6=BB=A4=E7=A9=BA=E8=A1=8C=20(#4707)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs #4701 --- backend/app/api/v1/docker.go | 8 ++++---- cmd/server/docs/docs.go | 16 ++++++++-------- cmd/server/docs/swagger.json | 16 ++++++++-------- cmd/server/docs/swagger.yaml | 16 ++++++++-------- frontend/src/utils/util.ts | 11 +++++++++++ .../src/views/container/setting/mirror/index.vue | 3 ++- .../views/container/setting/registry/index.vue | 3 ++- 7 files changed, 43 insertions(+), 30 deletions(-) diff --git a/backend/app/api/v1/docker.go b/backend/app/api/v1/docker.go index 1d493aab3..79a2e232f 100644 --- a/backend/app/api/v1/docker.go +++ b/backend/app/api/v1/docker.go @@ -61,7 +61,7 @@ func (b *BaseApi) LoadDaemonJson(c *gin.Context) { // @Success 200 // @Security ApiKeyAuth // @Router /containers/daemonjson/update [post] -// @x-panel-log {"bodyKeys":["key", "value"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 docker daemon.json 配置 [key]=>[value]","formatEN":"Updated the docker daemon.json configuration [key]=>[value]"} +// @x-panel-log {"bodyKeys":["key", "value"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新配置 [key]","formatEN":"Updated configuration [key]"} func (b *BaseApi) UpdateDaemonJson(c *gin.Context) { var req dto.SettingUpdate if err := helper.CheckBindAndValidate(&req, c); err != nil { @@ -84,7 +84,7 @@ func (b *BaseApi) UpdateDaemonJson(c *gin.Context) { // @Success 200 // @Security ApiKeyAuth // @Router /containers/logoption/update [post] -// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 docker daemon.json 日志配置","formatEN":"Updated the docker daemon.json log option"} +// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新日志配置","formatEN":"Updated the log option"} func (b *BaseApi) UpdateLogOption(c *gin.Context) { var req dto.LogOption if err := helper.CheckBind(&req, c); err != nil { @@ -107,7 +107,7 @@ func (b *BaseApi) UpdateLogOption(c *gin.Context) { // @Success 200 // @Security ApiKeyAuth // @Router /containers/ipv6option/update [post] -// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 docker daemon.json ipv6 配置","formatEN":"Updated the docker daemon.json ipv6 option"} +// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 ipv6 配置","formatEN":"Updated the ipv6 option"} func (b *BaseApi) UpdateIpv6Option(c *gin.Context) { var req dto.Ipv6Option if err := helper.CheckBind(&req, c); err != nil { @@ -130,7 +130,7 @@ func (b *BaseApi) UpdateIpv6Option(c *gin.Context) { // @Success 200 // @Security ApiKeyAuth // @Router /containers/daemonjson/update/byfile [post] -// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 docker daemon.json 配置","formatEN":"Updated the docker daemon.json configuration"} +// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新配置文件","formatEN":"Updated configuration file"} func (b *BaseApi) UpdateDaemonJsonByFile(c *gin.Context) { var req dto.DaemonJsonUpdateByFile if err := helper.CheckBindAndValidate(&req, c); err != nil { diff --git a/cmd/server/docs/docs.go b/cmd/server/docs/docs.go index 29bac1d03..bcc210e61 100644 --- a/cmd/server/docs/docs.go +++ b/cmd/server/docs/docs.go @@ -1444,8 +1444,8 @@ const docTemplate = `{ "key", "value" ], - "formatEN": "Updated the docker daemon.json configuration [key]=\u003e[value]", - "formatZH": "更新 docker daemon.json 配置 [key]=\u003e[value]", + "formatEN": "Updated configuration [key]", + "formatZH": "更新配置 [key]", "paramKeys": [] } } @@ -1484,8 +1484,8 @@ const docTemplate = `{ "x-panel-log": { "BeforeFunctions": [], "bodyKeys": [], - "formatEN": "Updated the docker daemon.json configuration", - "formatZH": "更新 docker daemon.json 配置", + "formatEN": "Updated configuration file", + "formatZH": "更新配置文件", "paramKeys": [] } } @@ -2094,8 +2094,8 @@ const docTemplate = `{ "x-panel-log": { "BeforeFunctions": [], "bodyKeys": [], - "formatEN": "Updated the docker daemon.json ipv6 option", - "formatZH": "更新 docker daemon.json ipv6 配置", + "formatEN": "Updated the ipv6 option", + "formatZH": "更新 ipv6 配置", "paramKeys": [] } } @@ -2233,8 +2233,8 @@ const docTemplate = `{ "x-panel-log": { "BeforeFunctions": [], "bodyKeys": [], - "formatEN": "Updated the docker daemon.json log option", - "formatZH": "更新 docker daemon.json 日志配置", + "formatEN": "Updated the log option", + "formatZH": "更新日志配置", "paramKeys": [] } } diff --git a/cmd/server/docs/swagger.json b/cmd/server/docs/swagger.json index a33dcc827..5f2fb5d48 100644 --- a/cmd/server/docs/swagger.json +++ b/cmd/server/docs/swagger.json @@ -1437,8 +1437,8 @@ "key", "value" ], - "formatEN": "Updated the docker daemon.json configuration [key]=\u003e[value]", - "formatZH": "更新 docker daemon.json 配置 [key]=\u003e[value]", + "formatEN": "Updated configuration [key]", + "formatZH": "更新配置 [key]", "paramKeys": [] } } @@ -1477,8 +1477,8 @@ "x-panel-log": { "BeforeFunctions": [], "bodyKeys": [], - "formatEN": "Updated the docker daemon.json configuration", - "formatZH": "更新 docker daemon.json 配置", + "formatEN": "Updated configuration file", + "formatZH": "更新配置文件", "paramKeys": [] } } @@ -2087,8 +2087,8 @@ "x-panel-log": { "BeforeFunctions": [], "bodyKeys": [], - "formatEN": "Updated the docker daemon.json ipv6 option", - "formatZH": "更新 docker daemon.json ipv6 配置", + "formatEN": "Updated the ipv6 option", + "formatZH": "更新 ipv6 配置", "paramKeys": [] } } @@ -2226,8 +2226,8 @@ "x-panel-log": { "BeforeFunctions": [], "bodyKeys": [], - "formatEN": "Updated the docker daemon.json log option", - "formatZH": "更新 docker daemon.json 日志配置", + "formatEN": "Updated the log option", + "formatZH": "更新日志配置", "paramKeys": [] } } diff --git a/cmd/server/docs/swagger.yaml b/cmd/server/docs/swagger.yaml index 8ec77eb4d..1e3d3cac2 100644 --- a/cmd/server/docs/swagger.yaml +++ b/cmd/server/docs/swagger.yaml @@ -5948,8 +5948,8 @@ paths: bodyKeys: - key - value - formatEN: Updated the docker daemon.json configuration [key]=>[value] - formatZH: 更新 docker daemon.json 配置 [key]=>[value] + formatEN: Updated configuration [key] + formatZH: 更新配置 [key] paramKeys: [] /containers/daemonjson/update/byfile: post: @@ -5974,8 +5974,8 @@ paths: x-panel-log: BeforeFunctions: [] bodyKeys: [] - formatEN: Updated the docker daemon.json configuration - formatZH: 更新 docker daemon.json 配置 + formatEN: Updated configuration file + formatZH: 更新配置文件 paramKeys: [] /containers/docker/operate: post: @@ -6363,8 +6363,8 @@ paths: x-panel-log: BeforeFunctions: [] bodyKeys: [] - formatEN: Updated the docker daemon.json ipv6 option - formatZH: 更新 docker daemon.json ipv6 配置 + formatEN: Updated the ipv6 option + formatZH: 更新 ipv6 配置 paramKeys: [] /containers/limit: get: @@ -6448,8 +6448,8 @@ paths: x-panel-log: BeforeFunctions: [] bodyKeys: [] - formatEN: Updated the docker daemon.json log option - formatZH: 更新 docker daemon.json 日志配置 + formatEN: Updated the log option + formatZH: 更新日志配置 paramKeys: [] /containers/network: get: diff --git a/frontend/src/utils/util.ts b/frontend/src/utils/util.ts index 642763116..499543412 100644 --- a/frontend/src/utils/util.ts +++ b/frontend/src/utils/util.ts @@ -518,3 +518,14 @@ export function getAction(action: string) { export function getLanguage() { return localStorage.getItem('lang') || 'zh'; } + +export function emptyLineFilter(str: string, spilt: string) { + let list = str.split(spilt); + let results = []; + for (let i = 0; i < list.length; i++) { + if (list[i].trim() !== '') { + results.push(list[i]); + } + } + return results.join(spilt); +} diff --git a/frontend/src/views/container/setting/mirror/index.vue b/frontend/src/views/container/setting/mirror/index.vue index 199660e3c..81a019a22 100644 --- a/frontend/src/views/container/setting/mirror/index.vue +++ b/frontend/src/views/container/setting/mirror/index.vue @@ -46,6 +46,7 @@ import ConfirmDialog from '@/components/confirm-dialog/index.vue'; import { updateDaemonJson } from '@/api/modules/container'; import DrawerHeader from '@/components/drawer-header/index.vue'; import { FormInstance } from 'element-plus'; +import { emptyLineFilter } from '@/utils/util'; const emit = defineEmits<{ (e: 'search'): void }>(); @@ -101,7 +102,7 @@ const onSave = async (formEl: FormInstance | undefined) => { const onSubmit = async () => { loading.value = true; - await updateDaemonJson('Mirrors', form.mirrors.replaceAll('\n', ',')) + await updateDaemonJson('Mirrors', emptyLineFilter(form.mirrors, '\n').replaceAll('\n', ',')) .then(() => { loading.value = false; emit('search'); diff --git a/frontend/src/views/container/setting/registry/index.vue b/frontend/src/views/container/setting/registry/index.vue index 1e34cd369..f4fc7a145 100644 --- a/frontend/src/views/container/setting/registry/index.vue +++ b/frontend/src/views/container/setting/registry/index.vue @@ -46,6 +46,7 @@ import ConfirmDialog from '@/components/confirm-dialog/index.vue'; import { updateDaemonJson } from '@/api/modules/container'; import DrawerHeader from '@/components/drawer-header/index.vue'; import { FormInstance } from 'element-plus'; +import { emptyLineFilter } from '@/utils/util'; const emit = defineEmits<{ (e: 'search'): void }>(); @@ -97,7 +98,7 @@ const onSave = async () => { const onSubmit = async () => { loading.value = true; - await updateDaemonJson('Registries', form.registries.replaceAll('\n', ',')) + await updateDaemonJson('Registries', emptyLineFilter(form.registries, '\n').replaceAll('\n', ',')) .then(() => { loading.value = false; handleClose();