From 5d2b60af56a68a083b7773a23f09cfb511098624 Mon Sep 17 00:00:00 2001 From: QLHazyCoder <2825305047@qq.com> Date: Tue, 21 Apr 2026 02:16:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=92=8C=E5=8F=96=E6=B6=88=E7=BC=96=E8=BE=91=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=88=B02925=E9=82=AE=E7=AE=B1=E7=AE=A1=E7=90=86=E5=99=A8?= =?UTF-8?q?=EF=BC=8C=E6=9B=B4=E6=96=B0=E7=9B=B8=E5=85=B3UI=E5=92=8C?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sidepanel/mail-2925-manager.js | 57 ++++++++++++++- sidepanel/sidepanel.html | 7 +- sidepanel/sidepanel.js | 2 + tests/sidepanel-contribution-button.test.js | 1 + tests/sidepanel-mail2925-edit.test.js | 81 +++++++++++++++++++++ tests/sidepanel-mail2925-manager.test.js | 1 + 6 files changed, 144 insertions(+), 5 deletions(-) create mode 100644 tests/sidepanel-mail2925-edit.test.js diff --git a/sidepanel/mail-2925-manager.js b/sidepanel/mail-2925-manager.js index fcb6918..e7793b8 100644 --- a/sidepanel/mail-2925-manager.js +++ b/sidepanel/mail-2925-manager.js @@ -15,6 +15,7 @@ let actionInFlight = false; let listExpanded = false; + let editingAccountId = ''; function getMail2925Accounts(currentState = state.getLatestState()) { return helpers.getMail2925Accounts(currentState); @@ -93,7 +94,7 @@ } } - function applyMail2925AccountMutation(account, options = {}) { + function applyMail2925AccountMutation(account) { if (!account?.id) return; const latestState = state.getLatestState(); const currentId = getCurrentMail2925AccountId(latestState); @@ -117,6 +118,32 @@ if (dom.inputMail2925Password) dom.inputMail2925Password.value = ''; } + function syncEditUi() { + if (dom.btnAddMail2925Account) { + dom.btnAddMail2925Account.textContent = editingAccountId ? '保存修改' : '添加账号'; + } + if (dom.btnCancelMail2925Edit) { + dom.btnCancelMail2925Edit.style.display = editingAccountId ? '' : 'none'; + } + } + + function startEditingAccount(account) { + if (!account?.id) return; + editingAccountId = account.id; + if (dom.inputMail2925Email) dom.inputMail2925Email.value = String(account.email || '').trim(); + if (dom.inputMail2925Password) dom.inputMail2925Password.value = String(account.password || ''); + syncEditUi(); + } + + function stopEditingAccount(options = {}) { + const { clearForm = true } = options; + editingAccountId = ''; + if (clearForm) { + clearMail2925Form(); + } + syncEditUi(); + } + function renderMail2925Accounts() { if (!dom.mail2925AccountsList) return; @@ -160,6 +187,7 @@