Bläddra i källkod

fix: 优化日志效果 (#80)

langren1353 2 år sedan
förälder
incheckning
8cfde6b2b8
2 ändrade filer med 13 tillägg och 12 borttagningar
  1. 1 1
      client/backup.go
  2. 12 11
      web/writing.html

+ 1 - 1
client/backup.go

@@ -200,7 +200,7 @@ func backup(backupConf entity.BackupConfig, encryptKey string, s3Conf entity.S3C
 		if util.IsGBK(outputBytes) {
 			outputBytes, _ = util.GbkToUtf8(outputBytes)
 		}
-		log.Printf("<span title=\"%s\">%s 执行shell的输出: 鼠标移动此处查看</span>\n", util.EscapeShell(string(outputBytes)), backupConf.ProjectName)
+		log.Printf("<span style='color: #7983f5;font-weight: bold;'>%s</span> 执行shell的输出: <span title=\"%s\" style='cursor: pointer; color: #4a3a3a; font-weight: bold'>鼠标[停留]此处查看</span>\n", backupConf.ProjectName, util.EscapeShell(string(outputBytes)))
 	} else {
 		log.Printf("执行shell的输出为空\n")
 	}

+ 12 - 11
web/writing.html

@@ -287,6 +287,7 @@
 
   <script>
     let contentIdx = 0
+    let logType = 1
     let logList = [] // 0:所有日志;1:日常日志;2:登录日志
 
     function contentChange(i) {
@@ -294,7 +295,8 @@
     }
     
     function changeLog(type = 0) {
-      const curLogList = logList[type]
+      logType = type
+      const curLogList = logList[logType]
       const totalLogList = logList[0]
       
       const failedCount = totalLogList.filter(one => one.includes('登录失败')).length
@@ -328,6 +330,9 @@
               // ok
               $('.alert').addClass("alert-success").removeClass("alert-danger")
               $('#resultMsg').html("保存成功")
+              setTimeout(() => {
+                getLogs()
+              }, 800)
               setTimeout(function(){
                 $('.alert').css("display", "none");
               }, 3000)
@@ -345,19 +350,16 @@
     function projectNameChange(that) {
       let id = $(that).attr("id").split("_")[1]
       let name = $(that).val()
-      let enabled = $("#Enabled_"+id).val()
-      $("#id_"+id).html(enabled === 0?name:name+'<span class="badge badge-pill badge-warning">停用</span>')
+      let enabled = +$("#Enabled_"+id).val() === 0
+      $("#id_"+id).html(enabled ? name:name+'<span class="badge badge-pill badge-warning">停用</span>')
     }
     // enabledChange
     function enabledChange(that) {
       let id = $(that).attr("id").split("_")[1]
       let name = $("#ProjectName_"+id).val()
-      let enabled = $(that).val()
-      $("#id_"+id).html(enabled === 0?name:name+'<span class="badge badge-pill badge-warning">停用</span>')
+      let enabled = +$(that).val() === 0
+      $("#id_"+id).html(enabled ? name:name+'<span class="badge badge-pill badge-warning">停用</span>')
     }
-
-
-
   </script>
 
   <script>
@@ -366,11 +368,10 @@
         const curList = result.split("<br/>").filter(one => one.length)
 
         logList[0] = curList.map(one => one)
-        
         logList[1] = curList.filter(one => !one.includes("登录"))
         logList[2] = curList.filter(one => one.includes("登录"))
         
-        changeLog(1)
+        changeLog(logType)
       })
     }
     getLogs()
@@ -413,5 +414,5 @@
       })
     })
   </script>
-
+</body>
 </html>