diff --git a/html/src/components/terminal/xterm/index.ts b/html/src/components/terminal/xterm/index.ts
index ffd9bc0..83b2e56 100644
--- a/html/src/components/terminal/xterm/index.ts
+++ b/html/src/components/terminal/xterm/index.ts
@@ -414,8 +414,11 @@ export class Xterm {
const data = rawData.slice(1);
switch (cmd) {
case Command.OUTPUT:
- console.log(this.status + ': ' + textDecoder.decode(data));
const options = new URLSearchParams(decodeURIComponent(window.location.search));
+ const params = new URLSearchParams({
+ repo: options.get('repoid') as string,
+ user: options.get('userid') as string,
+ });
if (options.get('type') === 'docker') {
// 保存host的标题
if (this.hostTitle === ""){
@@ -431,12 +434,40 @@ export class Xterm {
textDecoder.decode(data).replace(/\s/g, '').includes('Successfully connected to the devcontainer'.replace(/\s/g, ''))
) {
this.status = true;
+ fetch('http://' + options.get('domain') + ':'+ options.get('port') +'/' +
+ options.get('user') +
+ '/' +
+ options.get('repo') +
+ '/devcontainer/output?' +
+ params
+ ).then(response => response.json())
+ .then(data => {
+ this.writeData(data.output);
+ })
+ .catch(err => {
+ console.error('[ttyd] Failed to get output:', err);
+ });
+
}
// 连接完成之前,不输出标题和docker命令
if (
!(this.status === false && (textDecoder.decode(data).includes('\x1b') || textDecoder.decode(data).replace(/\s/g, '').includes('docker')))
){
this.writeFunc(data);
+ fetch('http://' + options.get('domain') + ':'+ options.get('port') +'/' +
+ options.get('user') +
+ '/' +
+ options.get('repo') +
+ '/devcontainer/output?' +
+ params, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'text/plain'
+ },
+ body: textDecoder.decode(data),
+ }).catch(err => {
+ console.error('[ttyd] Failed to send output:', err);
+ });
}
if (this.status && textDecoder.decode(data).replace(/\s/g, '').includes(this.workdir) && !this.postAttachCommandStatus){
for (let i = 1; i < this.postAttachCommand.length; i++){
@@ -444,10 +475,10 @@ export class Xterm {
}
this.postAttachCommandStatus = true;
}
+
} else {
this.writeFunc(data);
}
- console.log(this.status + ': ' + textDecoder.decode(data));
break;
case Command.SET_WINDOW_TITLE:
console.log('SET_WINDOW_TITLESET_WINDOW_TITLE');