fix: Docker 配置自动过滤空行 (#4707)

Refs #4701
pull/4721/head
ssongliu 7 months ago committed by GitHub
parent 35f311c452
commit ad6a1ac465
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -61,7 +61,7 @@ func (b *BaseApi) LoadDaemonJson(c *gin.Context) {
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Router /containers/daemonjson/update [post] // @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) { func (b *BaseApi) UpdateDaemonJson(c *gin.Context) {
var req dto.SettingUpdate var req dto.SettingUpdate
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
@ -84,7 +84,7 @@ func (b *BaseApi) UpdateDaemonJson(c *gin.Context) {
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Router /containers/logoption/update [post] // @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) { func (b *BaseApi) UpdateLogOption(c *gin.Context) {
var req dto.LogOption var req dto.LogOption
if err := helper.CheckBind(&req, c); err != nil { if err := helper.CheckBind(&req, c); err != nil {
@ -107,7 +107,7 @@ func (b *BaseApi) UpdateLogOption(c *gin.Context) {
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Router /containers/ipv6option/update [post] // @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) { func (b *BaseApi) UpdateIpv6Option(c *gin.Context) {
var req dto.Ipv6Option var req dto.Ipv6Option
if err := helper.CheckBind(&req, c); err != nil { if err := helper.CheckBind(&req, c); err != nil {
@ -130,7 +130,7 @@ func (b *BaseApi) UpdateIpv6Option(c *gin.Context) {
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Router /containers/daemonjson/update/byfile [post] // @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) { func (b *BaseApi) UpdateDaemonJsonByFile(c *gin.Context) {
var req dto.DaemonJsonUpdateByFile var req dto.DaemonJsonUpdateByFile
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {

@ -1444,8 +1444,8 @@ const docTemplate = `{
"key", "key",
"value" "value"
], ],
"formatEN": "Updated the docker daemon.json configuration [key]=\u003e[value]", "formatEN": "Updated configuration [key]",
"formatZH": "更新 docker daemon.json 配置 [key]=\u003e[value]", "formatZH": "更新配置 [key]",
"paramKeys": [] "paramKeys": []
} }
} }
@ -1484,8 +1484,8 @@ const docTemplate = `{
"x-panel-log": { "x-panel-log": {
"BeforeFunctions": [], "BeforeFunctions": [],
"bodyKeys": [], "bodyKeys": [],
"formatEN": "Updated the docker daemon.json configuration", "formatEN": "Updated configuration file",
"formatZH": "更新 docker daemon.json 配置", "formatZH": "更新配置文件",
"paramKeys": [] "paramKeys": []
} }
} }
@ -2094,8 +2094,8 @@ const docTemplate = `{
"x-panel-log": { "x-panel-log": {
"BeforeFunctions": [], "BeforeFunctions": [],
"bodyKeys": [], "bodyKeys": [],
"formatEN": "Updated the docker daemon.json ipv6 option", "formatEN": "Updated the ipv6 option",
"formatZH": "更新 docker daemon.json ipv6 配置", "formatZH": "更新 ipv6 配置",
"paramKeys": [] "paramKeys": []
} }
} }
@ -2233,8 +2233,8 @@ const docTemplate = `{
"x-panel-log": { "x-panel-log": {
"BeforeFunctions": [], "BeforeFunctions": [],
"bodyKeys": [], "bodyKeys": [],
"formatEN": "Updated the docker daemon.json log option", "formatEN": "Updated the log option",
"formatZH": "更新 docker daemon.json 日志配置", "formatZH": "更新日志配置",
"paramKeys": [] "paramKeys": []
} }
} }

@ -1437,8 +1437,8 @@
"key", "key",
"value" "value"
], ],
"formatEN": "Updated the docker daemon.json configuration [key]=\u003e[value]", "formatEN": "Updated configuration [key]",
"formatZH": "更新 docker daemon.json 配置 [key]=\u003e[value]", "formatZH": "更新配置 [key]",
"paramKeys": [] "paramKeys": []
} }
} }
@ -1477,8 +1477,8 @@
"x-panel-log": { "x-panel-log": {
"BeforeFunctions": [], "BeforeFunctions": [],
"bodyKeys": [], "bodyKeys": [],
"formatEN": "Updated the docker daemon.json configuration", "formatEN": "Updated configuration file",
"formatZH": "更新 docker daemon.json 配置", "formatZH": "更新配置文件",
"paramKeys": [] "paramKeys": []
} }
} }
@ -2087,8 +2087,8 @@
"x-panel-log": { "x-panel-log": {
"BeforeFunctions": [], "BeforeFunctions": [],
"bodyKeys": [], "bodyKeys": [],
"formatEN": "Updated the docker daemon.json ipv6 option", "formatEN": "Updated the ipv6 option",
"formatZH": "更新 docker daemon.json ipv6 配置", "formatZH": "更新 ipv6 配置",
"paramKeys": [] "paramKeys": []
} }
} }
@ -2226,8 +2226,8 @@
"x-panel-log": { "x-panel-log": {
"BeforeFunctions": [], "BeforeFunctions": [],
"bodyKeys": [], "bodyKeys": [],
"formatEN": "Updated the docker daemon.json log option", "formatEN": "Updated the log option",
"formatZH": "更新 docker daemon.json 日志配置", "formatZH": "更新日志配置",
"paramKeys": [] "paramKeys": []
} }
} }

