fix/search: glass-стиль пилюли + надёжный IMAP TEXT-поиск
- IMAP search: заменил OR [subject,from] на TEXT — работает на всех серверах, корректный finally-release lock даже при ошибке - Поисковая пилюля: liquid glass (backdrop-filter, gradient bg, inner highlight, accent ring при раскрытии) - Результаты поиска: glass-карточки с hover/selected state Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
ab1c084b91
commit
6950003c79
2 changed files with 185 additions and 64 deletions
|
|
@ -293,28 +293,26 @@ export class ImapProvider implements IEmailProvider {
|
|||
): Promise<void> {
|
||||
for (const folder of folders) {
|
||||
if (results.length >= limit) break
|
||||
let lock: Awaited<ReturnType<typeof this.client.getMailboxLock>> | null = null
|
||||
try {
|
||||
const lock = await this.client.getMailboxLock(folder.path)
|
||||
try {
|
||||
// OR SUBJECT FROM — быстрый поиск по заголовкам без загрузки тел
|
||||
const uids = await this.client.search(
|
||||
{ or: [{ subject: query }, { from: query }] },
|
||||
{ uid: true }
|
||||
) as number[]
|
||||
lock = await this.client.getMailboxLock(folder.path)
|
||||
|
||||
if (uids?.length) {
|
||||
const remaining = limit - results.length
|
||||
const sorted = [...uids].sort((a, b) => b - a).slice(0, remaining)
|
||||
for await (const msg of this.client.fetch(sorted.join(','), {
|
||||
uid: true, envelope: true, flags: true, bodyStructure: true
|
||||
}, { uid: true })) {
|
||||
results.push(this.convertMessage(msg, folder.path))
|
||||
}
|
||||
// TEXT ищет в заголовках + теле — работает на всех IMAP-серверах
|
||||
const uids = await this.client.search({ text: query }, { uid: true }) as number[]
|
||||
|
||||
if (uids?.length) {
|
||||
const remaining = limit - results.length
|
||||
const sorted = [...uids].sort((a, b) => b - a).slice(0, remaining)
|
||||
for await (const msg of this.client.fetch(sorted.join(','), {
|
||||
uid: true, envelope: true, flags: true, bodyStructure: true
|
||||
}, { uid: true })) {
|
||||
results.push(this.convertMessage(msg, folder.path))
|
||||
}
|
||||
} finally {
|
||||
lock.release()
|
||||
}
|
||||
} catch { /* папка не поддерживает SEARCH или временно недоступна */ }
|
||||
finally {
|
||||
lock?.release()
|
||||
}
|
||||
|
||||
if (folder.folders?.length && results.length < limit) {
|
||||
await this.searchFolderTree(folder.folders, query, limit, results)
|
||||
|
|
|
|||
|
|
@ -26,11 +26,16 @@ let searchDebounce: ReturnType<typeof setTimeout> | null = null
|
|||
|
||||
function openSearch(): void {
|
||||
searchOpen.value = true
|
||||
nextTick(() => searchInputEl.value?.focus())
|
||||
// Фокус после того как анимация начнётся (иначе браузер скроллит до элемента)
|
||||
setTimeout(() => {
|
||||
searchInputEl.value?.removeAttribute('tabindex')
|
||||
searchInputEl.value?.focus()
|
||||
}, 60)
|
||||
}
|
||||
|
||||
function closeSearch(): void {
|
||||
searchOpen.value = false
|
||||
searchInputEl.value?.setAttribute('tabindex', '-1')
|
||||
messagesStore.clearSearch()
|
||||
}
|
||||
|
||||
|
|
@ -313,8 +318,9 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
|||
<template>
|
||||
<div class="message-list-container">
|
||||
<!-- Заголовок -->
|
||||
<div class="message-list-header" :class="{ 'search-mode': searchOpen }">
|
||||
<template v-if="!searchOpen">
|
||||
<div class="message-list-header">
|
||||
<!-- Обычный контент: гасится при поиске -->
|
||||
<div class="header-normal" :class="{ 'is-hidden': searchOpen }">
|
||||
<h2 class="folder-title truncate">{{ folderName }}</h2>
|
||||
<button
|
||||
v-if="activeUnread > 0 || messagesStore.unreadOnly"
|
||||
|
|
@ -326,9 +332,6 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
|||
{{ activeUnread }}
|
||||
</button>
|
||||
<div class="header-actions">
|
||||
<button class="icon-btn" v-tooltip="'Поиск (Ctrl+F)'" @click="openSearch">
|
||||
<AppIcon name="search" :size="13" />
|
||||
</button>
|
||||
<button
|
||||
class="icon-btn select-mode-btn"
|
||||
:class="{ active: selectMode }"
|
||||
|
|
@ -342,25 +345,34 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
|||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
<div class="search-bar">
|
||||
<AppIcon name="search" :size="13" class="search-bar-icon" />
|
||||
<input
|
||||
ref="searchInputEl"
|
||||
class="search-input"
|
||||
placeholder="Поиск по письмам..."
|
||||
:value="messagesStore.searchQuery"
|
||||
@input="onSearchInput"
|
||||
@keydown="onSearchKeydown"
|
||||
/>
|
||||
<div v-if="messagesStore.searchLoading" class="spinner-sm" />
|
||||
</div>
|
||||
<button class="icon-btn" v-tooltip="'Закрыть поиск'" @click="closeSearch">
|
||||
<AppIcon name="close" :size="12" />
|
||||
<!-- Поисковая панель: выезжает из правого угла -->
|
||||
<div
|
||||
class="search-pill"
|
||||
:class="{ 'search-pill--open': searchOpen }"
|
||||
@click="!searchOpen && openSearch()"
|
||||
>
|
||||
<AppIcon name="search" :size="13" class="search-pill-icon" />
|
||||
<input
|
||||
ref="searchInputEl"
|
||||
class="search-pill-input"
|
||||
placeholder="Поиск по письмам..."
|
||||
:value="messagesStore.searchQuery"
|
||||
tabindex="-1"
|
||||
@input="onSearchInput"
|
||||
@keydown="onSearchKeydown"
|
||||
/>
|
||||
<div v-if="messagesStore.searchLoading" class="spinner-sm search-pill-spinner" />
|
||||
<button
|
||||
v-if="searchOpen"
|
||||
class="search-pill-close"
|
||||
v-tooltip="'Закрыть (Esc)'"
|
||||
@click.stop="closeSearch"
|
||||
>
|
||||
<AppIcon name="close" :size="10" />
|
||||
</button>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Pull-to-refresh индикатор (всегда в DOM, высота = 0 в обычном состоянии) -->
|
||||
|
|
@ -556,8 +568,8 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
|||
.message-list-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 10px 12px;
|
||||
/* padding-right: чуть больше чтобы кнопка выбора не уходила под пилюлю */
|
||||
padding: 10px 46px 10px 12px;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.07);
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.10),
|
||||
|
|
@ -570,6 +582,7 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
|||
rgba(12, 12, 20, 0.65);
|
||||
backdrop-filter: blur(24px) saturate(1.6);
|
||||
-webkit-backdrop-filter: blur(24px) saturate(1.6);
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.folder-title {
|
||||
|
|
@ -1055,31 +1068,94 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
|||
|
||||
/* Анимация раскрытия управляется JS-хуками через scrollHeight */
|
||||
|
||||
/* ── Search bar ──────────────────────────────────────────── */
|
||||
.message-list-header.search-mode {
|
||||
gap: 6px;
|
||||
/* ── Search pill ─────────────────────────────────────────── */
|
||||
.header-normal {
|
||||
display: contents; /* дети становятся детьми хедера напрямую */
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.search-bar {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
/* Fade-out когда поиск открыт */
|
||||
.header-normal.is-hidden > * {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity 0.18s ease;
|
||||
}
|
||||
|
||||
.header-normal > * {
|
||||
transition: opacity 0.18s ease;
|
||||
}
|
||||
|
||||
/* Пилюля поиска: всегда в правом углу хедера */
|
||||
.search-pill {
|
||||
position: absolute;
|
||||
right: 12px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
background: rgba(255, 255, 255, 0.07);
|
||||
border: 1px solid rgba(255, 255, 255, 0.13);
|
||||
border-radius: var(--radius-full);
|
||||
padding: 0 10px;
|
||||
gap: 0;
|
||||
height: 28px;
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
|
||||
width: 28px; /* свёрнута — размер кнопки */
|
||||
|
||||
/* Liquid glass */
|
||||
background:
|
||||
linear-gradient(135deg, rgba(255, 255, 255, 0.09) 0%, rgba(255, 255, 255, 0.03) 100%),
|
||||
rgba(14, 14, 22, 0.55);
|
||||
backdrop-filter: blur(28px) saturate(1.8);
|
||||
-webkit-backdrop-filter: blur(28px) saturate(1.8);
|
||||
border: 1px solid rgba(255, 255, 255, 0.11);
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.14),
|
||||
0 2px 10px rgba(0, 0, 0, 0.30);
|
||||
|
||||
border-radius: 9999px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
width 0.30s cubic-bezier(0.34, 1.12, 0.64, 1),
|
||||
background 0.2s ease,
|
||||
border-color 0.2s ease,
|
||||
box-shadow 0.2s ease;
|
||||
}
|
||||
|
||||
.search-bar-icon {
|
||||
color: var(--text-muted);
|
||||
.search-pill:hover:not(.search-pill--open) {
|
||||
background:
|
||||
linear-gradient(135deg, rgba(255, 255, 255, 0.13) 0%, rgba(255, 255, 255, 0.05) 100%),
|
||||
rgba(14, 14, 22, 0.65);
|
||||
border-color: rgba(255, 255, 255, 0.18);
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.18),
|
||||
0 3px 14px rgba(0, 0, 0, 0.35);
|
||||
}
|
||||
|
||||
.search-pill--open {
|
||||
width: calc(100% - 24px); /* разворачивается на всю ширину хедера */
|
||||
background:
|
||||
linear-gradient(135deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.02) 100%),
|
||||
rgba(10, 10, 18, 0.72);
|
||||
border-color: color-mix(in srgb, var(--accent) 30%, rgba(255, 255, 255, 0.12));
|
||||
cursor: default;
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.12),
|
||||
0 0 0 2px color-mix(in srgb, var(--accent) 15%, transparent),
|
||||
0 4px 20px rgba(0, 0, 0, 0.35);
|
||||
}
|
||||
|
||||
.search-pill-icon {
|
||||
flex-shrink: 0;
|
||||
width: 28px; /* занимает место кнопки */
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--text-muted);
|
||||
transition: color 0.18s ease;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
.search-pill--open .search-pill-icon {
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.search-pill-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
background: none;
|
||||
|
|
@ -1088,42 +1164,88 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
|||
color: var(--text-primary);
|
||||
font-size: 13px;
|
||||
caret-color: var(--accent);
|
||||
padding: 0;
|
||||
/* Скрыт пока pill свёрнута */
|
||||
opacity: 0;
|
||||
transition: opacity 0.18s ease 0.08s;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.search-input::placeholder {
|
||||
.search-pill--open .search-pill-input {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.search-pill-input::placeholder {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.search-pill-spinner {
|
||||
flex-shrink: 0;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.search-pill-close {
|
||||
flex-shrink: 0;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 50%;
|
||||
color: var(--text-muted);
|
||||
margin-right: 3px;
|
||||
transition: background 0.15s ease, color 0.15s ease;
|
||||
}
|
||||
|
||||
.search-pill-close:hover {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
/* ── Search results ──────────────────────────────────────── */
|
||||
.search-results-list {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 0;
|
||||
padding: 4px 0 8px;
|
||||
mask-image: linear-gradient(to bottom, black 0%, black calc(100% - 56px), transparent 100%);
|
||||
-webkit-mask-image: linear-gradient(to bottom, black 0%, black calc(100% - 56px), transparent 100%);
|
||||
}
|
||||
|
||||
.search-results-count {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
padding: 6px 12px 4px;
|
||||
padding: 4px 12px 6px;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.search-result-item {
|
||||
padding: 9px 12px 8px;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.04);
|
||||
margin: 2px 5px;
|
||||
padding: 9px 11px 8px;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
transition: background var(--transition-fast);
|
||||
transition: background var(--transition-fast), box-shadow var(--transition-fast);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
background: rgba(255, 255, 255, 0.02);
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
.search-result-item:hover {
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
background:
|
||||
linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.02) 100%),
|
||||
rgba(14, 14, 22, 0.40);
|
||||
border-color: rgba(255, 255, 255, 0.07);
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
|
||||
}
|
||||
|
||||
.search-result-item.selected {
|
||||
background: var(--bg-selected);
|
||||
border-color: color-mix(in srgb, var(--accent) 25%, transparent);
|
||||
box-shadow:
|
||||
inset 0 1px 0 color-mix(in srgb, var(--accent) 15%, transparent),
|
||||
0 2px 8px color-mix(in srgb, var(--accent) 10%, transparent);
|
||||
}
|
||||
|
||||
.search-result-row {
|
||||
|
|
@ -1161,5 +1283,6 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
|||
padding: 1px 7px;
|
||||
align-self: flex-start;
|
||||
line-height: 16px;
|
||||
backdrop-filter: blur(4px);
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
Loading…
Reference in a new issue