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> {
|
): Promise<void> {
|
||||||
for (const folder of folders) {
|
for (const folder of folders) {
|
||||||
if (results.length >= limit) break
|
if (results.length >= limit) break
|
||||||
|
let lock: Awaited<ReturnType<typeof this.client.getMailboxLock>> | null = null
|
||||||
try {
|
try {
|
||||||
const lock = await this.client.getMailboxLock(folder.path)
|
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[]
|
|
||||||
|
|
||||||
if (uids?.length) {
|
// TEXT ищет в заголовках + теле — работает на всех IMAP-серверах
|
||||||
const remaining = limit - results.length
|
const uids = await this.client.search({ text: query }, { uid: true }) as number[]
|
||||||
const sorted = [...uids].sort((a, b) => b - a).slice(0, remaining)
|
|
||||||
for await (const msg of this.client.fetch(sorted.join(','), {
|
if (uids?.length) {
|
||||||
uid: true, envelope: true, flags: true, bodyStructure: true
|
const remaining = limit - results.length
|
||||||
}, { uid: true })) {
|
const sorted = [...uids].sort((a, b) => b - a).slice(0, remaining)
|
||||||
results.push(this.convertMessage(msg, folder.path))
|
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 или временно недоступна */ }
|
} catch { /* папка не поддерживает SEARCH или временно недоступна */ }
|
||||||
|
finally {
|
||||||
|
lock?.release()
|
||||||
|
}
|
||||||
|
|
||||||
if (folder.folders?.length && results.length < limit) {
|
if (folder.folders?.length && results.length < limit) {
|
||||||
await this.searchFolderTree(folder.folders, query, limit, results)
|
await this.searchFolderTree(folder.folders, query, limit, results)
|
||||||
|
|
|
||||||
|
|
@ -26,11 +26,16 @@ let searchDebounce: ReturnType<typeof setTimeout> | null = null
|
||||||
|
|
||||||
function openSearch(): void {
|
function openSearch(): void {
|
||||||
searchOpen.value = true
|
searchOpen.value = true
|
||||||
nextTick(() => searchInputEl.value?.focus())
|
// Фокус после того как анимация начнётся (иначе браузер скроллит до элемента)
|
||||||
|
setTimeout(() => {
|
||||||
|
searchInputEl.value?.removeAttribute('tabindex')
|
||||||
|
searchInputEl.value?.focus()
|
||||||
|
}, 60)
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeSearch(): void {
|
function closeSearch(): void {
|
||||||
searchOpen.value = false
|
searchOpen.value = false
|
||||||
|
searchInputEl.value?.setAttribute('tabindex', '-1')
|
||||||
messagesStore.clearSearch()
|
messagesStore.clearSearch()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -313,8 +318,9 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
||||||
<template>
|
<template>
|
||||||
<div class="message-list-container">
|
<div class="message-list-container">
|
||||||
<!-- Заголовок -->
|
<!-- Заголовок -->
|
||||||
<div class="message-list-header" :class="{ 'search-mode': searchOpen }">
|
<div class="message-list-header">
|
||||||
<template v-if="!searchOpen">
|
<!-- Обычный контент: гасится при поиске -->
|
||||||
|
<div class="header-normal" :class="{ 'is-hidden': searchOpen }">
|
||||||
<h2 class="folder-title truncate">{{ folderName }}</h2>
|
<h2 class="folder-title truncate">{{ folderName }}</h2>
|
||||||
<button
|
<button
|
||||||
v-if="activeUnread > 0 || messagesStore.unreadOnly"
|
v-if="activeUnread > 0 || messagesStore.unreadOnly"
|
||||||
|
|
@ -326,9 +332,6 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
||||||
{{ activeUnread }}
|
{{ activeUnread }}
|
||||||
</button>
|
</button>
|
||||||
<div class="header-actions">
|
<div class="header-actions">
|
||||||
<button class="icon-btn" v-tooltip="'Поиск (Ctrl+F)'" @click="openSearch">
|
|
||||||
<AppIcon name="search" :size="13" />
|
|
||||||
</button>
|
|
||||||
<button
|
<button
|
||||||
class="icon-btn select-mode-btn"
|
class="icon-btn select-mode-btn"
|
||||||
:class="{ active: selectMode }"
|
:class="{ active: selectMode }"
|
||||||
|
|
@ -342,25 +345,34 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</div>
|
||||||
|
|
||||||
<template v-else>
|
<!-- Поисковая панель: выезжает из правого угла -->
|
||||||
<div class="search-bar">
|
<div
|
||||||
<AppIcon name="search" :size="13" class="search-bar-icon" />
|
class="search-pill"
|
||||||
<input
|
:class="{ 'search-pill--open': searchOpen }"
|
||||||
ref="searchInputEl"
|
@click="!searchOpen && openSearch()"
|
||||||
class="search-input"
|
>
|
||||||
placeholder="Поиск по письмам..."
|
<AppIcon name="search" :size="13" class="search-pill-icon" />
|
||||||
:value="messagesStore.searchQuery"
|
<input
|
||||||
@input="onSearchInput"
|
ref="searchInputEl"
|
||||||
@keydown="onSearchKeydown"
|
class="search-pill-input"
|
||||||
/>
|
placeholder="Поиск по письмам..."
|
||||||
<div v-if="messagesStore.searchLoading" class="spinner-sm" />
|
:value="messagesStore.searchQuery"
|
||||||
</div>
|
tabindex="-1"
|
||||||
<button class="icon-btn" v-tooltip="'Закрыть поиск'" @click="closeSearch">
|
@input="onSearchInput"
|
||||||
<AppIcon name="close" :size="12" />
|
@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>
|
</button>
|
||||||
</template>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Pull-to-refresh индикатор (всегда в DOM, высота = 0 в обычном состоянии) -->
|
<!-- Pull-to-refresh индикатор (всегда в DOM, высота = 0 в обычном состоянии) -->
|
||||||
|
|
@ -556,8 +568,8 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
||||||
.message-list-header {
|
.message-list-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
/* padding-right: чуть больше чтобы кнопка выбора не уходила под пилюлю */
|
||||||
padding: 10px 12px;
|
padding: 10px 46px 10px 12px;
|
||||||
border-bottom: 1px solid rgba(255, 255, 255, 0.07);
|
border-bottom: 1px solid rgba(255, 255, 255, 0.07);
|
||||||
box-shadow:
|
box-shadow:
|
||||||
inset 0 1px 0 rgba(255, 255, 255, 0.10),
|
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);
|
rgba(12, 12, 20, 0.65);
|
||||||
backdrop-filter: blur(24px) saturate(1.6);
|
backdrop-filter: blur(24px) saturate(1.6);
|
||||||
-webkit-backdrop-filter: blur(24px) saturate(1.6);
|
-webkit-backdrop-filter: blur(24px) saturate(1.6);
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.folder-title {
|
.folder-title {
|
||||||
|
|
@ -1055,31 +1068,94 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
||||||
|
|
||||||
/* Анимация раскрытия управляется JS-хуками через scrollHeight */
|
/* Анимация раскрытия управляется JS-хуками через scrollHeight */
|
||||||
|
|
||||||
/* ── Search bar ──────────────────────────────────────────── */
|
/* ── Search pill ─────────────────────────────────────────── */
|
||||||
.message-list-header.search-mode {
|
.header-normal {
|
||||||
gap: 6px;
|
display: contents; /* дети становятся детьми хедера напрямую */
|
||||||
|
transition: opacity 0.2s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-bar {
|
/* Fade-out когда поиск открыт */
|
||||||
flex: 1;
|
.header-normal.is-hidden > * {
|
||||||
min-width: 0;
|
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;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 6px;
|
gap: 0;
|
||||||
background: rgba(255, 255, 255, 0.07);
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.13);
|
|
||||||
border-radius: var(--radius-full);
|
|
||||||
padding: 0 10px;
|
|
||||||
height: 28px;
|
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 {
|
.search-pill:hover:not(.search-pill--open) {
|
||||||
color: var(--text-muted);
|
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;
|
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;
|
flex: 1;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
background: none;
|
background: none;
|
||||||
|
|
@ -1088,42 +1164,88 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
caret-color: var(--accent);
|
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);
|
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 ──────────────────────────────────────── */
|
||||||
.search-results-list {
|
.search-results-list {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
overflow-y: auto;
|
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 {
|
.search-results-count {
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
color: var(--text-muted);
|
color: var(--text-muted);
|
||||||
padding: 6px 12px 4px;
|
padding: 4px 12px 6px;
|
||||||
letter-spacing: 0.02em;
|
letter-spacing: 0.02em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-result-item {
|
.search-result-item {
|
||||||
padding: 9px 12px 8px;
|
margin: 2px 5px;
|
||||||
border-bottom: 1px solid rgba(255, 255, 255, 0.04);
|
padding: 9px 11px 8px;
|
||||||
|
border-radius: 8px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: background var(--transition-fast);
|
transition: background var(--transition-fast), box-shadow var(--transition-fast);
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 3px;
|
gap: 3px;
|
||||||
|
background: rgba(255, 255, 255, 0.02);
|
||||||
|
border: 1px solid transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-result-item:hover {
|
.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 {
|
.search-result-item.selected {
|
||||||
background: var(--bg-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 {
|
.search-result-row {
|
||||||
|
|
@ -1161,5 +1283,6 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
||||||
padding: 1px 7px;
|
padding: 1px 7px;
|
||||||
align-self: flex-start;
|
align-self: flex-start;
|
||||||
line-height: 16px;
|
line-height: 16px;
|
||||||
|
backdrop-filter: blur(4px);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue