From 9e97e9a5503b8f2ae057027e5c52e12a5cc5a5b4 Mon Sep 17 00:00:00 2001 From: Suwings Date: Sun, 17 Jul 2022 13:03:36 +0800 Subject: [PATCH] =?UTF-8?q?Refactor:=20=E9=87=8D=E6=9E=84=E5=AE=9E?= =?UTF-8?q?=E4=BE=8B=E6=9B=B4=E6=96=B0=E8=AF=B7=E6=B1=82=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/routers/protected/user_instance_router.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/app/routers/protected/user_instance_router.ts b/src/app/routers/protected/user_instance_router.ts index c75ec0dc..3d4bfd3f 100644 --- a/src/app/routers/protected/user_instance_router.ts +++ b/src/app/routers/protected/user_instance_router.ts @@ -353,16 +353,19 @@ router.put( // 可选参数 const crlf = Number(config?.crlf); - const oe = String(config?.oe || ""); - const ie = String(config?.ie || ""); + const oe = config?.oe ? String(config?.oe) : null; + const ie = config?.ie ? String(config?.ie) : null; const remoteService = RemoteServiceSubsystem.getInstance(serviceUuid); + + // 松散性参数传递,每个配置都可以传递或不传递 + // 其子对象配置一定要完整或者一个都没有 const result = await new RemoteRequest(remoteService).request("instance/update", { instanceUuid, config: { - pingConfig: pingConfig.ip != null ? pingConfig : null, - eventTask: eventTask.autoStart != null ? eventTask : null, - terminalOption, + pingConfig: config.pingConfig?.ip != null ? pingConfig : null, + eventTask: config.eventTask?.autoStart != null ? eventTask : null, + terminalOption: config.terminalOption?.pty != null ? terminalOption : null, crlf, oe, ie