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,12 +200,24 @@ 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)
|
||||
|
||||
buf.content += oneRuneStr
|
||||
|
||||
now := time.Now().UnixNano() / int64(time.Millisecond)
|
||||
|
||||
if 0 == buf.millisecond {
|
||||
buf.millisecond = now
|
||||
}
|
||||
|
||||
if now-outputTimeout >= buf.millisecond || len(buf.content) > outputBufMax || oneRuneStr == "\n" {
|
||||
channelRet["cmd"] = "run"
|
||||
channelRet["output"] = "<span class='stderr'>" + buf + "</span>"
|
||||
channelRet["output"] = "<span class='stderr'>" + buf.content + "</span>"
|
||||
|
||||
buf = outputBuf{} // a new buffer
|
||||
|
||||
err = wsChannel.WriteJSON(&channelRet)
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
|
@ -213,6 +226,7 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
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