构建提示
This commit is contained in:
parent
a3801b3b0b
commit
775b11b210
|
@ -272,8 +272,8 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
|
|||
if nil != session.OutputWS[sid] {
|
||||
// 在前端 output 中显示“开始构建”
|
||||
|
||||
channelRet["output"] = i18n
|
||||
channelRet["cmd"] = "pre-build"
|
||||
channelRet["output"] = i18n.Get(r, "start-build").(string) + "\n"
|
||||
channelRet["cmd"] = "start-build"
|
||||
|
||||
wsChannel := session.OutputWS[sid]
|
||||
|
||||
|
@ -313,7 +313,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
|
|||
if 0 == count { // 说明构建成功,没有错误信息输出
|
||||
// 设置下一次执行命令(前端会根据这个发送请求)
|
||||
channelRet["nextCmd"] = args["nextCmd"]
|
||||
channelRet["output"] = "Build Succ"
|
||||
channelRet["output"] = i18n.Get(r, "build-succ").(string) + "\n"
|
||||
|
||||
go func() { // 运行 go install,生成的库用于 gocode lib-path
|
||||
cmd := exec.Command("go", "install")
|
||||
|
@ -329,7 +329,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
|
|||
} else { // 构建失败
|
||||
// 解析错误信息,返回给编辑器 gutter lint
|
||||
errOut := string(buf[:count])
|
||||
channelRet["output"] = "Build Failed\n" + errOut
|
||||
channelRet["output"] = i18n.Get(r, "build-failed").(string) + "\n" + errOut
|
||||
|
||||
lines := strings.Split(errOut, "\n")
|
||||
|
||||
|
|
|
@ -322,7 +322,6 @@ var wide = {
|
|||
data: JSON.stringify(request),
|
||||
dataType: "json",
|
||||
beforeSend: function (data) {
|
||||
$('.bottom-window-group .output').text('');
|
||||
},
|
||||
success: function (data) {
|
||||
|
||||
|
@ -330,20 +329,35 @@ var wide = {
|
|||
});
|
||||
}
|
||||
|
||||
// TODO: 重构成 switch-case
|
||||
|
||||
if ('run' === data.cmd) { // 正在运行
|
||||
switch (data.cmd) {
|
||||
case 'run': // 正在运行
|
||||
wide.fillOutput($('.bottom-window-group .output').text() + data.output);
|
||||
wide.curProcessId = data.pid;
|
||||
} else if ('run-done' === data.cmd) { // 运行结束
|
||||
|
||||
break;
|
||||
case 'run-done': // 运行结束
|
||||
wide.curProcessId = undefined;
|
||||
// 运行结束后修改 [构建&运行] 图标状态为可用状态
|
||||
$(".toolbars .ico-stop").removeClass("ico-stop")
|
||||
.addClass("ico-buildrun").attr("title", config.label.build_n_run);
|
||||
} else if ('build' === data.cmd || 'go install' === data.cmd) {
|
||||
|
||||
break;
|
||||
case 'start-build':
|
||||
wide.fillOutput(data.output);
|
||||
|
||||
if (0 !== data.output.length) { // 说明编译有错误输出
|
||||
break;
|
||||
case 'go install':
|
||||
wide.fillOutput($('.bottom-window-group .output').text() + data.output);
|
||||
|
||||
break;
|
||||
case 'go get':
|
||||
wide.fillOutput($('.bottom-window-group .output').text() + data.output);
|
||||
|
||||
break;
|
||||
case 'build':
|
||||
wide.fillOutput($('.bottom-window-group .output').text() + data.output);
|
||||
|
||||
if (data.lints) { // 说明编译有错误输出
|
||||
for (var i = 0; i < data.lints.length; i++) {
|
||||
var lint = data.lints[i];
|
||||
|
||||
|
@ -358,10 +372,8 @@ var wide = {
|
|||
|
||||
// 触发一次 gutter lint
|
||||
CodeMirror.signal(wide.curEditor, "change", wide.curEditor);
|
||||
} else if ('go get' === data.cmd || 'go install' === data.cmd) {
|
||||
wide.fillOutput($('.bottom-window-group .output').text() + data.output);
|
||||
} else if ('pre-build' === data.cmd) {
|
||||
wide.fillOutput(data.output);
|
||||
|
||||
break;
|
||||
}
|
||||
};
|
||||
outputWS.onclose = function (e) {
|
||||
|
|
Loading…
Reference in New Issue