fix bug
Some checks failed
backend / cross (i686) (push) Failing after 17m35s
backend / cross (win32) (push) Failing after 4m40s
backend / cross (mips) (push) Failing after 14m39s
backend / cross (x86_64) (push) Failing after 19m22s
backend / cross (mips64) (push) Failing after 6m38s
docker / build (push) Failing after 15m6s
backend / cross (aarch64) (push) Failing after 16m29s
backend / cross (mips64el) (push) Failing after 14m16s
backend / cross (arm) (push) Failing after 6m33s
backend / cross (mipsel) (push) Failing after 9m27s
backend / cross (armhf) (push) Failing after 13m14s
backend / cross (s390x) (push) Failing after 1m32s
Some checks failed
backend / cross (i686) (push) Failing after 17m35s
backend / cross (win32) (push) Failing after 4m40s
backend / cross (mips) (push) Failing after 14m39s
backend / cross (x86_64) (push) Failing after 19m22s
backend / cross (mips64) (push) Failing after 6m38s
docker / build (push) Failing after 15m6s
backend / cross (aarch64) (push) Failing after 16m29s
backend / cross (mips64el) (push) Failing after 14m16s
backend / cross (arm) (push) Failing after 6m33s
backend / cross (mipsel) (push) Failing after 9m27s
backend / cross (armhf) (push) Failing after 13m14s
backend / cross (s390x) (push) Failing after 1m32s
This commit is contained in:
@@ -61,6 +61,7 @@ export class Terminal extends Component<Props, State> {
|
||||
if (data.status !== '-1') {
|
||||
if (options.get('type') === 'docker') {
|
||||
this.xterm.open(this.container);
|
||||
this.xterm.changeContainerStatus(data.status);
|
||||
this.xterm.connect();
|
||||
} else {
|
||||
this.intervalID = setInterval(this.loadOutput, 8000);
|
||||
|
||||
@@ -283,7 +283,11 @@ export class Xterm {
|
||||
register(addEventListener(socket, 'error', () => (this.doReconnect = false)));
|
||||
const options = new URLSearchParams(decodeURIComponent(window.location.search));
|
||||
if (options.get('type') === 'docker') {
|
||||
this.intervalID = setInterval(this.loadCommand, 8000);
|
||||
if(this.containerStatus === '4' || this.containerStatus === '-1'){
|
||||
this.intervalID = setInterval(this.loadCommand, 1000);
|
||||
}else{
|
||||
this.intervalID = setInterval(this.loadCommand, 8000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,21 +367,8 @@ export class Xterm {
|
||||
}
|
||||
this.containerStatus = data.status;
|
||||
} else {
|
||||
clearInterval(this.intervalID);
|
||||
this.containerStatus = data.status;
|
||||
if (data.status === '4') {
|
||||
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);
|
||||
});
|
||||
const parts = data.command.split('\n');
|
||||
this.sendData(parts[0]+"\n");
|
||||
this.postAttachCommand = parts;
|
||||
@@ -388,7 +379,10 @@ export class Xterm {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
}
|
||||
|
||||
@bind
|
||||
public changeContainerStatus(v: string){
|
||||
this.containerStatus = v;
|
||||
}
|
||||
@bind
|
||||
private parseOptsFromUrlQuery(query: string): Preferences {
|
||||
const { terminal } = this;
|
||||
@@ -431,6 +425,7 @@ export class Xterm {
|
||||
const data = rawData.slice(1);
|
||||
switch (cmd) {
|
||||
case Command.OUTPUT:
|
||||
console.log('[ttyd] output:', textDecoder.decode(data));
|
||||
const options = new URLSearchParams(decodeURIComponent(window.location.search));
|
||||
const params = new URLSearchParams({
|
||||
repo: options.get('repoid') as string,
|
||||
@@ -450,31 +445,16 @@ export class Xterm {
|
||||
this.connectStatus === false &&
|
||||
textDecoder.decode(data).replace(/\s/g, '').includes('Successfully connected to the devcontainer'.replace(/\s/g, ''))
|
||||
) {
|
||||
clearInterval(this.intervalID);
|
||||
this.connectStatus = true;
|
||||
}
|
||||
// 连接完成之前,不输出标题和docker命令
|
||||
if (
|
||||
!(this.connectStatus === false && (textDecoder.decode(data).includes('\x1b') || textDecoder.decode(data).replace(/\s/g, '').includes('docker')))
|
||||
!(this.connectStatus === false && (textDecoder.decode(data).includes('\x1b') || textDecoder.decode(data).replace(/\s/g, '').includes('docker-H')))
|
||||
){
|
||||
this.writeFunc(data);
|
||||
if(!this.connectStatus){
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
// 连接完成且出现容器的标题,且没有执行过postAttach命令
|
||||
if (this.connectStatus && 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");
|
||||
|
||||
Reference in New Issue
Block a user