From b7763bb800fc79d745df764538a466d069242d1d Mon Sep 17 00:00:00 2001 From: Nixevol Date: Mon, 12 Oct 2026 08:54:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9C=AC=E6=9C=BA=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E4=BF=A1=E4=BB=BB=E8=87=AA=E5=B7=B1=E4=B8=94=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E7=A7=BB=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- agent/internal/engine/engine.go | 7 +++++++ agent/internal/store/store.go | 13 +++++++++++++ ui/src/views/TrustView.vue | 7 ++++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/agent/internal/engine/engine.go b/agent/internal/engine/engine.go index 78e89b2..e807310 100644 --- a/agent/internal/engine/engine.go +++ b/agent/internal/engine/engine.go @@ -658,7 +658,11 @@ func (e *Engine) TrustAdd(id string) error { } func (e *Engine) TrustRemove(id string) error { + id = strings.TrimSpace(id) return e.st.Update(func(d *store.Data) error { + if id != "" && id == d.EndpointID { + return nil + } out := d.Trust[:0] for _, it := range d.Trust { if it == id { @@ -790,6 +794,9 @@ func checkDelivery(opt Delivery, lim Limits, now time.Time) error { } func trusted(d *store.Data, id string) bool { + if id != "" && id == d.EndpointID { + return true + } for _, it := range d.Trust { if it == id { return true diff --git a/agent/internal/store/store.go b/agent/internal/store/store.go index bff7eac..5904657 100644 --- a/agent/internal/store/store.go +++ b/agent/internal/store/store.go @@ -202,6 +202,19 @@ func (d *Data) normalize() { if d.Results == nil { d.Results = []CmdResult{} } + d.ensureSelf() +} + +func (d *Data) ensureSelf() { + if d.EndpointID == "" { + return + } + for _, it := range d.Trust { + if it == d.EndpointID { + return + } + } + d.Trust = append([]string{d.EndpointID}, d.Trust...) } func (s *Store) normalize() { diff --git a/ui/src/views/TrustView.vue b/ui/src/views/TrustView.vue index a46c524..2ed5476 100644 --- a/ui/src/views/TrustView.vue +++ b/ui/src/views/TrustView.vue @@ -8,9 +8,10 @@
请先启动被控。
还没有信任的设备。
- {{ store.nameOf(id) }} - {{ id }} - 移除 + {{ id === store.endpointId ? '本机' : store.nameOf(id) }} + {{ id }} + {{ id }} + 移除