构建提示
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] {
|
if nil != session.OutputWS[sid] {
|
||||||
// 在前端 output 中显示“开始构建”
|
// 在前端 output 中显示“开始构建”
|
||||||
|
|
||||||
channelRet["output"] = i18n
|
channelRet["output"] = i18n.Get(r, "start-build").(string) + "\n"
|
||||||
channelRet["cmd"] = "pre-build"
|
channelRet["cmd"] = "start-build"
|
||||||
|
|
||||||
wsChannel := session.OutputWS[sid]
|
wsChannel := session.OutputWS[sid]
|
||||||
|
|
||||||
|
@ -313,7 +313,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
if 0 == count { // 说明构建成功,没有错误信息输出
|
if 0 == count { // 说明构建成功,没有错误信息输出
|
||||||
// 设置下一次执行命令(前端会根据这个发送请求)
|
// 设置下一次执行命令(前端会根据这个发送请求)
|
||||||
channelRet["nextCmd"] = args["nextCmd"]
|
channelRet["nextCmd"] = args["nextCmd"]
|
||||||
channelRet["output"] = "Build Succ"
|
channelRet["output"] = i18n.Get(r, "build-succ").(string) + "\n"
|
||||||
|
|
||||||
go func() { // 运行 go install,生成的库用于 gocode lib-path
|
go func() { // 运行 go install,生成的库用于 gocode lib-path
|
||||||
cmd := exec.Command("go", "install")
|
cmd := exec.Command("go", "install")
|
||||||
|
@ -329,7 +329,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
} else { // 构建失败
|
} else { // 构建失败
|
||||||
// 解析错误信息,返回给编辑器 gutter lint
|
// 解析错误信息,返回给编辑器 gutter lint
|
||||||
errOut := string(buf[:count])
|
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")
|
lines := strings.Split(errOut, "\n")
|
||||||
|
|
||||||
|
|
|
@ -276,7 +276,7 @@ var wide = {
|
||||||
"title": config.label.about,
|
"title": config.label.about,
|
||||||
"hideFooter": true
|
"hideFooter": true
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: remove
|
// TODO: remove
|
||||||
$("#dialogAbout").dialog("open");
|
$("#dialogAbout").dialog("open");
|
||||||
});
|
});
|
||||||
|
@ -310,8 +310,8 @@ var wide = {
|
||||||
|
|
||||||
if (goLintFound) {
|
if (goLintFound) {
|
||||||
goLintFound = [];
|
goLintFound = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('run' === data.nextCmd) {
|
if ('run' === data.nextCmd) {
|
||||||
var request = newWideRequest();
|
var request = newWideRequest();
|
||||||
request.executable = data.executable;
|
request.executable = data.executable;
|
||||||
|
@ -321,8 +321,7 @@ var wide = {
|
||||||
url: '/run',
|
url: '/run',
|
||||||
data: JSON.stringify(request),
|
data: JSON.stringify(request),
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
beforeSend: function (data) {
|
beforeSend: function (data) {
|
||||||
$('.bottom-window-group .output').text('');
|
|
||||||
},
|
},
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
|
|
||||||
|
@ -330,38 +329,51 @@ var wide = {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: 重构成 switch-case
|
switch (data.cmd) {
|
||||||
|
case 'run': // 正在运行
|
||||||
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;
|
|
||||||
} else if ('run-done' === data.cmd) { // 运行结束
|
|
||||||
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) {
|
|
||||||
wide.fillOutput(data.output);
|
|
||||||
|
|
||||||
if (0 !== data.output.length) { // 说明编译有错误输出
|
|
||||||
for (var i = 0; i < data.lints.length; i++) {
|
|
||||||
var lint = data.lints[i];
|
|
||||||
|
|
||||||
goLintFound.push({from: CodeMirror.Pos(lint.lineNo, 0),
|
|
||||||
to: CodeMirror.Pos(lint.lineNo, 0),
|
|
||||||
message: lint.msg, severity: lint.severity});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 'run-done': // 运行结束
|
||||||
|
wide.curProcessId = undefined;
|
||||||
|
// 运行结束后修改 [构建&运行] 图标状态为可用状态
|
||||||
$(".toolbars .ico-stop").removeClass("ico-stop")
|
$(".toolbars .ico-stop").removeClass("ico-stop")
|
||||||
.addClass("ico-buildrun").attr("title", config.label.build_n_run);
|
.addClass("ico-buildrun").attr("title", config.label.build_n_run);
|
||||||
}
|
|
||||||
|
|
||||||
// 触发一次 gutter lint
|
break;
|
||||||
CodeMirror.signal(wide.curEditor, "change", wide.curEditor);
|
case 'start-build':
|
||||||
} else if ('go get' === data.cmd || 'go install' === data.cmd) {
|
wide.fillOutput(data.output);
|
||||||
wide.fillOutput($('.bottom-window-group .output').text() + data.output);
|
|
||||||
} else if ('pre-build' === data.cmd) {
|
break;
|
||||||
wide.fillOutput(data.output);
|
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];
|
||||||
|
|
||||||
|
goLintFound.push({from: CodeMirror.Pos(lint.lineNo, 0),
|
||||||
|
to: CodeMirror.Pos(lint.lineNo, 0),
|
||||||
|
message: lint.msg, severity: lint.severity});
|
||||||
|
}
|
||||||
|
|
||||||
|
$(".toolbars .ico-stop").removeClass("ico-stop")
|
||||||
|
.addClass("ico-buildrun").attr("title", config.label.build_n_run);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 触发一次 gutter lint
|
||||||
|
CodeMirror.signal(wide.curEditor, "change", wide.curEditor);
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
outputWS.onclose = function (e) {
|
outputWS.onclose = function (e) {
|
||||||
|
@ -449,7 +461,7 @@ var wide = {
|
||||||
if ($(".menu li.save-all").hasClass("disabled")) {
|
if ($(".menu li.save-all").hasClass("disabled")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: 只保存未保存过的文件
|
// TODO: 只保存未保存过的文件
|
||||||
|
|
||||||
for (var i = 0, ii = editors.data.length; i < ii; i++) {
|
for (var i = 0, ii = editors.data.length; i < ii; i++) {
|
||||||
|
@ -516,7 +528,7 @@ var wide = {
|
||||||
// 构建.
|
// 构建.
|
||||||
build: function () {
|
build: function () {
|
||||||
wide.saveAllFiles();
|
wide.saveAllFiles();
|
||||||
|
|
||||||
var currentPath = editors.getCurrentPath();
|
var currentPath = editors.getCurrentPath();
|
||||||
if (!currentPath) {
|
if (!currentPath) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -542,7 +554,7 @@ var wide = {
|
||||||
// 构建并运行.
|
// 构建并运行.
|
||||||
run: function () {
|
run: function () {
|
||||||
wide.saveAllFiles();
|
wide.saveAllFiles();
|
||||||
|
|
||||||
var currentPath = editors.getCurrentPath();
|
var currentPath = editors.getCurrentPath();
|
||||||
if (!currentPath) {
|
if (!currentPath) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -603,7 +615,7 @@ var wide = {
|
||||||
},
|
},
|
||||||
goinstall: function () {
|
goinstall: function () {
|
||||||
wide.saveAllFiles();
|
wide.saveAllFiles();
|
||||||
|
|
||||||
var currentPath = editors.getCurrentPath();
|
var currentPath = editors.getCurrentPath();
|
||||||
if (!currentPath) {
|
if (!currentPath) {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue