feat(sidepanel): 添加账号池搜索筛选
(cherry picked from commit 9f2c3ebd3455e761c30e453daca98fe98206b33b)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 = '<div class="hotmail-empty">没有匹配当前筛选条件的 Hotmail 账号。</div>';
|
||||
updateHotmailListViewport();
|
||||
return;
|
||||
}
|
||||
|
||||
dom.hotmailAccountsList.innerHTML = visibleAccounts.map((account) => `
|
||||
<div class="hotmail-account-item${account.id === currentId ? ' is-current' : ''}">
|
||||
<div class="hotmail-account-top">
|
||||
<div class="hotmail-account-title-row">
|
||||
@@ -541,6 +583,14 @@
|
||||
|
||||
dom.btnAddHotmailAccount?.addEventListener('click', handleAddHotmailAccount);
|
||||
dom.btnImportHotmailAccounts?.addEventListener('click', handleImportHotmailAccounts);
|
||||
dom.inputHotmailSearch?.addEventListener('input', (event) => {
|
||||
searchTerm = normalizeSearchText(event.target.value);
|
||||
renderHotmailAccounts();
|
||||
});
|
||||
dom.selectHotmailFilter?.addEventListener('change', (event) => {
|
||||
filterMode = String(event.target.value || 'all');
|
||||
renderHotmailAccounts();
|
||||
});
|
||||
dom.hotmailAccountsList?.addEventListener('click', handleAccountListClick);
|
||||
formController.sync();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
let actionInFlight = false;
|
||||
let listExpanded = false;
|
||||
let editingAccountId = '';
|
||||
let searchTerm = '';
|
||||
let filterMode = 'all';
|
||||
|
||||
function getMail2925Accounts(currentState = state.getLatestState()) {
|
||||
return helpers.getMail2925Accounts(currentState);
|
||||
@@ -89,6 +91,47 @@
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeSearchText(value = '') {
|
||||
return String(value || '').trim().toLowerCase();
|
||||
}
|
||||
|
||||
function getStatusKey(account) {
|
||||
return typeof mail2925Utils.getMail2925AccountStatus === 'function'
|
||||
? mail2925Utils.getMail2925AccountStatus(account, Date.now())
|
||||
: 'ready';
|
||||
}
|
||||
|
||||
function getFilteredMail2925Accounts(accounts, currentId = '') {
|
||||
const normalizedSearchTerm = normalizeSearchText(searchTerm);
|
||||
return accounts.filter((account) => {
|
||||
const statusKey = getStatusKey(account);
|
||||
const status = getStatusSnapshot(account);
|
||||
const isCurrent = Boolean(currentId) && account.id === currentId;
|
||||
const matchesFilter = (() => {
|
||||
switch (filterMode) {
|
||||
case 'current': return isCurrent;
|
||||
case 'ready': return statusKey === 'ready';
|
||||
case 'cooldown': return statusKey === 'cooldown';
|
||||
case 'disabled': return statusKey === 'disabled';
|
||||
case 'error': return statusKey === 'error';
|
||||
default: return true;
|
||||
}
|
||||
})();
|
||||
|
||||
if (!matchesFilter) return false;
|
||||
if (!normalizedSearchTerm) return true;
|
||||
|
||||
const haystack = [
|
||||
account.email,
|
||||
statusKey,
|
||||
status.label,
|
||||
isCurrent ? 'current 当前' : '',
|
||||
].join(' ').toLowerCase();
|
||||
|
||||
return haystack.includes(normalizedSearchTerm);
|
||||
});
|
||||
}
|
||||
|
||||
function refreshManagedAliasBaseEmail() {
|
||||
if (typeof helpers.refreshManagedAliasBaseEmail === 'function') {
|
||||
helpers.refreshManagedAliasBaseEmail();
|
||||
@@ -175,7 +218,14 @@
|
||||
return;
|
||||
}
|
||||
|
||||
dom.mail2925AccountsList.innerHTML = accounts.map((account) => {
|
||||
const visibleAccounts = getFilteredMail2925Accounts(accounts, currentId);
|
||||
if (!visibleAccounts.length) {
|
||||
dom.mail2925AccountsList.innerHTML = '<div class="hotmail-empty">没有匹配当前筛选条件的 2925 账号。</div>';
|
||||
updateMail2925ListViewport();
|
||||
return;
|
||||
}
|
||||
|
||||
dom.mail2925AccountsList.innerHTML = visibleAccounts.map((account) => {
|
||||
const status = getStatusSnapshot(account);
|
||||
const coolingDown = status.label === '冷却中';
|
||||
return `
|
||||
@@ -520,6 +570,14 @@
|
||||
|
||||
dom.btnAddMail2925Account?.addEventListener('click', handleAddMail2925Account);
|
||||
dom.btnImportMail2925Accounts?.addEventListener('click', handleImportMail2925Accounts);
|
||||
dom.inputMail2925Search?.addEventListener('input', (event) => {
|
||||
searchTerm = normalizeSearchText(event.target.value);
|
||||
renderMail2925Accounts();
|
||||
});
|
||||
dom.selectMail2925Filter?.addEventListener('change', (event) => {
|
||||
filterMode = String(event.target.value || 'all');
|
||||
renderMail2925Accounts();
|
||||
});
|
||||
dom.mail2925AccountsList?.addEventListener('click', handleAccountListClick);
|
||||
syncEditUi();
|
||||
formController.sync();
|
||||
|
||||
@@ -1572,6 +1572,27 @@ header {
|
||||
background: var(--text-muted);
|
||||
}
|
||||
|
||||
.account-pool-toolbar {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
padding: 6px 4px 8px;
|
||||
background: color-mix(in srgb, var(--bg-base) 92%, transparent);
|
||||
backdrop-filter: blur(6px);
|
||||
}
|
||||
|
||||
.account-pool-search {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.account-pool-filter {
|
||||
flex: 0 0 110px;
|
||||
}
|
||||
|
||||
.hotmail-accounts-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -609,6 +609,17 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="hotmail-list-shell" class="hotmail-list-shell is-collapsed">
|
||||
<div class="account-pool-toolbar">
|
||||
<input id="input-hotmail-search" class="data-input account-pool-search" type="text"
|
||||
placeholder="搜索邮箱 / 状态" />
|
||||
<select id="select-hotmail-filter" class="data-select account-pool-filter">
|
||||
<option value="all">全部</option>
|
||||
<option value="current">当前</option>
|
||||
<option value="available">可分配</option>
|
||||
<option value="used">已用</option>
|
||||
<option value="error">异常</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="hotmail-accounts-list" class="hotmail-accounts-list"></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -657,6 +668,18 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="mail2925-list-shell" class="hotmail-list-shell is-collapsed">
|
||||
<div class="account-pool-toolbar">
|
||||
<input id="input-mail2925-search" class="data-input account-pool-search" type="text"
|
||||
placeholder="搜索邮箱 / 状态" />
|
||||
<select id="select-mail2925-filter" class="data-select account-pool-filter">
|
||||
<option value="all">全部</option>
|
||||
<option value="current">当前</option>
|
||||
<option value="ready">可用</option>
|
||||
<option value="cooldown">冷却中</option>
|
||||
<option value="disabled">已禁用</option>
|
||||
<option value="error">异常</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="mail2925-accounts-list" class="hotmail-accounts-list"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+13
-1
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user