optimize output stderr 📜
This commit is contained in:
parent
0a5a88335d
commit
a2f50ae94e
|
@ -191,6 +191,7 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
}()
|
||||
|
||||
buf := outputBuf{}
|
||||
for {
|
||||
r, _, err := errReader.ReadRune()
|
||||
|
||||
|
@ -199,19 +200,32 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
|
|||
break
|
||||
}
|
||||
|
||||
buf := string(r)
|
||||
buf = strings.Replace(buf, "<", "<", -1)
|
||||
buf = strings.Replace(buf, ">", ">", -1)
|
||||
oneRuneStr := string(r)
|
||||
oneRuneStr = strings.Replace(oneRuneStr, "<", "<", -1)
|
||||
oneRuneStr = strings.Replace(oneRuneStr, ">", ">", -1)
|
||||
|
||||
channelRet["cmd"] = "run"
|
||||
channelRet["output"] = "<span class='stderr'>" + buf + "</span>"
|
||||
err = wsChannel.WriteJSON(&channelRet)
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
break
|
||||
buf.content += oneRuneStr
|
||||
|
||||
now := time.Now().UnixNano() / int64(time.Millisecond)
|
||||
|
||||
if 0 == buf.millisecond {
|
||||
buf.millisecond = now
|
||||
}
|
||||
|
||||
wsChannel.Refresh()
|
||||
if now-outputTimeout >= buf.millisecond || len(buf.content) > outputBufMax || oneRuneStr == "\n" {
|
||||
channelRet["cmd"] = "run"
|
||||
channelRet["output"] = "<span class='stderr'>" + buf.content + "</span>"
|
||||
|
||||
buf = outputBuf{} // a new buffer
|
||||
|
||||
err = wsChannel.WriteJSON(&channelRet)
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
break
|
||||
}
|
||||
|
||||
wsChannel.Refresh()
|
||||
}
|
||||
}
|
||||
}(rand.Int())
|
||||
}
|
||||
|
|
|
@ -439,6 +439,7 @@
|
|||
padding: 0 5px;
|
||||
line-height: 16px;
|
||||
font-size: 12px;
|
||||
overflow-x: scroll;
|
||||
}
|
||||
|
||||
.bottom-window-group .output pre {
|
||||
|
|
Loading…
Reference in New Issue