Compare commits

...

5 Commits

Author SHA1 Message Date
46d308ce35 fix bug
Some checks failed
backend / cross (aarch64) (push) Failing after 18m22s
backend / cross (arm) (push) Failing after 31s
backend / cross (i686) (push) Failing after 31s
backend / cross (mips64) (push) Failing after 31s
backend / cross (mips64el) (push) Failing after 31s
backend / cross (armhf) (push) Failing after 1m31s
backend / cross (mips) (push) Failing after 31s
backend / cross (mipsel) (push) Failing after 14m31s
backend / cross (s390x) (push) Failing after 40m18s
backend / cross (win32) (push) Failing after 26m5s
backend / cross (x86_64) (push) Failing after 34m16s
docker / build (push) Failing after 5m50s
2025-10-22 11:59:58 +08:00
7cd85a3315 add postAttachCommand feature
Some checks are pending
docker / build (push) Waiting to run
2025-10-19 01:13:49 +08:00
fd338d2dad show differences
Some checks failed
backend / cross (aarch64) (push) Waiting to run
backend / cross (arm) (push) Waiting to run
backend / cross (armhf) (push) Waiting to run
backend / cross (i686) (push) Waiting to run
backend / cross (mips) (push) Waiting to run
backend / cross (mips64) (push) Waiting to run
backend / cross (mips64el) (push) Waiting to run
backend / cross (mipsel) (push) Waiting to run
backend / cross (s390x) (push) Waiting to run
backend / cross (win32) (push) Waiting to run
backend / cross (x86_64) (push) Waiting to run
frontend / build (push) Waiting to run
docker / build (push) Has been cancelled
2025-10-18 16:35:39 +08:00
6dbe2f6e20 Show differences
Some checks failed
backend / cross (aarch64) (push) Has been cancelled
backend / cross (arm) (push) Has been cancelled
backend / cross (armhf) (push) Has been cancelled
backend / cross (i686) (push) Has been cancelled
backend / cross (mips) (push) Has been cancelled
backend / cross (mips64) (push) Has been cancelled
backend / cross (mips64el) (push) Has been cancelled
backend / cross (mipsel) (push) Has been cancelled
backend / cross (s390x) (push) Has been cancelled
backend / cross (win32) (push) Has been cancelled
backend / cross (x86_64) (push) Has been cancelled
docker / build (push) Has been cancelled
frontend / build (push) Has been cancelled
2025-10-18 16:33:31 +08:00
36d23c3d74 add log
Some checks failed
backend / cross (mips64el) (push) Has been cancelled
backend / cross (mipsel) (push) Has been cancelled
backend / cross (s390x) (push) Has been cancelled
backend / cross (win32) (push) Has been cancelled
backend / cross (x86_64) (push) Has been cancelled
backend / cross (aarch64) (push) Has been cancelled
backend / cross (arm) (push) Has been cancelled
backend / cross (armhf) (push) Has been cancelled
backend / cross (i686) (push) Has been cancelled
backend / cross (mips) (push) Has been cancelled
backend / cross (mips64) (push) Has been cancelled
docker / build (push) Has been cancelled
2025-10-18 13:18:15 +08:00
3 changed files with 14186 additions and 14168 deletions

View File

@@ -104,9 +104,10 @@ export class Xterm {
private intervalID: NodeJS.Timeout;
private writeFunc = (data: ArrayBuffer) => this.writeData(new Uint8Array(data));
private status = false;
private titleStatus = false;
private checkStatus = false;
private connectStatus = false;
private hostTitle = "";
private postAttachCommand = [];
private postAttachCommandStatus = false;
private workdir = "";
private beforeCommand?: string;
constructor(
private options: XtermOptions,
@@ -352,26 +353,17 @@ export class Xterm {
)
.then(response => response.json())
.then(data => {
if (this.workdir === ''){
this.workdir = data.workdir;
}
if (data.status !== '4' && data.status !== '0') {
this.sendData(data.command);
} else {
clearInterval(this.intervalID);
if (data.status === '4') {
fetch(
'http://' + options.get('domain') + ':'+ options.get('port') +'/' +
options.get('user') +
'/' +
options.get('repo') +
'/devcontainer/command?' +
params
)
.then(response => response.json())
.then(data => {
this.sendData(data.command);
})
.catch(error => {
console.error('Error:', error);
});
const parts = data.command.split('\n');
this.sendData(parts[0]+"\n");
this.postAttachCommand = parts;
}
}
})
@@ -423,42 +415,65 @@ export class Xterm {
switch (cmd) {
case Command.OUTPUT:
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 === ""){
this.hostTitle = textDecoder.decode(data).replace(/\s/g, '');
}
// 检测是否退出devcontainer标题等于host的标题
if (this.status && textDecoder.decode(data).replace(/\s/g, '').includes(this.hostTitle)){
this.status = false
}
// this.status = true 连接完成
if (
this.status === false &&
textDecoder.decode(data).replace(/\s/g, '').includes('Successfully connected to the container'.replace(/\s/g, ''))
textDecoder.decode(data).replace(/\s/g, '').includes('Successfully connected to the devcontainer'.replace(/\s/g, ''))
) {
if(this.connectStatus == true){
this.status = true;
}
this.connectStatus = true;
}
if (this.checkStatus) {
if (textDecoder.decode(data).replace(/\s/g, '').includes('You have out the container. Please refresh the terminal to reconnect.'.replace(/\s/g, ''))) {
this.checkStatus = false;
this.status = false;
this.connectStatus = false;
}
if(textDecoder.decode(data).includes('\x1b')){
this.checkStatus = false;
}
}
if (this.titleStatus && textDecoder.decode(data).includes('\x1b')) {
this.titleStatus = false;
this.checkStatus = true;
this.sendData(
`echo $WEB_TERMINAL\n`
);
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.titleStatus !== true &&
this.checkStatus !== true
!(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 (textDecoder.decode(data).replace(/\s/g, '').includes('exit')) {
this.titleStatus = true;
if (this.status && textDecoder.decode(data).replace(/\s/g, '').includes(this.workdir) && !this.postAttachCommandStatus){
for (let i = 1; i < this.postAttachCommand.length; i++){
this.sendData(this.postAttachCommand[i]+"\n");
}
this.postAttachCommandStatus = true;
}
} else {

2
package-lock.json generated
View File

@@ -1,5 +1,5 @@
{
"name": "ttyd",
"name": "webTerminal",
"lockfileVersion": 3,
"requires": true,
"packages": {}

28247
src/html.h generated

File diff suppressed because it is too large Load Diff