forked from mirror/MCSM-Daemon
Feat: 新增伪终端配置兼容性
This commit is contained in:
parent
9217024884
commit
646072f00e
@ -49,7 +49,7 @@ export default class InstanceConfig {
|
||||
|
||||
// terminal option
|
||||
public terminalOption = {
|
||||
haveColor: true,
|
||||
haveColor: false,
|
||||
pty: true,
|
||||
ptyWindowCol: 80,
|
||||
ptyWindowRow: 40
|
||||
|
@ -120,6 +120,12 @@ export default class Instance extends EventEmitter {
|
||||
configureEntityParams(this.config, cfg, "processType", String);
|
||||
this.forceExec(new FunctionDispatcher());
|
||||
}
|
||||
// 若终端类型改变,则必须重置预设命令
|
||||
if (cfg.terminalOption.pty != null && cfg.terminalOption.pty !== this.config.terminalOption.pty) {
|
||||
if (this.status() != Instance.STATUS_STOP) throw new Error("正在运行时无法修改PTY模式");
|
||||
configureEntityParams(this.config.terminalOption, cfg.terminalOption, "pty", Boolean);
|
||||
this.forceExec(new FunctionDispatcher());
|
||||
}
|
||||
configureEntityParams(this.config, cfg, "nickname", String);
|
||||
configureEntityParams(this.config, cfg, "startCommand", String);
|
||||
configureEntityParams(this.config, cfg, "stopCommand", String);
|
||||
@ -158,7 +164,7 @@ export default class Instance extends EventEmitter {
|
||||
}
|
||||
if (cfg.terminalOption) {
|
||||
configureEntityParams(this.config.terminalOption, cfg.terminalOption, "haveColor", Boolean);
|
||||
configureEntityParams(this.config.terminalOption, cfg.terminalOption, "pty", Boolean);
|
||||
|
||||
configureEntityParams(this.config.terminalOption, cfg.terminalOption, "ptyWindowCol", Number);
|
||||
configureEntityParams(this.config.terminalOption, cfg.terminalOption, "ptyWindowRow", Number);
|
||||
}
|
||||
|
@ -104,7 +104,8 @@ routerApp.on("stream/input", async (ctx, data) => {
|
||||
const instance = InstanceSubsystem.getInstance(instanceUuid);
|
||||
await instance.exec(new SendCommand(command));
|
||||
} catch (error) {
|
||||
protocol.responseError(ctx, error);
|
||||
// 忽略此处潜在的高频异常
|
||||
// protocol.responseError(ctx, error);
|
||||
}
|
||||
});
|
||||
|
||||
@ -118,7 +119,7 @@ routerApp.on("stream/write", async (ctx, data) => {
|
||||
if (instance.process) instance.process.write(buf);
|
||||
} catch (error) {
|
||||
// 忽略此处潜在的高频异常
|
||||
protocol.responseError(ctx, error);
|
||||
// protocol.responseError(ctx, error);
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user