mirror of
https://github.com/tsl0922/ttyd.git
synced 2025-12-28 14:34:34 +01:00
html: add closeOnDisconnect option
This commit is contained in:
committed by
Shuanglei Tao
parent
4dad1315d8
commit
9c87671cca
@@ -16,6 +16,7 @@ const clientOptions = {
|
||||
enableZmodem: false,
|
||||
enableTrzsz: false,
|
||||
enableSixel: false,
|
||||
closeOnDisconnect: false,
|
||||
isWindows: false,
|
||||
unicodeVersion: '11',
|
||||
} as ClientOptions;
|
||||
|
||||
@@ -50,6 +50,7 @@ export interface ClientOptions {
|
||||
isWindows: boolean;
|
||||
trzszDragInitTimeout: number;
|
||||
unicodeVersion: string;
|
||||
closeOnDisconnect: boolean;
|
||||
}
|
||||
|
||||
export interface FlowControl {
|
||||
@@ -99,6 +100,7 @@ export class Xterm {
|
||||
private resizeOverlay = true;
|
||||
private reconnect = true;
|
||||
private doReconnect = true;
|
||||
private closeOnDisconnect = false;
|
||||
|
||||
private writeFunc = (data: ArrayBuffer) => this.writeData(new Uint8Array(data));
|
||||
|
||||
@@ -287,6 +289,8 @@ export class Xterm {
|
||||
if (event.code !== 1000 && doReconnect) {
|
||||
overlayAddon.showOverlay('Reconnecting...');
|
||||
refreshToken().then(connect);
|
||||
} else if (this.closeOnDisconnect) {
|
||||
window.close();
|
||||
} else {
|
||||
const { terminal } = this;
|
||||
const keyDispose = terminal.onKey(e => {
|
||||
@@ -419,6 +423,14 @@ export class Xterm {
|
||||
console.log('[ttyd] Sixel enabled');
|
||||
}
|
||||
break;
|
||||
case 'closeOnDisconnect':
|
||||
if (value) {
|
||||
console.log('[ttyd] close on disconnect enabled (Reconnect disabled)');
|
||||
this.closeOnDisconnect = true;
|
||||
this.reconnect = false;
|
||||
this.doReconnect = false;
|
||||
}
|
||||
break;
|
||||
case 'titleFixed':
|
||||
if (!value || value === '') return;
|
||||
console.log(`[ttyd] setting fixed title: ${value}`);
|
||||
|
||||
Reference in New Issue
Block a user