From 40ca2ea427d12de013f558aa7fc6a563739681f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B4=E5=9C=A3=E4=BD=91?= Date: Sun, 26 Apr 2026 22:23:40 +0800 Subject: [PATCH] =?UTF-8?q?feat(sidepanel):=20=E6=B7=BB=E5=8A=A0=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7=E6=B1=A0=E6=90=9C=E7=B4=A2=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 9f2c3ebd3455e761c30e453daca98fe98206b33b) --- sidepanel/custom-email-pool-manager.js | 2 - sidepanel/hotmail-manager.js | 52 +++++++++++++++++++++- sidepanel/mail-2925-manager.js | 60 +++++++++++++++++++++++++- sidepanel/sidepanel.css | 21 +++++++++ sidepanel/sidepanel.html | 23 ++++++++++ sidepanel/sidepanel.js | 14 +++++- 6 files changed, 167 insertions(+), 5 deletions(-) diff --git a/sidepanel/custom-email-pool-manager.js b/sidepanel/custom-email-pool-manager.js index 2509bef..82a3e1d 100644 --- a/sidepanel/custom-email-pool-manager.js +++ b/sidepanel/custom-email-pool-manager.js @@ -140,8 +140,6 @@ if (dom.btnCustomEmailPoolClearUsed) dom.btnCustomEmailPoolClearUsed.disabled = loading; if (dom.btnCustomEmailPoolDeleteAll) dom.btnCustomEmailPoolDeleteAll.disabled = loading; if (dom.inputCustomEmailPoolImport) dom.inputCustomEmailPoolImport.disabled = loading; - if (dom.inputCustomEmailPoolSearch) dom.inputCustomEmailPoolSearch.disabled = loading; - if (dom.selectCustomEmailPoolFilter) dom.selectCustomEmailPoolFilter.disabled = loading; if (summary && dom.customEmailPoolSummary) { dom.customEmailPoolSummary.textContent = summary; diff --git a/sidepanel/hotmail-manager.js b/sidepanel/hotmail-manager.js index 23fd45b..2492730 100644 --- a/sidepanel/hotmail-manager.js +++ b/sidepanel/hotmail-manager.js @@ -16,6 +16,8 @@ let actionInFlight = false; let listExpanded = false; + let searchTerm = ''; + let filterMode = 'all'; function getHotmailAccountsByUsage(mode = 'all', currentState = state.getLatestState()) { const accounts = helpers.getHotmailAccounts(currentState); @@ -171,6 +173,39 @@ return `status-${account.status || 'pending'}`; } + function normalizeSearchText(value = '') { + return String(value || '').trim().toLowerCase(); + } + + function getFilteredHotmailAccounts(accounts, currentId = '') { + const normalizedSearchTerm = normalizeSearchText(searchTerm); + return accounts.filter((account) => { + const isCurrent = Boolean(currentId) && account.id === currentId; + const matchesFilter = (() => { + switch (filterMode) { + case 'current': return isCurrent; + case 'available': return !account.used; + case 'used': return Boolean(account.used); + case 'error': return account.status === 'error'; + default: return true; + } + })(); + + if (!matchesFilter) return false; + if (!normalizedSearchTerm) return true; + + const haystack = [ + account.email, + account.status, + getHotmailAvailabilityLabel(account), + getHotmailStatusLabel(account), + isCurrent ? 'current 当前' : '', + ].join(' ').toLowerCase(); + + return haystack.includes(normalizedSearchTerm); + }); + } + function clearHotmailForm() { dom.inputHotmailEmail.value = ''; dom.inputHotmailClientId.value = ''; @@ -209,7 +244,14 @@ return; } - dom.hotmailAccountsList.innerHTML = accounts.map((account) => ` + const visibleAccounts = getFilteredHotmailAccounts(accounts, currentId); + if (!visibleAccounts.length) { + dom.hotmailAccountsList.innerHTML = '
没有匹配当前筛选条件的 Hotmail 账号。
'; + updateHotmailListViewport(); + return; + } + + dom.hotmailAccountsList.innerHTML = visibleAccounts.map((account) => `
@@ -657,6 +668,18 @@ diff --git a/sidepanel/sidepanel.js b/sidepanel/sidepanel.js index 9cfcf4f..206634b 100644 --- a/sidepanel/sidepanel.js +++ b/sidepanel/sidepanel.js @@ -249,6 +249,8 @@ const inputHotmailClientId = document.getElementById('input-hotmail-client-id'); const inputHotmailPassword = document.getElementById('input-hotmail-password'); const inputHotmailRefreshToken = document.getElementById('input-hotmail-refresh-token'); const inputHotmailImport = document.getElementById('input-hotmail-import'); +const inputHotmailSearch = document.getElementById('input-hotmail-search'); +const selectHotmailFilter = document.getElementById('select-hotmail-filter'); const btnAddHotmailAccount = document.getElementById('btn-add-hotmail-account'); const btnImportHotmailAccounts = document.getElementById('btn-import-hotmail-accounts'); const btnToggleHotmailForm = document.getElementById('btn-toggle-hotmail-form'); @@ -262,6 +264,8 @@ const hotmailAccountsList = document.getElementById('hotmail-accounts-list'); const inputMail2925Email = document.getElementById('input-mail2925-email'); const inputMail2925Password = document.getElementById('input-mail2925-password'); const inputMail2925Import = document.getElementById('input-mail2925-import'); +const inputMail2925Search = document.getElementById('input-mail2925-search'); +const selectMail2925Filter = document.getElementById('select-mail2925-filter'); const btnAddMail2925Account = document.getElementById('btn-add-mail2925-account'); const btnToggleMail2925Form = document.getElementById('btn-toggle-mail2925-form'); const btnImportMail2925Accounts = document.getElementById('btn-import-mail2925-accounts'); @@ -6551,7 +6555,11 @@ function setSettingsCardLocked(locked) { return; } settingsCard.classList.toggle('is-locked', locked); - settingsCard.toggleAttribute('inert', locked); + settingsCard.toggleAttribute('inert', false); + Array.from(settingsCard.children).forEach((child) => { + const keepInteractive = child?.id === 'row-custom-email-pool'; + child.toggleAttribute('inert', Boolean(locked && !keepInteractive)); + }); } async function setRuntimeEmailState(email) { @@ -8817,6 +8825,8 @@ const hotmailManager = window.SidepanelHotmailManager?.createHotmailManager({ inputHotmailImport, inputHotmailPassword, inputHotmailRefreshToken, + inputHotmailSearch, + selectHotmailFilter, selectMailProvider, }, helpers: { @@ -8899,6 +8909,8 @@ const mail2925Manager = window.SidepanelMail2925Manager?.createMail2925Manager({ inputMail2925Email, inputMail2925Import, inputMail2925Password, + inputMail2925Search, + selectMail2925Filter, mail2925AccountsList, mail2925FormShell, mail2925ListShell,