From 582037ae7020eae1454d794311a9ed8036abfa7e Mon Sep 17 00:00:00 2001 From: root Date: Fri, 24 Apr 2026 15:44:48 +0800 Subject: [PATCH] fix: settings save button and multiple UI bugs - Fix duplicate :min attributes on a-input-number (webPort, subPort, tgCpu) - Fix mismatched closing tags (a-input/a-switch instead of a-input-number) - Fix twoFactorEnable toggle receiving MouseEvent instead of boolean - Fix noise input handlers referencing undefined global `event` - Add error handling to settings change detection polling loop - Bump version to v1.5.4-beta --- config/version | 2 +- ...24-fix-settings-save-button-and-ui-bugs.md | 49 +++++++++++++++++++ web/html/settings.html | 11 +++-- web/html/settings/panel/general.html | 2 +- web/html/settings/panel/security.html | 2 +- .../settings/panel/subscription/general.html | 2 +- .../settings/panel/subscription/json.html | 4 +- web/html/settings/panel/telegram.html | 2 +- 8 files changed, 62 insertions(+), 12 deletions(-) create mode 100644 docs/Tasktracking/2026-04-24-fix-settings-save-button-and-ui-bugs.md diff --git a/config/version b/config/version index 9ddafeb7..452dfff2 100644 --- a/config/version +++ b/config/version @@ -1 +1 @@ -v1.5.3-beta \ No newline at end of file +v1.5.4-beta \ No newline at end of file diff --git a/docs/Tasktracking/2026-04-24-fix-settings-save-button-and-ui-bugs.md b/docs/Tasktracking/2026-04-24-fix-settings-save-button-and-ui-bugs.md new file mode 100644 index 00000000..c8adf7ef --- /dev/null +++ b/docs/Tasktracking/2026-04-24-fix-settings-save-button-and-ui-bugs.md @@ -0,0 +1,49 @@ +# 2026-04-24 Fix Settings Save Button and UI Bugs + +## Problem +Settings page save button would not enable when user changed settings. + +## Root Cause Analysis +Systematic debugging found multiple UI bugs affecting the settings page: + +1. **Duplicate `:min` attributes on `a-input-number`** (3 locations) + - `general.html:42` — webPort had `:min="1" :min="65535"` (second should be `:max`) + - `subscription/general.html:43` — subPort had same issue + - `telegram.html:64` — tgCpu had `:min="0" :min="100"` (second should be `:max`) + +2. **Mismatched closing tags** + - `general.html:42` — `` closed with `` + - `telegram.html:64` — `` closed with `` + +3. **twoFactorEnable toggle broken** (`security.html:39`) + - Used `@click="toggleTwoFactor" :checked="..."` instead of proper event handling + - `@click` passes MouseEvent as first arg, not the boolean toggle value + - Method expected boolean but received Event → always truthy → always triggered enable flow + +4. **Noise input handlers referenced undefined `event`** (`json.html:91,99`) + - `(value) => updateNoisePacket(index, event.target.value)` — `event` is not defined + - Arrow function parameter named `value` but code accessed global `event` + +5. **Polling loop had no error handling** (`settings.html:653-656`) + - Any error in the `while(true)` loop would silently stop change detection + +## Changes +- Fixed `:min`/`:max` attributes on all `a-input-number` components +- Fixed closing tags to match opening tags +- Changed twoFactorEnable to use `@click.prevent="toggleTwoFactor(!allSetting.twoFactorEnable)"` +- Updated `toggleTwoFactor` method to only set `twoFactorEnable` on success +- Fixed noise input handlers to use `(e) => ... e.target.value` +- Added try/catch around polling loop comparison + +## Files Modified +- `web/html/settings/panel/general.html` — webPort input fix +- `web/html/settings/panel/subscription/general.html` — subPort input fix +- `web/html/settings/panel/telegram.html` — tgCpu input fix +- `web/html/settings/panel/security.html` — twoFactorEnable toggle fix +- `web/html/settings/panel/subscription/json.html` — noise input handler fix +- `web/html/settings.html` — toggleTwoFactor method + polling error handling + +## Verification +- Visual inspection of all modified templates +- Confirmed `ObjectUtil.equals()` shallow comparison works correctly with Vue 2 reactivity +- Confirmed `AllSetting` class properties match Go struct fields diff --git a/web/html/settings.html b/web/html/settings.html index 196b27b9..6447650c 100644 --- a/web/html/settings.html +++ b/web/html/settings.html @@ -396,11 +396,9 @@ confirm: (success) => { if (success) { Vue.prototype.$message['success']('{{ i18n "pages.settings.security.twoFactorModalSetSuccess" }}') - this.allSetting.twoFactorToken = newTwoFactorToken + this.allSetting.twoFactorEnable = true } - - this.allSetting.twoFactorEnable = success } }) } else { @@ -412,7 +410,6 @@ confirm: (success) => { if (success) { Vue.prototype.$message['success']('{{ i18n "pages.settings.security.twoFactorModalDeleteSuccess" }}') - this.allSetting.twoFactorEnable = false this.allSetting.twoFactorToken = "" } @@ -655,7 +652,11 @@ } while (true) { await PromiseUtil.sleep(1000); - this.saveBtnDisable = this.oldAllSetting.equals(this.allSetting); + try { + this.saveBtnDisable = this.oldAllSetting.equals(this.allSetting); + } catch (e) { + console.error('Settings change detection error:', e); + } } } }); diff --git a/web/html/settings/panel/general.html b/web/html/settings/panel/general.html index 6969a1b4..205a3b88 100644 --- a/web/html/settings/panel/general.html +++ b/web/html/settings/panel/general.html @@ -39,7 +39,7 @@ diff --git a/web/html/settings/panel/security.html b/web/html/settings/panel/security.html index 2a570faa..5a2bd8d5 100644 --- a/web/html/settings/panel/security.html +++ b/web/html/settings/panel/security.html @@ -36,7 +36,7 @@ diff --git a/web/html/settings/panel/subscription/general.html b/web/html/settings/panel/subscription/general.html index ea00bdd3..64eaf0ef 100644 --- a/web/html/settings/panel/subscription/general.html +++ b/web/html/settings/panel/subscription/general.html @@ -40,7 +40,7 @@ diff --git a/web/html/settings/panel/subscription/json.html b/web/html/settings/panel/subscription/json.html index e8642305..f2371858 100644 --- a/web/html/settings/panel/subscription/json.html +++ b/web/html/settings/panel/subscription/json.html @@ -88,7 +88,7 @@ @@ -96,7 +96,7 @@ diff --git a/web/html/settings/panel/telegram.html b/web/html/settings/panel/telegram.html index 248831fd..ead89870 100644 --- a/web/html/settings/panel/telegram.html +++ b/web/html/settings/panel/telegram.html @@ -61,7 +61,7 @@