From b8b2041a0c5b2d0b67658cbfe07397ab10b6d37b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=98=AD?= <81747598+lan-yonghui@users.noreply.github.com> Date: Fri, 1 Aug 2025 16:01:24 +0800 Subject: [PATCH] fix: Fix Docker proxy error issue (#9790) refs #9780 --- core/app/service/setting.go | 25 +++++++++++-------- .../src/views/setting/panel/proxy/index.vue | 4 +-- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/core/app/service/setting.go b/core/app/service/setting.go index f6d4be6bc..3210ab519 100644 --- a/core/app/service/setting.go +++ b/core/app/service/setting.go @@ -189,7 +189,11 @@ func (u *SettingService) UpdateBindInfo(req dto.BindInfo) error { } func (u *SettingService) UpdateProxy(req dto.ProxyUpdate) error { - if err := settingRepo.Update("ProxyUrl", req.ProxyUrl); err != nil { + proxyUrl := req.ProxyUrl + if req.ProxyType == "https" || req.ProxyType == "http" { + proxyUrl = req.ProxyType + "://" + req.ProxyUrl + } + if err := settingRepo.Update("ProxyUrl", proxyUrl); err != nil { return err } if err := settingRepo.Update("ProxyType", req.ProxyType); err != nil { @@ -675,16 +679,17 @@ func (u *SettingService) GetAppstoreConfig() (*dto.AppstoreConfig, error) { } func loadDockerProxy(req dto.ProxyUpdate) string { - if len(req.ProxyType) == 0 || req.ProxyType == "close" || !req.ProxyDocker { + if req.ProxyType == "" || req.ProxyType == "close" || !req.ProxyDocker { return "" } - proxyPasswd := "" - if len(req.ProxyUser) != 0 { - proxyPasswd = req.ProxyPasswd + "@" + var account string + if req.ProxyUser != "" { + account = req.ProxyUser + if req.ProxyPasswd != "" { + account += ":" + req.ProxyPasswd + } + account += "@" } - proxyUrl := req.ProxyType + "://" + req.ProxyUser + ":" + proxyPasswd + req.ProxyUrl + ":" + req.ProxyPort - if req.ProxyType == "http" || req.ProxyType == "https" { - req.ProxyUrl = req.ProxyType + "://" + req.ProxyUrl - } - return proxyUrl + + return fmt.Sprintf("%s://%s%s:%s", req.ProxyType, account, req.ProxyUrl, req.ProxyPort) } diff --git a/frontend/src/views/setting/panel/proxy/index.vue b/frontend/src/views/setting/panel/proxy/index.vue index 842b1bd01..28f574659 100644 --- a/frontend/src/views/setting/panel/proxy/index.vue +++ b/frontend/src/views/setting/panel/proxy/index.vue @@ -156,7 +156,7 @@ const submitChangePassword = async (formEl: FormInstance | undefined) => { params.proxyPasswdKeep = form.proxyPasswdKeepItem ? 'Enable' : 'Disable'; } if (form.proxyType === 'http' || form.proxyType === 'https') { - params.proxyUrl = form.proxyType + '://' + form.proxyUrl; + params.proxyUrl = form.proxyUrl; } if (isMasterProductPro.value && (params.proxyDocker || proxyDockerVisible.value)) { dockerProxyRef.value.acceptParams({ @@ -197,7 +197,7 @@ const onSubmit = async () => { params.proxyPasswdKeep = form.proxyPasswdKeepItem ? 'Enable' : 'Disable'; } if (form.proxyType === 'http' || form.proxyType === 'https') { - params.proxyUrl = form.proxyType + '://' + form.proxyUrl; + params.proxyUrl = form.proxyUrl; } await updateProxy(params); emit('search');