This commit is contained in:
Liang Ding 2014-10-22 17:47:53 +08:00
parent bc9145790c
commit a8c55a6f9b
2 changed files with 122 additions and 96 deletions

View File

@ -262,7 +262,30 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
return return
} }
if data["succ"].(bool) { if !data["succ"].(bool) {
return
}
channelRet := map[string]interface{}{}
if nil != session.OutputWS[sid] {
// 在前端 output 中显示“开始构建”
channelRet["output"] = "go build"
channelRet["cmd"] = "pre-build"
wsChannel := session.OutputWS[sid]
err := wsChannel.Conn.WriteJSON(&channelRet)
if nil != err {
glog.Error(err)
return
}
// 更新通道最近使用时间
wsChannel.Time = time.Now()
}
reader := io.MultiReader(stdout, stderr) reader := io.MultiReader(stdout, stderr)
if err := cmd.Start(); nil != err { if err := cmd.Start(); nil != err {
@ -361,7 +384,6 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
} }
}(rand.Int()) }(rand.Int())
}
} }
// go install. // go install.

View File

@ -317,6 +317,8 @@ var wide = {
}); });
} }
// TODO: 重构成 switch-case
if ('run' === data.cmd) { // 正在运行 if ('run' === data.cmd) { // 正在运行
wide.fillOutput($('.bottom-window-group .output').text() + data.output); wide.fillOutput($('.bottom-window-group .output').text() + data.output);
wide.curProcessId = data.pid; wide.curProcessId = data.pid;
@ -345,6 +347,8 @@ var wide = {
CodeMirror.signal(wide.curEditor, "change", wide.curEditor); CodeMirror.signal(wide.curEditor, "change", wide.curEditor);
} else if ('go get' === data.cmd || 'go install' === data.cmd) { } else if ('go get' === data.cmd || 'go install' === data.cmd) {
wide.fillOutput($('.bottom-window-group .output').text() + data.output); wide.fillOutput($('.bottom-window-group .output').text() + data.output);
} else if ('pre-build' === data.cmd) {
wide.fillOutput(data.output);
} }
}; };
outputWS.onclose = function (e) { outputWS.onclose = function (e) {