diff --git a/sub/subController.go b/sub/subController.go index 0e9e2c97..a765ef06 100644 --- a/sub/subController.go +++ b/sub/subController.go @@ -138,6 +138,7 @@ func (a *SUBController) subs(c *gin.Context) { "host": page.Host, "base_path": page.BasePath, "sId": page.SId, + "enabled": page.Enabled, "download": page.Download, "upload": page.Upload, "total": page.Total, diff --git a/sub/subService.go b/sub/subService.go index d9fe0a6b..12d9bfb5 100644 --- a/sub/subService.go +++ b/sub/subService.go @@ -46,6 +46,7 @@ func (s *SubService) GetSubs(subId string, host string) ([]string, int64, xray.C var result []string var traffic xray.ClientTraffic var lastOnline int64 + var hasEnabledClient bool var clientTraffics []xray.ClientTraffic inbounds, err := s.getInboundsBySubId(subId) if err != nil { @@ -78,6 +79,9 @@ func (s *SubService) GetSubs(subId string, host string) ([]string, int64, xray.C } for _, client := range clients { if client.SubID == subId { + if client.Enable { + hasEnabledClient = true + } link := s.getLink(inbound, client.Email) result = append(result, link) ct := s.getClientTraffics(inbound.ClientStats, client.Email) @@ -111,6 +115,7 @@ func (s *SubService) GetSubs(subId string, host string) ([]string, int64, xray.C } } } + traffic.Enable = hasEnabledClient return result, lastOnline, traffic, nil } @@ -1304,6 +1309,7 @@ type PageData struct { Host string BasePath string SId string + Enabled bool Download string Upload string Total string @@ -1453,6 +1459,7 @@ func (s *SubService) BuildPageData(subId string, hostHeader string, traffic xray Host: hostHeader, BasePath: basePath, SId: subId, + Enabled: traffic.Enable, Download: download, Upload: upload, Total: total, diff --git a/web/assets/js/subscription.js b/web/assets/js/subscription.js index d08bfd28..aa09e1c4 100644 --- a/web/assets/js/subscription.js +++ b/web/assets/js/subscription.js @@ -7,6 +7,7 @@ const data = { sId: el.getAttribute('data-sid') || '', + enabled: (el.getAttribute('data-enabled') || '').toLowerCase() === 'true', subUrl: el.getAttribute('data-sub-url') || '', subJsonUrl: el.getAttribute('data-subjson-url') || '', subClashUrl: el.getAttribute('data-subclash-url') || '', @@ -128,9 +129,10 @@ }, isActive() { const now = Date.now(); + const enabledOk = this.app.enabled; const expiryOk = !this.app.expireMs || this.app.expireMs >= now; const trafficOk = !this.app.totalByte || (this.app.uploadByte + this.app.downloadByte) <= this.app.totalByte; - return expiryOk && trafficOk; + return enabledOk && expiryOk && trafficOk; }, shadowrocketUrl() { const rawUrl = this.app.subUrl + '?flag=shadowrocket'; diff --git a/web/html/settings/panel/subscription/subpage.html b/web/html/settings/panel/subscription/subpage.html index 48f0ecfb..adfbea93 100644 --- a/web/html/settings/panel/subscription/subpage.html +++ b/web/html/settings/panel/subscription/subpage.html @@ -153,7 +153,10 @@ app.sId ]] - + data-totalbyte="{{ .totalByte }}" data-datepicker="{{ .datepicker }}" data-enabled="{{ .enabled }}">