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 = '