@ -5948,8 +5948,8 @@ paths:
bodyKeys: bodyKeys:
- key - key
- value - value
formatEN: Updated the docker daemon.json configuration [key]=>[value] formatEN: Updated configuration [key]
formatZH: 更新 docker daemon.json 配置 [key]=>[value] formatZH: 更新配置 [key]
paramKeys: [] paramKeys: []
/containers/daemonjson/update/byfile: /containers/daemonjson/update/byfile:
post: post:
@ -5974,8 +5974,8 @@ paths:
x-panel-log: x-panel-log:
BeforeFunctions: [] BeforeFunctions: []
bodyKeys: [] bodyKeys: []
formatEN: Updated the docker daemon.json configuration formatEN: Updated configuration file
formatZH: 更新 docker daemon.json 配置 formatZH: 更新配置文件
paramKeys: [] paramKeys: []
/containers/docker/operate: /containers/docker/operate:
post: post:
@ -6363,8 +6363,8 @@ paths:
x-panel-log: x-panel-log:
BeforeFunctions: [] BeforeFunctions: []
bodyKeys: [] bodyKeys: []
formatEN: Updated the docker daemon.json ipv6 option formatEN: Updated the ipv6 option
formatZH: 更新 docker daemon.json ipv6 配置 formatZH: 更新 ipv6 配置
paramKeys: [] paramKeys: []
/containers/limit: /containers/limit:
get: get:
@ -6448,8 +6448,8 @@ paths:
x-panel-log: x-panel-log:
BeforeFunctions: [] BeforeFunctions: []
bodyKeys: [] bodyKeys: []
formatEN: Updated the docker daemon.json log option formatEN: Updated the log option
formatZH: 更新 docker daemon.json 日志配置 formatZH: 更新日志配置
paramKeys: [] paramKeys: []
/containers/network: /containers/network:
get: get:

@ -518,3 +518,14 @@ export function getAction(action: string) {
export function getLanguage() { export function getLanguage() {
return localStorage.getItem('lang') || 'zh'; 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);
}

@ -46,6 +46,7 @@ import ConfirmDialog from '@/components/confirm-dialog/index.vue';
import { updateDaemonJson } from '@/api/modules/container'; import { updateDaemonJson } from '@/api/modules/container';
import DrawerHeader from '@/components/drawer-header/index.vue'; import DrawerHeader from '@/components/drawer-header/index.vue';
import { FormInstance } from 'element-plus'; import { FormInstance } from 'element-plus';
import { emptyLineFilter } from '@/utils/util';
const emit = defineEmits<{ (e: 'search'): void }>(); const emit = defineEmits<{ (e: 'search'): void }>();
@ -101,7 +102,7 @@ const onSave = async (formEl: FormInstance | undefined) => {
const onSubmit = async () => { const onSubmit = async () => {
loading.value = true; loading.value = true;
await updateDaemonJson('Mirrors', form.mirrors.replaceAll('\n', ',')) await updateDaemonJson('Mirrors', emptyLineFilter(form.mirrors, '\n').replaceAll('\n', ','))
.then(() => { .then(() => {
loading.value = false; loading.value = false;
emit('search'); emit('search');

@ -46,6 +46,7 @@ import ConfirmDialog from '@/components/confirm-dialog/index.vue';
import { updateDaemonJson } from '@/api/modules/container'; import { updateDaemonJson } from '@/api/modules/container';
import DrawerHeader from '@/components/drawer-header/index.vue'; import DrawerHeader from '@/components/drawer-header/index.vue';
import { FormInstance } from 'element-plus'; import { FormInstance } from 'element-plus';
import { emptyLineFilter } from '@/utils/util';
const emit = defineEmits<{ (e: 'search'): void }>(); const emit = defineEmits<{ (e: 'search'): void }>();
@ -97,7 +98,7 @@ const onSave = async () => {
const onSubmit = async () => { const onSubmit = async () => {
loading.value = true; loading.value = true;
await updateDaemonJson('Registries', form.registries.replaceAll('\n', ',')) await updateDaemonJson('Registries', emptyLineFilter(form.registries, '\n').replaceAll('\n', ','))
.then(() => { .then(() => {
loading.value = false; loading.value = false;
handleClose(); handleClose();

Loading…
Cancel
Save