Skip to content

Commit ec609bf

Browse files
author
dirkhe1051931999
committed
add:features
1 parent c3ee66e commit ec609bf

File tree

23 files changed

+1809
-16
lines changed

23 files changed

+1809
-16
lines changed

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,22 @@
3636
"quasar": "^2.6.0",
3737
"sass.js": "^0.11.1",
3838
"sha256": "^0.2.0",
39+
"shepherd.js": "^11.0.1",
3940
"ts-md5": "^1.2.7",
4041
"uuid": "^9.0.0",
4142
"vanilla-jsoneditor": "^0.9.2",
4243
"vue": "^3.2.29",
4344
"vue-facing-decorator": "^2.1.12",
4445
"vue-i18n": "^9.3.0-beta.6",
4546
"vue-router": "^4.1.6",
47+
"vue-shepherd": "^2.0.1",
4648
"vue3-count-to": "^1.1.2",
4749
"vue3-photo-preview": "^0.2.6",
4850
"vue3-side-panel": "^1.1.1",
49-
"vuex": "^4.0.1"
51+
"vuex": "^4.0.1",
52+
"xterm": "^5.1.0",
53+
"xterm-addon-attach": "^0.8.0",
54+
"xterm-addon-fit": "^0.7.0"
5055
},
5156
"devDependencies": {
5257
"@quasar/app-webpack": "^3.0.0",

service/index.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const pty = require('node-pty');
2+
const os = require('os');
3+
const WebSocket = require('ws');
4+
const shell = os.platform() === 'win32' ? 'powershell.exe' : 'bash';
5+
6+
const wss = new WebSocket.Server({ port: 4001 });
7+
8+
wss.on('connection', (ws) => {
9+
console.log('socket connection success');
10+
const ptyProcess = pty.spawn(shell, [], {
11+
name: 'xterm-color',
12+
cols: 180,
13+
rows: 124,
14+
cwd: process.env.HOME,
15+
env: process.env,
16+
});
17+
//接受数据
18+
ws.on('message', (res) => {
19+
ptyProcess.write(res);
20+
});
21+
//发送数据
22+
ptyProcess.on('data', function (data) {
23+
process.stdout.write(data);
24+
ws.send(data);
25+
});
26+
});

service/package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "service",
3+
"version": "1.0.0",
4+
"description": "nodejs service",
5+
"main": "index.js",
6+
"scripts": {
7+
"start": "nodemon index.js",
8+
"test": "echo \"Error: no test specified\" && exit 1"
9+
},
10+
"author": "dirkhe1051931999",
11+
"license": "ISC",
12+
"dependencies": {
13+
"express": "^4.18.2",
14+
"node-pty": "^0.10.1",
15+
"ws": "^8.13.0"
16+
}
17+
}

0 commit comments

Comments
 (0)