This commit is contained in:
Van 2014-10-22 17:31:33 +08:00
commit a094e36fe6
3 changed files with 33 additions and 3 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
/wide.exe /wide.exe
/wide /wide
/main
/data/workspace/bin/ /data/workspace/bin/
/data/workspace/pkg/ /data/workspace/pkg/

View File

@ -115,7 +115,7 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
glog.V(3).Infof("Session [%s] is running [id=%d, file=%s]", sid, runningId, filePath) glog.V(3).Infof("Session [%s] is running [id=%d, file=%s]", sid, runningId, filePath)
// 在读取程序输出前先返回一次,使前端获取到 run 状态以及对应的 pid // 在读取程序输出前先返回一次,使前端获取到 run 状态 pid
if nil != session.OutputWS[sid] { if nil != session.OutputWS[sid] {
wsChannel := session.OutputWS[sid] wsChannel := session.OutputWS[sid]
@ -289,7 +289,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
if 0 == count { // 说明构建成功,没有错误信息输出 if 0 == count { // 说明构建成功,没有错误信息输出
// 设置下一次执行命令(前端会根据这个发送请求) // 设置下一次执行命令(前端会根据这个发送请求)
channelRet["nextCmd"] = "run" channelRet["nextCmd"] = args["nextCmd"]
go func() { // 运行 go install生成的库用于 gocode lib-path go func() { // 运行 go install生成的库用于 gocode lib-path
cmd := exec.Command("go", "install") cmd := exec.Command("go", "install")

View File

@ -442,6 +442,8 @@ var wide = {
if ($(".menu li.save-all").hasClass("disabled")) { if ($(".menu li.save-all").hasClass("disabled")) {
return false; return false;
} }
// TODO: 只保存未保存过的文件
for (var i = 0, ii = editors.data.length; i < ii; i++) { for (var i = 0, ii = editors.data.length; i < ii; i++) {
this.fmt(tree.fileTree.getNodeByTId(editors.data[i].id).path, editors.data[i].editor); this.fmt(tree.fileTree.getNodeByTId(editors.data[i].id).path, editors.data[i].editor);
@ -506,10 +508,34 @@ var wide = {
}, },
// 构建. // 构建.
build: function () { build: function () {
// TODO: 构建 wide.saveAllFiles();
var currentPath = editors.getCurrentPath();
if (!currentPath) {
return false;
}
var request = newWideRequest();
request.file = currentPath;
request.code = wide.curEditor.getValue();
request.nextCmd = ""; // 只构建,无下一步操作
$.ajax({
type: 'POST',
url: '/build',
data: JSON.stringify(request),
dataType: "json",
beforeSend: function (data) {
$('.bottom-window-group .output').text('');
},
success: function (data) {
}
});
}, },
// 构建并运行. // 构建并运行.
run: function () { run: function () {
wide.saveAllFiles();
var currentPath = editors.getCurrentPath(); var currentPath = editors.getCurrentPath();
if (!currentPath) { if (!currentPath) {
return false; return false;
@ -527,6 +553,7 @@ var wide = {
var request = newWideRequest(); var request = newWideRequest();
request.file = currentPath; request.file = currentPath;
request.code = wide.curEditor.getValue(); request.code = wide.curEditor.getValue();
request.nextCmd = "run";
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
@ -568,6 +595,8 @@ var wide = {
}); });
}, },
goinstall: function () { goinstall: function () {
wide.saveAllFiles();
var currentPath = editors.getCurrentPath(); var currentPath = editors.getCurrentPath();
if (!currentPath) { if (!currentPath) {
return false; return false;