From 93ce123ab68e2e4c5e25f7652e684970f520975d Mon Sep 17 00:00:00 2001 From: NanamiAdmin Date: Mon, 6 Apr 2026 10:41:30 +0800 Subject: [PATCH] fix(instance-detail): reset logs and reconnect websocket on instance state change Ensure logs are cleared and websocket connection is refreshed when starting, stopping or restarting an instance to maintain accurate log display --- src/views/InstanceDetail.vue | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/views/InstanceDetail.vue b/src/views/InstanceDetail.vue index c84e0e3..10c7acb 100644 --- a/src/views/InstanceDetail.vue +++ b/src/views/InstanceDetail.vue @@ -368,6 +368,10 @@ export default { await instanceApi.startInstance(instanceID.value); showNotification('Instance started successfully', 'success'); await loadInstanceInfo(); + // Clear logs && reconnect to websocket + logs.value = []; + disconnectLogWebSocket(); + connectLogWebSocket(); } catch (error) { showNotification(error.message || 'Start instance failed', 'error'); } @@ -378,6 +382,10 @@ export default { await instanceApi.stopInstance(instanceID.value); showNotification('Instance stopped successfully', 'success'); await loadInstanceInfo(); + // Clear logs && reconnect to websocket + logs.value = []; + disconnectLogWebSocket(); + connectLogWebSocket(); } catch (error) { showNotification(error.message || 'Stop instance failed', 'error'); } @@ -398,6 +406,10 @@ export default { await instanceApi.restartInstance(instanceID.value); showNotification('Instance restarted successfully', 'success'); await loadInstanceInfo(); + // Clear logs && reconnect to websocket + logs.value = []; + disconnectLogWebSocket(); + connectLogWebSocket(); } catch (error) { showNotification(error.message || 'Restart instance failed', 'error'); }