diff --git a/static/js/components/app-main/index.js b/static/js/components/app-main/index.js index 3eb408a..e64e42e 100644 --- a/static/js/components/app-main/index.js +++ b/static/js/components/app-main/index.js @@ -194,8 +194,19 @@ module.exports = Vue.component('app-main', { }, false); var step = 0; + var timestamp = Date.now(); ipc.on('emulator', function (event, type, project, data){ + var now = Date.now(); + + if (now - timestamp > 1000) { + step = 0; + } + + timestamp = now; + + step++; + var delay = step * 16; var runtime = window.AppRuntime[project.name]; @@ -203,20 +214,17 @@ module.exports = Vue.component('app-main', { switch (type) { case 'data': data += ''; - step++; break; case 'error': data = '执行出现错误: ' + data; - step = 0; break; case 'close': data = '\u001b[32m命令执行完毕\u001b[39m\r\n'; - step = 0; break; } setTimeout(function (){ - runtime.xterm.write(data + ''); + runtime.xterm.write(data); scroll(runtime.xterm); }, delay); } else {