fix: Fix Docker proxy error issue (#9790)

refs #9780
This commit is contained in:
2025-08-01 16:01:24 +08:00 committed by GitHub
parent c45bb60b50
commit b8b2041a0c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 12 deletions

View file

@ -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)
}

View file

@ -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');