mirror of
https://github.com/nuintun/command-manager.git
synced 2025-06-07 19:44:35 +08:00
update files
This commit is contained in:
parent
f34adf9270
commit
b3176ef2e9
@ -49,16 +49,12 @@ function scroll(xterm, parent){
|
||||
|
||||
var worker = new Worker('static/js/components/app-main/terminal-worker.js');
|
||||
|
||||
worker.onmessage = function (){
|
||||
console.log(arguments);
|
||||
};
|
||||
|
||||
/**
|
||||
* openXTerm
|
||||
* @param name
|
||||
*/
|
||||
function openXTerm(name){
|
||||
worker.postMessage({ atcion: 'open', name: name });
|
||||
worker.postMessage({ action: 'open', name: name });
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,7 +62,7 @@ function openXTerm(name){
|
||||
* @param name
|
||||
*/
|
||||
function closeXTerm(name){
|
||||
worker.postMessage({ atcion: 'close', name: name });
|
||||
worker.postMessage({ action: 'close', name: name });
|
||||
}
|
||||
|
||||
module.exports = Vue.component('app-main', {
|
||||
@ -166,21 +162,21 @@ module.exports = Vue.component('app-main', {
|
||||
}, false);
|
||||
|
||||
ipc.on('emulator', function (event, type, project, data){
|
||||
var runtime = window.AppRuntime[project.name];
|
||||
|
||||
if (runtime) {
|
||||
worker.postMessage({ action: 'write', name: project.name, data: data + '' });
|
||||
|
||||
worker.postMessage({ atcion: 'write', name: project.name, data: data + '' });
|
||||
|
||||
if (project.name === context.project.name) {
|
||||
|
||||
}
|
||||
} else {
|
||||
event.sender.send('emulator', project, 'stop');
|
||||
}
|
||||
// event.sender.send('emulator', project, 'stop');
|
||||
});
|
||||
},
|
||||
ready: function (){
|
||||
var context = this;
|
||||
|
||||
worker.onmessage = function (event){
|
||||
if (event.data.name === context.project.name) {
|
||||
context.$els.terminal.innerHTML = event.data.screen;
|
||||
}
|
||||
};
|
||||
|
||||
openXTerm(this.project.name);
|
||||
}
|
||||
});
|
@ -6,8 +6,32 @@
|
||||
|
||||
importScripts('../../terminal/index.js');
|
||||
|
||||
var RUNCACHE = {};
|
||||
var RUNTIMECACHE = {};
|
||||
|
||||
function send(name, xterm){
|
||||
postMessage({
|
||||
name: name,
|
||||
screen: xterm.toString('html')
|
||||
});
|
||||
}
|
||||
|
||||
onmessage = function (event){
|
||||
console.log(event.data);
|
||||
var message = event.data;
|
||||
|
||||
switch (message.action) {
|
||||
case 'open':
|
||||
RUNTIMECACHE[message.name] = RUNTIMECACHE[message.name] || new AnsiTerminal(120, 60, 60);
|
||||
send(message.name, RUNTIMECACHE[message.name]);
|
||||
break;
|
||||
case 'close':
|
||||
delete RUNTIMECACHE[message.name];
|
||||
break;
|
||||
case 'write':
|
||||
var xterm = RUNTIMECACHE[message.name];
|
||||
|
||||
xterm.write(message.data);
|
||||
|
||||
send(message.name, xterm);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user