fix(app): Fix issue with leading zero parameter loss in applications. (#8450)

Refs https://github.com/1Panel-dev/1Panel/issues/6557
This commit is contained in:
ChengPlay 2025-04-22 17:09:07 +08:00 committed by GitHub
parent 86e6721be5
commit 3370bac67a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 25 additions and 12 deletions

View file

@ -10,7 +10,7 @@ import (
)
func Write(envMap map[string]string, filename string) error {
content, err := Marshal(envMap)
content, err := marshal(envMap)
if err != nil {
return err
}
@ -26,10 +26,10 @@ func Write(envMap map[string]string, filename string) error {
return file.Sync()
}
func Marshal(envMap map[string]string) (string, error) {
func marshal(envMap map[string]string) (string, error) {
lines := make([]string, 0, len(envMap))
for k, v := range envMap {
if d, err := strconv.Atoi(v); err == nil {
if d, err := strconv.Atoi(v); err == nil && !isStartWithZero(v) {
lines = append(lines, fmt.Sprintf(`%s=%d`, k, d))
} else {
lines = append(lines, fmt.Sprintf(`%s="%s"`, k, v))
@ -50,3 +50,10 @@ func GetEnvValueByKey(envPath, key string) (string, error) {
}
return value, nil
}
func isStartWithZero(value string) bool {
if strings.HasPrefix(value, "0") && len(value) > 1 {
return true
}
return false
}

View file

@ -51,7 +51,7 @@ const props = defineProps({
},
heightDiff: {
type: Number,
default: 0,
default: 320,
},
height: {
type: Number,

View file

@ -2094,7 +2094,8 @@ const message = {
ignoreAll: 'Ignore all subsequent versions',
ignoreVersion: 'Ignore specified version',
specifyIP: 'Bind Host IP',
specifyIPHelper: 'Set the host address to bind the port, usually the local machine IP',
specifyIPHelper:
'Set the host address/network interface to bind the port (if you are not sure about this, please do not fill it in)',
},
website: {
primaryDomain: 'Primary Domain',

View file

@ -1997,7 +1997,8 @@ const message = {
ignoreAll: '後続のすべてのバージョンを無視',
ignoreVersion: '指定されたバージョンを無視',
specifyIP: 'ホスト IP をバインド',
specifyIPHelper: 'ポートにバインドするホストアドレスを設定します通常はローカルマシンの IP です',
specifyIPHelper:
'ポートにバインドするホストアドレス/ネットワークインターフェースを設定しますこの機能がわからない場合は入力しないでください',
},
website: {
primaryDomain: 'プライマリドメイン',

View file

@ -1965,7 +1965,8 @@ const message = {
ignoreAll: '후속 모든 버전 무시',
ignoreVersion: '지정된 버전 무시',
specifyIP: '호스트 IP 바인딩',
specifyIPHelper: '포트 바인딩을 위한 호스트 주소를 설정합니다. 일반적으로 로컬 머신의 IP입니다',
specifyIPHelper:
'포트 바인딩을 위한 호스트 주소/네트워크 인터페이스를 설정합니다 ( 기능을 모를 경우, 입력하지 마십시오)',
},
website: {
primaryDomain: '기본 도메인',

View file

@ -2051,7 +2051,8 @@ const message = {
ignoreAll: 'Abaikan semua versi berikutnya',
ignoreVersion: 'Abaikan versi yang ditentukan',
specifyIP: 'Bind IP Hos',
specifyIPHelper: 'Tetapkan alamat hos untuk mengikat port, biasanya IP mesin tempatan',
specifyIPHelper:
'Tetapkan alamat hos/antara muka rangkaian untuk mengikat port (jika anda tidak pasti mengenai ini, jangan isi)',
},
website: {
primaryDomain: 'Domain Utama',

View file

@ -2043,7 +2043,8 @@ const message = {
ignoreAll: 'Ignorar todas as versões subsequentes',
ignoreVersion: 'Ignorar versão especificada',
specifyIP: 'Vincular IP do Host',
specifyIPHelper: 'Defina o endereço do host para vincular a porta, geralmente o IP da máquina local',
specifyIPHelper:
'Defina o endereço do host/interface de rede para vincular a porta (se você não tiver certeza sobre isso, por favor, não preencha)',
},
website: {
primaryDomain: 'Domínio principal',

View file

@ -2043,7 +2043,8 @@ const message = {
ignoreAll: 'Игнорировать все последующие версии',
ignoreVersion: 'Игнорировать указанную версию',
specifyIP: 'Привязать IP хоста',
specifyIPHelper: 'Установите адрес хоста для привязки порта, обычно IP локального компьютера',
specifyIPHelper:
'Установите адрес хоста/сетевого интерфейса для привязки порта (если вы не уверены в этом, пожалуйста, не заполняйте)',
},
website: {
primaryDomain: 'Основной домен',

View file

@ -1939,7 +1939,7 @@ const message = {
ignoreAll: '忽略後續所有版本',
ignoreVersion: '忽略指定版本',
specifyIP: '綁定主機 IP',
specifyIPHelper: '設置端口綁定的主機地址一般為本機 IP',
specifyIPHelper: '設置端口綁定的主機地址/網卡如果你不清楚這個的作用請不要填寫',
},
website: {
primaryDomain: '主域名',

View file

@ -1929,7 +1929,7 @@ const message = {
ignoreAll: '忽略后续所有版本',
ignoreVersion: '忽略指定版本',
specifyIP: '绑定主机 IP',
specifyIPHelper: '设置端口绑定的主机地址一般为本机 IP',
specifyIPHelper: '设置端口绑定的主机地址/网卡如果你不清楚这个的作用请不要填写',
},
website: {
primaryDomain: '主域名',