From 32b7ada54915adc7b6f93e9fef5e468e2fe66f6a Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Mon, 4 May 2026 23:27:57 +0200 Subject: subpage: enabled state Track and surface a subscription's enabled state from backend to frontend so the UI can show inactive subscriptions and use it in active-state logic. Changes: - sub/subService.go: track hasEnabledClient, set traffic.Enable, add Enabled to PageData and populate it in BuildPageData. - sub/subController.go: include enabled in the page context. - web/html/settings/panel/subscription/subpage.html: emit data-enabled attribute and render an "inactive" tag when disabled. - web/assets/js/subscription.js: read data-enabled and include it in isActive() checks. This ensures subscriptions with no enabled clients are marked inactive in the UI and excluded from being considered active. --- web/assets/js/subscription.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'web/assets') 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'; -- cgit v1.2.3