Commit 4cdd5450338050f49cdc70efdf5481ec70d92d1a
1 parent
6e5f7a7d
修改多文件编译字段修改
Showing
2 changed files
with
48 additions
and
52 deletions
src/index.html
| @@ -20,7 +20,7 @@ | @@ -20,7 +20,7 @@ | ||
| 20 | 20 | ||
| 21 | <script> | 21 | <script> |
| 22 | // var gxb_api = "https://restful1.gaoxiaobang.com"; | 22 | // var gxb_api = "https://restful1.gaoxiaobang.com"; |
| 23 | - var gxb_api = "http://192.168.80.140:8080" | 23 | + var gxb_api = "http://192.168.80.223:8080" |
| 24 | 24 | ||
| 25 | </script> | 25 | </script> |
| 26 | 26 |
src/js/gb.js
| @@ -751,13 +751,14 @@ $(function() { | @@ -751,13 +751,14 @@ $(function() { | ||
| 751 | 751 | ||
| 752 | // 播放录制代码过程 | 752 | // 播放录制代码过程 |
| 753 | $('.audio-play').unbind('click').click(function() { | 753 | $('.audio-play').unbind('click').click(function() { |
| 754 | - alert(1) | 754 | + // alert(1) |
| 755 | var resultData = { | 755 | var resultData = { |
| 756 | - output: '', | ||
| 757 | - stderr: '', | ||
| 758 | - cmpinfo: '', | ||
| 759 | - result: 1 | ||
| 760 | - } | 756 | + status: 200, |
| 757 | + compilerInfo: '', | ||
| 758 | + content: '', | ||
| 759 | + error: '', | ||
| 760 | + code: '' | ||
| 761 | + }; | ||
| 761 | GBCodePlayBack.resetCodeMirrorValue(); | 762 | GBCodePlayBack.resetCodeMirrorValue(); |
| 762 | compileResult(resultData); | 763 | compileResult(resultData); |
| 763 | var data = $(this).attr('data'); | 764 | var data = $(this).attr('data'); |
| @@ -1145,7 +1146,7 @@ $(function() { | @@ -1145,7 +1146,7 @@ $(function() { | ||
| 1145 | 1146 | ||
| 1146 | $.ajax({ | 1147 | $.ajax({ |
| 1147 | type: "post", | 1148 | type: "post", |
| 1148 | - url: "http://192.168.80.140:8080/gxb-web/programmingMulti/api", | 1149 | + url: gxb_api + "/gxb-web/programmingMulti/api", |
| 1149 | data: JSON.stringify(postData), | 1150 | data: JSON.stringify(postData), |
| 1150 | dataType: "json", | 1151 | dataType: "json", |
| 1151 | contentType: "application/json", | 1152 | contentType: "application/json", |
| @@ -1661,11 +1662,12 @@ $(function() { | @@ -1661,11 +1662,12 @@ $(function() { | ||
| 1661 | GBCodePlayBack.codeTimes = 1; // | 1662 | GBCodePlayBack.codeTimes = 1; // |
| 1662 | 1663 | ||
| 1663 | var resultData = { | 1664 | var resultData = { |
| 1664 | - output: record.output || '', | ||
| 1665 | - stderr: record.stderr || '', | ||
| 1666 | - cmpinfo: record.cmpinfo || '', | ||
| 1667 | - result: record.result | ||
| 1668 | - } | 1665 | + status: record.status || 200, |
| 1666 | + compilerInfo: record.compilerInfo || '', | ||
| 1667 | + content: record.content || '', | ||
| 1668 | + error: record.error || '', | ||
| 1669 | + code: record.code || '' | ||
| 1670 | + }; | ||
| 1669 | 1671 | ||
| 1670 | if (resultData.cmpinfo || resultData.result == 1) { | 1672 | if (resultData.cmpinfo || resultData.result == 1) { |
| 1671 | compileResult(resultData); | 1673 | compileResult(resultData); |
| @@ -1797,6 +1799,7 @@ $(function() { | @@ -1797,6 +1799,7 @@ $(function() { | ||
| 1797 | } | 1799 | } |
| 1798 | 1800 | ||
| 1799 | $('.record-before').hide(); | 1801 | $('.record-before').hide(); |
| 1802 | + | ||
| 1800 | // 动态获取目录结构 | 1803 | // 动态获取目录结构 |
| 1801 | $.ajax({ | 1804 | $.ajax({ |
| 1802 | type: "GET", | 1805 | type: "GET", |
| @@ -1804,7 +1807,7 @@ $(function() { | @@ -1804,7 +1807,7 @@ $(function() { | ||
| 1804 | dataType: "json", | 1807 | dataType: "json", |
| 1805 | contentType: "application/json", | 1808 | contentType: "application/json", |
| 1806 | success: function(res) { | 1809 | success: function(res) { |
| 1807 | - console.info("Ajax tree.json success"); | 1810 | + console.info(); |
| 1808 | treeData = res.tree; | 1811 | treeData = res.tree; |
| 1809 | 1812 | ||
| 1810 | treeObj = $.fn.zTree.init($("#folder"), ZTREE.config, treeData); | 1813 | treeObj = $.fn.zTree.init($("#folder"), ZTREE.config, treeData); |
| @@ -1830,10 +1833,11 @@ $(function() { | @@ -1830,10 +1833,11 @@ $(function() { | ||
| 1830 | $("#countdown").show(); | 1833 | $("#countdown").show(); |
| 1831 | 1834 | ||
| 1832 | var resultData = { | 1835 | var resultData = { |
| 1833 | - output: '', | ||
| 1834 | - stderr: '', | ||
| 1835 | - cmpinfo: '', | ||
| 1836 | - result: 1 | 1836 | + status: 200, |
| 1837 | + compilerInfo: '', | ||
| 1838 | + content: '', | ||
| 1839 | + error: '', | ||
| 1840 | + code: '' | ||
| 1837 | }; | 1841 | }; |
| 1838 | runResult() | 1842 | runResult() |
| 1839 | 1843 | ||
| @@ -2095,44 +2099,35 @@ $(function() { | @@ -2095,44 +2099,35 @@ $(function() { | ||
| 2095 | $('#upload').removeClass('recording-finish').addClass('upload-teach').attr("disabled", true); | 2099 | $('#upload').removeClass('recording-finish').addClass('upload-teach').attr("disabled", true); |
| 2096 | GBCodePlayBack.htmleditor.setValue(''); | 2100 | GBCodePlayBack.htmleditor.setValue(''); |
| 2097 | var resultData = { | 2101 | var resultData = { |
| 2098 | - output: '', | ||
| 2099 | - stderr: '', | ||
| 2100 | - cmpinfo: '', | ||
| 2101 | - result: 1 | 2102 | + status: 200, |
| 2103 | + content: '', | ||
| 2104 | + error: '', | ||
| 2105 | + code: '' | ||
| 2102 | }; | 2106 | }; |
| 2103 | compileResult(resultData); | 2107 | compileResult(resultData); |
| 2104 | } | 2108 | } |
| 2105 | 2109 | ||
| 2106 | // 编译结果 | 2110 | // 编译结果 |
| 2107 | function compileResult(data) { | 2111 | function compileResult(data) { |
| 2108 | - if (data.result) { | ||
| 2109 | - | ||
| 2110 | - $('#cmpinfo').html('<p class="text-warning">' + data.cmpinfo.replace(/\n/g, "<br />") + "</p>"); | ||
| 2111 | - $('#stderr').html('<p class="text-danger">' + data.stderr.replace(/\n/g, "<br />") + "</p>"); | ||
| 2112 | - $('#output').html('<p class="text-success">' + data.output.replace(/\n/g, "<br />") + "</p>"); | ||
| 2113 | - | ||
| 2114 | - if (data.cmpinfo.length) { | ||
| 2115 | - $('#cmprun-tabs a[href="#cmpinfo"]').tab('show'); | ||
| 2116 | - } else if (data.stderr.length) { | ||
| 2117 | - $('#cmprun-tabs a[href="#stderr"]').tab('show'); | ||
| 2118 | - } else if (data.output.length) { | 2112 | + if (data.status == 200) { |
| 2113 | + if (data.code == 0) { | ||
| 2114 | + $('#output').html('<p class="text-success">' + data.content.replace(/\n/g, "<br />") + "</p>"); | ||
| 2115 | + $('#cmpinfo').prepend('<p class="alert alert-success"><i class="glyphicon glyphicon-ok-sign"></i> 编译成功 </p>'); | ||
| 2119 | $('#cmprun-tabs a[href="#output"]').tab('show'); | 2116 | $('#cmprun-tabs a[href="#output"]').tab('show'); |
| 2117 | + } else if (data.code == 1) { | ||
| 2118 | + if (data.error.length) { | ||
| 2119 | + $('#cmpinfo').html('<p class="text-warning">' + data.error.replace(/\n/g, "<br />") + "</p>"); | ||
| 2120 | + }else if (data.compilerInfo.length){ | ||
| 2121 | + $('#cmpinfo').html('<p class="text-warning">' + data.compilerInfo.replace(/\n/g, "<br />") + "</p>"); | ||
| 2122 | + }else{ | ||
| 2123 | + $('#cmpinfo').html('<p class="alert alert-danger"><i class="glyphicon glyphicon-exclamation-sign"></i> 编译超时,请重新编译 </p>'); | ||
| 2124 | + } | ||
| 2125 | + $('#cmprun-tabs a[href="#cmpinfo"]').tab('show'); | ||
| 2126 | + }else{ | ||
| 2127 | + $('#cmpinfo').prepend('<p class="alert alert-success"><i class="glyphicon glyphicon-ok-sign"></i> 等待编译 </p>'); | ||
| 2120 | } | 2128 | } |
| 2121 | - | ||
| 2122 | - if (!data.cmpinfo.length) { | ||
| 2123 | - $('#cmpinfo').prepend('<p class="alert alert-success"><i class="glyphicon glyphicon-ok-sign"></i> 编译已成功</p>'); | ||
| 2124 | - } | ||
| 2125 | - | ||
| 2126 | - if (!data.stderr.length) { | ||
| 2127 | - $('#stderr').prepend('<p class="alert alert-success"><i class="glyphicon glyphicon-ok-sign"></i> 无输出错误</p>'); | ||
| 2128 | - } | ||
| 2129 | - | ||
| 2130 | - if (!data.output.length) { | ||
| 2131 | - $('#output').prepend('<p class="alert alert-warning"><i class="glyphicon glyphicon-exclamation-sign"></i> 代码编译错误或者运行相关功能受限制</p>'); | ||
| 2132 | - } | ||
| 2133 | - | ||
| 2134 | - } else { | ||
| 2135 | - $('#cmpinfo').html('<p class="alert alert-danger"><i class="glyphicon glyphicon-exclamation-sign"></i> 云端编译超时,请稍后重新尝试</p>'); | 2129 | + }else{ |
| 2130 | + $('#cmpinfo').html('<p class="alert alert-danger"><i class="glyphicon glyphicon-exclamation-sign"></i> 请求失败 </p>'); | ||
| 2136 | $('#cmprun-tabs a[href="#cmpinfo"]').tab('show'); | 2131 | $('#cmprun-tabs a[href="#cmpinfo"]').tab('show'); |
| 2137 | } | 2132 | } |
| 2138 | } | 2133 | } |
| @@ -2324,10 +2319,11 @@ $(function() { | @@ -2324,10 +2319,11 @@ $(function() { | ||
| 2324 | }else{ | 2319 | }else{ |
| 2325 | GBCodePlayBack.htmlplayereditor.setValue('') | 2320 | GBCodePlayBack.htmlplayereditor.setValue('') |
| 2326 | var resultData = { | 2321 | var resultData = { |
| 2327 | - output: '', | ||
| 2328 | - stderr: '', | ||
| 2329 | - cmpinfo: '', | ||
| 2330 | - result: 1 | 2322 | + status: 200, |
| 2323 | + compilerInfo: '', | ||
| 2324 | + content: '', | ||
| 2325 | + error: '', | ||
| 2326 | + code: '' | ||
| 2331 | }; | 2327 | }; |
| 2332 | compileResult(resultData); | 2328 | compileResult(resultData); |
| 2333 | } | 2329 | } |