fix: 网元激活码多行行内容提取

This commit is contained in:
TsMask
2025-05-29 21:25:42 +08:00
parent d9bb31a523
commit 72ffd848d7
3 changed files with 5 additions and 5 deletions

View File

@@ -268,7 +268,7 @@ func (s *NeLicenseController) State(c *gin.Context) {
neLicense.Status = "0" neLicense.Status = "0"
} }
// 更新授权码 // 更新授权码
if neLicense.ActivationRequestCode == "" || strings.HasPrefix(neLicense.ActivationRequestCode, "SN") { if neLicense.ActivationRequestCode == "" || strings.HasPrefix(neLicense.ActivationRequestCode, "SN") || neLicense.Status == "0" {
code, licensePath := s.neLicenseService.ReadLicenseInfo(neLicense) code, licensePath := s.neLicenseService.ReadLicenseInfo(neLicense)
neLicense.ActivationRequestCode = code neLicense.ActivationRequestCode = code
neLicense.LicensePath = licensePath neLicense.LicensePath = licensePath

View File

@@ -138,9 +138,9 @@ func (r *NeLicense) ReadLicenseInfo(neLicense model.NeLicense) (string, string)
} }
activationRequestCode := string(bytes) activationRequestCode := string(bytes)
parts := strings.SplitAfter(string(bytes), "\n") parts := strings.Split(activationRequestCode, "\n")
if len(parts) > 1 { if len(parts) > 1 && strings.HasPrefix(parts[0], "SN") {
activationRequestCode = parts[1] // 获取 \n 后的内容 activationRequestCode = parts[1] // 获取第二行内容
} }
return strings.TrimSpace(activationRequestCode), licensePath return strings.TrimSpace(activationRequestCode), licensePath
} }

View File

@@ -658,7 +658,7 @@ func (r NeVersion) operateRun(sshClient *ssh.ConnSSH, preinput map[string]string
} }
} }
if !suffix { if !suffix {
suffix = strings.LastIndex(outputStr, "~# ") != -1 suffix = strings.LastIndex(outputStr, "# ") != -1 // 特殊内容中的终端终止符
} }
if len(cmdStrArr) > 0 && suffix { if len(cmdStrArr) > 0 && suffix {
if firstRead { if firstRead {