feature/compose: отдельное Electron-окно для написания писем
- Новое compose-окно открывается как BrowserWindow через IPC compose:open - ComposeView.vue — отдельная страница #/compose с token-input адресами - Кнопка «Новое письмо» перенесена в заголовок списка писем (message-list-header) - compose.store упрощён: только openNew/openReply/openForward через IPC - Убран модальный ComposeWindow из AppShell - Улучшен liquid glass стиль инпутов: сильнее blur, highlight, hover и focus-glow Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
05e5c8c5d2
commit
b3a66604b1
9 changed files with 665 additions and 153 deletions
|
|
@ -5,9 +5,56 @@ import { registerAccountHandlers } from './ipc/accounts.handler'
|
|||
import { registerFolderHandlers } from './ipc/folders.handler'
|
||||
import { registerMessageHandlers } from './ipc/messages.handler'
|
||||
import { registerOAuthHandlers } from './ipc/oauth.handler'
|
||||
import type { ComposeSession } from '@shared/types/message'
|
||||
|
||||
const accountManager = new AccountManager()
|
||||
|
||||
// ── Compose windows ───────────────────────────────────────
|
||||
// webContentsId → session, заполняется до loadURL, читается окном при монтировании
|
||||
const composeSessions = new Map<number, ComposeSession>()
|
||||
|
||||
function createComposeWindow(session: ComposeSession): void {
|
||||
const iconPath = app.isPackaged
|
||||
? join(process.resourcesPath, 'icon.png')
|
||||
: join(app.getAppPath(), 'resources/icon.png')
|
||||
|
||||
const win = new BrowserWindow({
|
||||
width: 700,
|
||||
height: 580,
|
||||
minWidth: 520,
|
||||
minHeight: 440,
|
||||
icon: iconPath,
|
||||
backgroundColor: '#09090e',
|
||||
title: session.mode === 'new' ? 'Новое письмо'
|
||||
: session.mode === 'forward' ? 'Переслать'
|
||||
: 'Ответить',
|
||||
webPreferences: {
|
||||
preload: join(__dirname, '../preload/index.js'),
|
||||
sandbox: false,
|
||||
contextIsolation: true,
|
||||
nodeIntegration: false
|
||||
}
|
||||
})
|
||||
|
||||
composeSessions.set(win.webContents.id, session)
|
||||
win.on('closed', () => composeSessions.delete(win.webContents.id))
|
||||
|
||||
if (process.env.ELECTRON_RENDERER_URL) {
|
||||
win.loadURL(`${process.env.ELECTRON_RENDERER_URL}#/compose`)
|
||||
} else {
|
||||
win.loadFile(join(__dirname, '../renderer/index.html'), { hash: '/compose' })
|
||||
}
|
||||
}
|
||||
|
||||
ipcMain.handle('compose:open', (_event, session: ComposeSession) => {
|
||||
createComposeWindow(session)
|
||||
})
|
||||
|
||||
ipcMain.handle('compose:getData', (event) => {
|
||||
const session = composeSessions.get(event.sender.id) ?? null
|
||||
return session
|
||||
})
|
||||
|
||||
function createWindow(): BrowserWindow {
|
||||
const iconPath = app.isPackaged
|
||||
? join(process.resourcesPath, 'icon.png')
|
||||
|
|
|
|||
|
|
@ -74,27 +74,50 @@ textarea {
|
|||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
color: var(--text-primary);
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
background:
|
||||
linear-gradient(180deg, rgba(255, 255, 255, 0.055) 0%, rgba(255, 255, 255, 0.02) 100%),
|
||||
rgba(12, 12, 20, 0.55);
|
||||
border: 1px solid rgba(255, 255, 255, 0.13);
|
||||
border-radius: var(--radius-sm);
|
||||
padding: 7px 10px;
|
||||
outline: none;
|
||||
backdrop-filter: blur(8px);
|
||||
-webkit-backdrop-filter: blur(8px);
|
||||
backdrop-filter: blur(16px) saturate(1.6);
|
||||
-webkit-backdrop-filter: blur(16px) saturate(1.6);
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.07),
|
||||
inset 0 -1px 0 rgba(0, 0, 0, 0.1);
|
||||
transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
|
||||
inset 0 1.5px 0 rgba(255, 255, 255, 0.13),
|
||||
inset 0 -1px 0 rgba(0, 0, 0, 0.18),
|
||||
inset 1px 0 0 rgba(255, 255, 255, 0.04),
|
||||
inset -1px 0 0 rgba(255, 255, 255, 0.04),
|
||||
0 1px 3px rgba(0, 0, 0, 0.22);
|
||||
transition:
|
||||
border-color var(--transition-fast),
|
||||
box-shadow var(--transition-fast),
|
||||
background var(--transition-fast);
|
||||
}
|
||||
|
||||
input:hover:not(:focus),
|
||||
select:hover:not(:focus),
|
||||
textarea:hover:not(:focus) {
|
||||
background:
|
||||
linear-gradient(180deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.03) 100%),
|
||||
rgba(12, 12, 20, 0.60);
|
||||
border-color: rgba(255, 255, 255, 0.18);
|
||||
}
|
||||
|
||||
input:focus,
|
||||
select:focus,
|
||||
textarea:focus {
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border-color: color-mix(in srgb, var(--accent) 55%, transparent);
|
||||
background:
|
||||
linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.03) 100%),
|
||||
rgba(14, 14, 24, 0.65);
|
||||
border-color: color-mix(in srgb, var(--accent) 60%, transparent);
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.08),
|
||||
0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
|
||||
inset 0 1.5px 0 rgba(255, 255, 255, 0.16),
|
||||
inset 0 -1px 0 rgba(0, 0, 0, 0.20),
|
||||
inset 1px 0 0 rgba(255, 255, 255, 0.05),
|
||||
inset -1px 0 0 rgba(255, 255, 255, 0.05),
|
||||
0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent),
|
||||
0 0 12px color-mix(in srgb, var(--accent) 8%, transparent);
|
||||
}
|
||||
|
||||
/* ── Scrollbar ─────────────────────────────────────────── */
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import MessageList from '../messages/MessageList.vue'
|
|||
import MessagePreview from '../preview/MessagePreview.vue'
|
||||
import AddAccountDialog from '../accounts/AddAccountDialog.vue'
|
||||
import NotificationContainer from '../notifications/NotificationContainer.vue'
|
||||
import ComposeWindow from '../compose/ComposeWindow.vue'
|
||||
import AppIcon from '../AppIcon.vue'
|
||||
import { useAccountsStore } from '../../stores/accounts.store'
|
||||
import { useComposeStore } from '../../stores/compose.store'
|
||||
|
|
@ -69,14 +68,6 @@ onUnmounted(() => document.removeEventListener('keydown', onGlobalKeydown))
|
|||
<div class="content-area">
|
||||
<div class="account-bar">
|
||||
<AccountSwitcher @add-account="onAddAccount" />
|
||||
<button
|
||||
v-if="accountsStore.accounts.length > 0"
|
||||
class="compose-btn"
|
||||
v-tooltip="'Новое письмо (Ctrl+N)'"
|
||||
@click="composeStore.openNew()"
|
||||
>
|
||||
<AppIcon name="compose" :size="16" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="folder-pane" :style="{ width: folderPaneWidth + 'px' }">
|
||||
|
|
@ -102,7 +93,6 @@ onUnmounted(() => document.removeEventListener('keydown', onGlobalKeydown))
|
|||
/>
|
||||
|
||||
<NotificationContainer />
|
||||
<ComposeWindow />
|
||||
|
||||
<!-- Пустое состояние: нет аккаунтов -->
|
||||
<div v-if="accountsStore.accounts.length === 0 && !accountsStore.loading && !showAddAccount" class="empty-state">
|
||||
|
|
@ -159,44 +149,6 @@ onUnmounted(() => document.removeEventListener('keydown', onGlobalKeydown))
|
|||
overflow: hidden;
|
||||
}
|
||||
|
||||
.compose-btn {
|
||||
margin: 0 8px 10px;
|
||||
padding: 9px 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 10px;
|
||||
color: var(--text-secondary);
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
border: 1px solid rgba(255, 255, 255, 0.10);
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09);
|
||||
cursor: pointer;
|
||||
transition:
|
||||
background var(--transition-fast),
|
||||
color var(--transition-fast),
|
||||
border-color var(--transition-fast),
|
||||
box-shadow var(--transition-fast),
|
||||
transform var(--transition-fast);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.compose-btn:hover {
|
||||
background: linear-gradient(
|
||||
to bottom,
|
||||
color-mix(in srgb, var(--accent) 88%, white 12%) 0%,
|
||||
var(--accent) 100%
|
||||
);
|
||||
border-color: transparent;
|
||||
color: var(--accent-text);
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.35),
|
||||
0 3px 12px color-mix(in srgb, var(--accent) 35%, transparent);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.compose-btn:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.folder-pane {
|
||||
flex-shrink: 0;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { useMessagesStore } from '../../stores/messages.store'
|
|||
import { useFoldersStore } from '../../stores/folders.store'
|
||||
import { useAccountsStore } from '../../stores/accounts.store'
|
||||
import { useSettingsStore, type SwipeAction } from '../../stores/settings.store'
|
||||
import { useComposeStore } from '../../stores/compose.store'
|
||||
import { useIpc } from '../../composables/useIpc'
|
||||
import MessageListItem from './MessageListItem.vue'
|
||||
import ThreadListItem from './ThreadListItem.vue'
|
||||
|
|
@ -15,6 +16,7 @@ const messagesStore = useMessagesStore()
|
|||
const foldersStore = useFoldersStore()
|
||||
const accountsStore = useAccountsStore()
|
||||
const settingsStore = useSettingsStore()
|
||||
const composeStore = useComposeStore()
|
||||
const { invoke } = useIpc()
|
||||
|
||||
const selectMode = ref(false)
|
||||
|
|
@ -340,6 +342,14 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
|||
{{ activeUnread }}
|
||||
</button>
|
||||
<div class="header-actions">
|
||||
<button
|
||||
v-if="accountsStore.accounts.length > 0"
|
||||
class="icon-btn compose-btn"
|
||||
v-tooltip="'Новое письмо (Ctrl+N)'"
|
||||
@click="composeStore.openNew()"
|
||||
>
|
||||
<AppIcon name="compose" :size="14" />
|
||||
</button>
|
||||
<button
|
||||
class="icon-btn select-mode-btn"
|
||||
:class="{ active: selectMode }"
|
||||
|
|
|
|||
|
|
@ -18,6 +18,11 @@ const router = createRouter({
|
|||
path: '/settings',
|
||||
name: 'settings',
|
||||
component: () => import('./views/SettingsView.vue')
|
||||
},
|
||||
{
|
||||
path: '/compose',
|
||||
name: 'compose',
|
||||
component: () => import('./views/ComposeView.vue')
|
||||
}
|
||||
]
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,25 +1,9 @@
|
|||
import { ref, computed } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
import type { ComposeData } from '@shared/types/message'
|
||||
import type { ComposeSession } from '@shared/types/message'
|
||||
import type { MessageEnvelope, MessageBody } from '@shared/types/message'
|
||||
import { useAccountsStore } from './accounts.store'
|
||||
import { useIpc } from '../composables/useIpc'
|
||||
|
||||
export type ComposeMode = 'new' | 'reply' | 'replyAll' | 'forward'
|
||||
|
||||
export interface ComposeDraft {
|
||||
mode: ComposeMode
|
||||
to: string[]
|
||||
cc: string[]
|
||||
bcc: string[]
|
||||
subject: string
|
||||
body: string
|
||||
inReplyTo?: string
|
||||
references?: string
|
||||
replyToMessageId?: string
|
||||
replyToFolderId?: string
|
||||
}
|
||||
|
||||
function quoteBody(envelope: MessageEnvelope, body: MessageBody | null): string {
|
||||
const date = envelope.date ? new Date(envelope.date).toLocaleString('ru') : ''
|
||||
const from = envelope.from.name
|
||||
|
|
@ -34,26 +18,39 @@ export const useComposeStore = defineStore('compose', () => {
|
|||
const { invoke } = useIpc()
|
||||
const accountsStore = useAccountsStore()
|
||||
|
||||
const draft = ref<ComposeDraft | null>(null)
|
||||
const sending = ref(false)
|
||||
const sendError = ref<string | null>(null)
|
||||
|
||||
const isOpen = computed(() => draft.value !== null)
|
||||
function getAccountSession(): Pick<ComposeSession, 'accountId' | 'accountEmail' | 'accountLabel'> | null {
|
||||
const acc = accountsStore.activeAccount
|
||||
if (!acc) return null
|
||||
return {
|
||||
accountId: acc.id,
|
||||
accountEmail: acc.email,
|
||||
accountLabel: acc.label ?? acc.email
|
||||
}
|
||||
}
|
||||
|
||||
function openNew(): void {
|
||||
sendError.value = null
|
||||
draft.value = { mode: 'new', to: [], cc: [], bcc: [], subject: '', body: '' }
|
||||
const acc = getAccountSession()
|
||||
if (!acc) return
|
||||
const session: ComposeSession = {
|
||||
...acc,
|
||||
mode: 'new',
|
||||
to: [], cc: [], bcc: [],
|
||||
subject: '', body: ''
|
||||
}
|
||||
invoke('compose:open', session)
|
||||
}
|
||||
|
||||
function openReply(envelope: MessageEnvelope, body: MessageBody | null, replyAll = false): void {
|
||||
sendError.value = null
|
||||
const acc = getAccountSession()
|
||||
if (!acc) return
|
||||
const to = replyAll
|
||||
? [envelope.from.email, ...envelope.to.map((a) => a.email)].filter(
|
||||
(e) => e !== accountsStore.activeAccount?.email
|
||||
(e) => e !== acc.accountEmail
|
||||
)
|
||||
: [envelope.from.email]
|
||||
const cc = replyAll ? envelope.cc.map((a) => a.email) : []
|
||||
draft.value = {
|
||||
const session: ComposeSession = {
|
||||
...acc,
|
||||
mode: replyAll ? 'replyAll' : 'reply',
|
||||
to,
|
||||
cc,
|
||||
|
|
@ -65,80 +62,23 @@ export const useComposeStore = defineStore('compose', () => {
|
|||
? [envelope.inReplyTo, envelope.messageId].filter(Boolean).join(' ')
|
||||
: undefined,
|
||||
replyToMessageId: envelope.id,
|
||||
replyToFolderId: envelope.folderId
|
||||
replyToFolderId: envelope.folderId
|
||||
}
|
||||
invoke('compose:open', session)
|
||||
}
|
||||
|
||||
function openForward(envelope: MessageEnvelope, body: MessageBody | null): void {
|
||||
sendError.value = null
|
||||
draft.value = {
|
||||
const acc = getAccountSession()
|
||||
if (!acc) return
|
||||
const session: ComposeSession = {
|
||||
...acc,
|
||||
mode: 'forward',
|
||||
to: [],
|
||||
cc: [],
|
||||
bcc: [],
|
||||
to: [], cc: [], bcc: [],
|
||||
subject: envelope.subject.startsWith('Fwd:') ? envelope.subject : `Fwd: ${envelope.subject}`,
|
||||
body: quoteBody(envelope, body)
|
||||
}
|
||||
invoke('compose:open', session)
|
||||
}
|
||||
|
||||
function close(): void {
|
||||
draft.value = null
|
||||
sendError.value = null
|
||||
}
|
||||
|
||||
async function send(): Promise<boolean> {
|
||||
if (!draft.value) return false
|
||||
if (!accountsStore.activeAccountId) {
|
||||
sendError.value = 'Нет активного аккаунта'
|
||||
return false
|
||||
}
|
||||
if (!draft.value.to.length) {
|
||||
sendError.value = 'Укажите получателя'
|
||||
return false
|
||||
}
|
||||
|
||||
const compose: ComposeData = {
|
||||
to: draft.value.to,
|
||||
cc: draft.value.cc,
|
||||
bcc: draft.value.bcc,
|
||||
subject: draft.value.subject,
|
||||
body: draft.value.body,
|
||||
inReplyTo: draft.value.inReplyTo,
|
||||
references: draft.value.references,
|
||||
replyToMessageId: draft.value.replyToMessageId,
|
||||
replyToFolderId: draft.value.replyToFolderId
|
||||
}
|
||||
|
||||
sending.value = true
|
||||
sendError.value = null
|
||||
try {
|
||||
const result = await invoke('messages:send', {
|
||||
accountId: accountsStore.activeAccountId,
|
||||
compose
|
||||
})
|
||||
if (!result.success) {
|
||||
sendError.value = result.error ?? 'Ошибка отправки'
|
||||
return false
|
||||
}
|
||||
close()
|
||||
return true
|
||||
} catch (e) {
|
||||
sendError.value = (e as Error).message
|
||||
return false
|
||||
} finally {
|
||||
sending.value = false
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
draft,
|
||||
isOpen,
|
||||
sending,
|
||||
sendError,
|
||||
openNew,
|
||||
openReply,
|
||||
openForward,
|
||||
close,
|
||||
send
|
||||
}
|
||||
return { openNew, openReply, openForward }
|
||||
})
|
||||
|
|
|
|||
523
src/renderer/src/views/ComposeView.vue
Normal file
523
src/renderer/src/views/ComposeView.vue
Normal file
|
|
@ -0,0 +1,523 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, onMounted, onUnmounted, nextTick } from 'vue'
|
||||
import type { ComposeSession } from '@shared/types/message'
|
||||
import { useIpc } from '../composables/useIpc'
|
||||
import AppIcon from '../components/AppIcon.vue'
|
||||
|
||||
const { invoke } = useIpc()
|
||||
|
||||
// ── State ─────────────────────────────────────────────────
|
||||
const session = ref<ComposeSession | null>(null)
|
||||
const to = ref<string[]>([])
|
||||
const cc = ref<string[]>([])
|
||||
const bcc = ref<string[]>([])
|
||||
const subject = ref('')
|
||||
const body = ref('')
|
||||
const sending = ref(false)
|
||||
const sendError = ref('')
|
||||
|
||||
const toInput = ref('')
|
||||
const ccInput = ref('')
|
||||
const bccInput = ref('')
|
||||
const showCc = ref(false)
|
||||
const showBcc = ref(false)
|
||||
|
||||
const toInputEl = ref<HTMLInputElement | null>(null)
|
||||
const bodyEl = ref<HTMLTextAreaElement | null>(null)
|
||||
|
||||
// ── Init ──────────────────────────────────────────────────
|
||||
onMounted(async () => {
|
||||
const data = await invoke('compose:getData')
|
||||
if (!data) return
|
||||
session.value = data
|
||||
to.value = [...(data.to ?? [])]
|
||||
cc.value = [...(data.cc ?? [])]
|
||||
bcc.value = [...(data.bcc ?? [])]
|
||||
subject.value = data.subject ?? ''
|
||||
body.value = data.body ?? ''
|
||||
showCc.value = cc.value.length > 0
|
||||
showBcc.value = bcc.value.length > 0
|
||||
|
||||
nextTick(() => {
|
||||
if (data.mode === 'new') toInputEl.value?.focus()
|
||||
else { bodyEl.value?.focus(); bodyEl.value?.setSelectionRange(0, 0) }
|
||||
})
|
||||
})
|
||||
|
||||
// ── Address tokens ────────────────────────────────────────
|
||||
type Field = 'to' | 'cc' | 'bcc'
|
||||
|
||||
const fieldInput = (f: Field) => f === 'to' ? toInput : f === 'cc' ? ccInput : bccInput
|
||||
const fieldArr = (f: Field) => f === 'to' ? to : f === 'cc' ? cc : bcc
|
||||
|
||||
function parseEmails(raw: string): string[] {
|
||||
return raw.split(/[,;\s]+/).map((s) => s.trim()).filter((s) => s.includes('@'))
|
||||
}
|
||||
|
||||
function commitInput(field: Field): void {
|
||||
const raw = fieldInput(field).value
|
||||
const emails = parseEmails(raw)
|
||||
if (!emails.length) return
|
||||
fieldArr(field).value.push(...emails)
|
||||
fieldInput(field).value = ''
|
||||
}
|
||||
|
||||
function onAddrKeydown(e: KeyboardEvent, field: Field): void {
|
||||
if (e.key === 'Enter' || e.key === 'Tab' || e.key === ',') {
|
||||
e.preventDefault()
|
||||
commitInput(field)
|
||||
}
|
||||
if (e.key === 'Backspace' && fieldInput(field).value === '') {
|
||||
fieldArr(field).value.pop()
|
||||
}
|
||||
}
|
||||
|
||||
function removeAddr(field: Field, idx: number): void {
|
||||
fieldArr(field).value.splice(idx, 1)
|
||||
}
|
||||
|
||||
// ── Send ──────────────────────────────────────────────────
|
||||
async function handleSend(): Promise<void> {
|
||||
commitInput('to'); commitInput('cc'); commitInput('bcc')
|
||||
await nextTick()
|
||||
|
||||
if (!to.value.length) { sendError.value = 'Укажите получателя'; return }
|
||||
if (!session.value) { sendError.value = 'Нет данных аккаунта'; return }
|
||||
|
||||
sending.value = true
|
||||
sendError.value = ''
|
||||
try {
|
||||
const result = await invoke('messages:send', {
|
||||
accountId: session.value.accountId,
|
||||
compose: {
|
||||
to: to.value,
|
||||
cc: cc.value,
|
||||
bcc: bcc.value,
|
||||
subject: subject.value,
|
||||
body: body.value,
|
||||
inReplyTo: session.value.inReplyTo,
|
||||
references: session.value.references,
|
||||
replyToMessageId: session.value.replyToMessageId,
|
||||
replyToFolderId: session.value.replyToFolderId
|
||||
}
|
||||
})
|
||||
if (result.success) {
|
||||
window.close()
|
||||
} else {
|
||||
sendError.value = result.error ?? 'Ошибка отправки'
|
||||
}
|
||||
} catch (e) {
|
||||
sendError.value = (e as Error).message
|
||||
} finally {
|
||||
sending.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// ── Keyboard shortcuts ────────────────────────────────────
|
||||
function onKeydown(e: KeyboardEvent): void {
|
||||
if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') { e.preventDefault(); handleSend() }
|
||||
if (e.key === 'Escape') window.close()
|
||||
}
|
||||
|
||||
onMounted(() => document.addEventListener('keydown', onKeydown))
|
||||
onUnmounted(() => document.removeEventListener('keydown', onKeydown))
|
||||
|
||||
// ── Title label ───────────────────────────────────────────
|
||||
const modeLabel = (m?: string) =>
|
||||
m === 'forward' ? 'Переслать' : m === 'reply' || m === 'replyAll' ? 'Ответить' : 'Новое письмо'
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="compose-page">
|
||||
<!-- Header bar -->
|
||||
<div class="compose-bar">
|
||||
<span class="compose-bar-title">{{ modeLabel(session?.mode) }}</span>
|
||||
<div class="compose-bar-from" v-if="session">
|
||||
От: {{ session.accountLabel || session.accountEmail }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Fields -->
|
||||
<div class="compose-fields">
|
||||
<!-- To -->
|
||||
<div class="field-row">
|
||||
<span class="field-label">Кому</span>
|
||||
<div class="addr-wrap">
|
||||
<span v-for="(addr, i) in to" :key="i" class="addr-token">
|
||||
{{ addr }}<button class="token-x" @click="removeAddr('to', i)">×</button>
|
||||
</span>
|
||||
<input
|
||||
ref="toInputEl"
|
||||
class="addr-input"
|
||||
:value="toInput"
|
||||
placeholder="email@example.com"
|
||||
@input="toInput = ($event.target as HTMLInputElement).value"
|
||||
@keydown="onAddrKeydown($event, 'to')"
|
||||
@blur="commitInput('to')"
|
||||
/>
|
||||
</div>
|
||||
<div class="field-extras">
|
||||
<button v-if="!showCc" class="extra-btn" @click="showCc = true">Копия</button>
|
||||
<button v-if="!showBcc" class="extra-btn" @click="showBcc = true">Скрытая</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Cc -->
|
||||
<div v-if="showCc" class="field-row">
|
||||
<span class="field-label">Копия</span>
|
||||
<div class="addr-wrap">
|
||||
<span v-for="(addr, i) in cc" :key="i" class="addr-token">
|
||||
{{ addr }}<button class="token-x" @click="removeAddr('cc', i)">×</button>
|
||||
</span>
|
||||
<input
|
||||
class="addr-input"
|
||||
:value="ccInput"
|
||||
placeholder="email@example.com"
|
||||
@input="ccInput = ($event.target as HTMLInputElement).value"
|
||||
@keydown="onAddrKeydown($event, 'cc')"
|
||||
@blur="commitInput('cc')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Bcc -->
|
||||
<div v-if="showBcc" class="field-row">
|
||||
<span class="field-label">Скрытая</span>
|
||||
<div class="addr-wrap">
|
||||
<span v-for="(addr, i) in bcc" :key="i" class="addr-token">
|
||||
{{ addr }}<button class="token-x" @click="removeAddr('bcc', i)">×</button>
|
||||
</span>
|
||||
<input
|
||||
class="addr-input"
|
||||
:value="bccInput"
|
||||
placeholder="email@example.com"
|
||||
@input="bccInput = ($event.target as HTMLInputElement).value"
|
||||
@keydown="onAddrKeydown($event, 'bcc')"
|
||||
@blur="commitInput('bcc')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Subject -->
|
||||
<div class="field-row">
|
||||
<span class="field-label">Тема</span>
|
||||
<input
|
||||
class="subject-input"
|
||||
v-model="subject"
|
||||
placeholder="Тема письма"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Body -->
|
||||
<textarea
|
||||
ref="bodyEl"
|
||||
class="compose-body"
|
||||
v-model="body"
|
||||
placeholder="Напишите сообщение…"
|
||||
/>
|
||||
|
||||
<!-- Footer -->
|
||||
<div class="compose-footer">
|
||||
<div v-if="sendError" class="send-error">{{ sendError }}</div>
|
||||
<div class="footer-row">
|
||||
<span class="shortcut-hint">Ctrl+Enter — отправить</span>
|
||||
<div class="footer-btns">
|
||||
<button class="btn-cancel" @click="window.close()">Отмена</button>
|
||||
<button
|
||||
class="btn-send"
|
||||
:disabled="sending"
|
||||
@click="handleSend"
|
||||
>
|
||||
<span v-if="sending" class="spinner-sm" />
|
||||
<span v-else class="send-icon"><AppIcon name="send" :size="13" /></span>
|
||||
{{ sending ? 'Отправка…' : 'Отправить' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.compose-page {
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background:
|
||||
radial-gradient(ellipse 70% 50% at 20% 10%, rgba(168,230,0,0.06) 0%, transparent 65%),
|
||||
radial-gradient(ellipse 50% 60% at 80% 85%, rgba(0,100,220,0.05) 0%, transparent 65%),
|
||||
#09090e;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* ── Top bar ─────────────────────────────────────────────── */
|
||||
.compose-bar {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 10px 16px 9px;
|
||||
border-bottom: 1px solid rgba(255,255,255,0.07);
|
||||
background:
|
||||
linear-gradient(180deg, rgba(255,255,255,0.055) 0%, rgba(255,255,255,0.015) 100%),
|
||||
rgba(10,10,18,0.70);
|
||||
backdrop-filter: blur(24px);
|
||||
-webkit-backdrop-filter: blur(24px);
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255,255,255,0.10),
|
||||
0 1px 0 rgba(0,0,0,0.20);
|
||||
}
|
||||
|
||||
.compose-bar-title {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.compose-bar-from {
|
||||
font-size: 11.5px;
|
||||
color: var(--text-muted);
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
/* ── Fields ──────────────────────────────────────────────── */
|
||||
.compose-fields {
|
||||
flex-shrink: 0;
|
||||
border-bottom: 1px solid rgba(255,255,255,0.06);
|
||||
}
|
||||
|
||||
.field-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
padding: 5px 16px;
|
||||
border-bottom: 1px solid rgba(255,255,255,0.04);
|
||||
min-height: 34px;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.field-row:last-child { border-bottom: none; }
|
||||
|
||||
.field-label {
|
||||
flex-shrink: 0;
|
||||
width: 58px;
|
||||
font-size: 10.5px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
color: var(--text-muted);
|
||||
padding-top: 7px;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
/* Token address input */
|
||||
.addr-wrap {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 3px 0;
|
||||
}
|
||||
|
||||
.addr-token {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
padding: 2px 6px 2px 8px;
|
||||
border-radius: 99px;
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
background: rgba(255,255,255,0.08);
|
||||
border: 1px solid rgba(255,255,255,0.11);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.token-x {
|
||||
font-size: 13px;
|
||||
line-height: 1;
|
||||
color: var(--text-muted);
|
||||
padding: 0 1px;
|
||||
cursor: pointer;
|
||||
transition: color var(--transition-fast);
|
||||
}
|
||||
.token-x:hover { color: var(--danger); }
|
||||
|
||||
.addr-input {
|
||||
flex: 1;
|
||||
min-width: 120px;
|
||||
background: none;
|
||||
border: none;
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
color: var(--text-primary);
|
||||
font-size: 13px;
|
||||
padding: 4px 0;
|
||||
caret-color: var(--accent);
|
||||
backdrop-filter: none;
|
||||
-webkit-backdrop-filter: none;
|
||||
}
|
||||
|
||||
.addr-input::placeholder { color: rgba(255,255,255,0.18); }
|
||||
|
||||
.field-extras {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
padding-top: 6px;
|
||||
}
|
||||
|
||||
.extra-btn {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
padding: 1px 6px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: color var(--transition-fast), background var(--transition-fast);
|
||||
}
|
||||
.extra-btn:hover {
|
||||
color: var(--text-secondary);
|
||||
background: rgba(255,255,255,0.06);
|
||||
}
|
||||
|
||||
/* Subject input */
|
||||
.subject-input {
|
||||
flex: 1;
|
||||
background: none;
|
||||
border: none;
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
color: var(--text-primary);
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
padding: 6px 0;
|
||||
caret-color: var(--accent);
|
||||
backdrop-filter: none;
|
||||
-webkit-backdrop-filter: none;
|
||||
}
|
||||
.subject-input::placeholder { color: rgba(255,255,255,0.18); font-weight:400; }
|
||||
|
||||
/* ── Body ────────────────────────────────────────────────── */
|
||||
.compose-body {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
background: none;
|
||||
border: none;
|
||||
outline: none;
|
||||
resize: none;
|
||||
color: var(--text-primary);
|
||||
font-size: 13px;
|
||||
line-height: 1.65;
|
||||
padding: 14px 16px;
|
||||
caret-color: var(--accent);
|
||||
font-family: inherit;
|
||||
min-height: 0;
|
||||
box-shadow: none;
|
||||
backdrop-filter: none;
|
||||
-webkit-backdrop-filter: none;
|
||||
}
|
||||
.compose-body::placeholder { color: rgba(255,255,255,0.16); }
|
||||
|
||||
/* ── Footer ──────────────────────────────────────────────── */
|
||||
.compose-footer {
|
||||
flex-shrink: 0;
|
||||
padding: 10px 16px 14px;
|
||||
border-top: 1px solid rgba(255,255,255,0.06);
|
||||
background: rgba(0,0,0,0.14);
|
||||
}
|
||||
|
||||
.send-error {
|
||||
font-size: 12px;
|
||||
color: var(--danger);
|
||||
margin-bottom: 8px;
|
||||
padding: 6px 10px;
|
||||
background: rgba(255,60,60,0.10);
|
||||
border: 1px solid rgba(255,60,60,0.20);
|
||||
border-radius: 7px;
|
||||
}
|
||||
|
||||
.footer-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.shortcut-hint {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.footer-btns {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.btn-cancel {
|
||||
padding: 7px 16px;
|
||||
border-radius: var(--radius-full);
|
||||
font-size: 13px;
|
||||
color: var(--text-muted);
|
||||
background: rgba(255,255,255,0.05);
|
||||
border: 1px solid rgba(255,255,255,0.09);
|
||||
cursor: pointer;
|
||||
transition: background var(--transition-fast), color var(--transition-fast);
|
||||
}
|
||||
.btn-cancel:hover {
|
||||
background: rgba(255,255,255,0.09);
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.btn-send {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
padding: 7px 22px;
|
||||
border-radius: var(--radius-full);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--accent-text);
|
||||
background: linear-gradient(
|
||||
to bottom,
|
||||
color-mix(in srgb, var(--accent) 88%, white 12%) 0%,
|
||||
var(--accent) 100%
|
||||
);
|
||||
border: none;
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255,255,255,0.35),
|
||||
0 2px 10px color-mix(in srgb, var(--accent) 35%, transparent);
|
||||
cursor: pointer;
|
||||
transition:
|
||||
background var(--transition-fast),
|
||||
box-shadow var(--transition-fast),
|
||||
transform var(--transition-fast),
|
||||
opacity var(--transition-fast);
|
||||
}
|
||||
.btn-send:hover:not(:disabled) {
|
||||
background: linear-gradient(
|
||||
to bottom,
|
||||
color-mix(in srgb, var(--accent-hover) 88%, white 12%) 0%,
|
||||
var(--accent-hover) 100%
|
||||
);
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255,255,255,0.40),
|
||||
0 4px 18px color-mix(in srgb, var(--accent) 45%, transparent);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
.btn-send:active:not(:disabled) { transform: translateY(0); }
|
||||
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }
|
||||
|
||||
.send-icon { display: flex; align-items: center; }
|
||||
|
||||
.spinner-sm {
|
||||
width: 13px; height: 13px;
|
||||
border: 2px solid rgba(255,255,255,0.3);
|
||||
border-top-color: #fff;
|
||||
border-radius: 50%;
|
||||
animation: spin 0.7s linear infinite;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
@keyframes spin { to { transform: rotate(360deg); } }
|
||||
</style>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import type { AccountConfig } from './account'
|
||||
import type { FolderListResult, MessageListResult } from './provider'
|
||||
import type { MessageBody, MessageFlags, MessageEnvelope, ComposeData } from './message'
|
||||
import type { MessageBody, MessageFlags, MessageEnvelope, ComposeData, ComposeSession } from './message'
|
||||
|
||||
export interface IpcChannelMap {
|
||||
'accounts:list': [void, AccountConfig[]]
|
||||
|
|
@ -41,6 +41,10 @@ export interface IpcChannelMap {
|
|||
'messages:poll': [{ accountId: string }, void]
|
||||
'messages:search': [{ accountId: string; query: string; limit: number }, MessageEnvelope[]]
|
||||
'messages:send': [{ accountId: string; compose: ComposeData }, { success: boolean; error?: string }]
|
||||
|
||||
'compose:open': [ComposeSession, void]
|
||||
'compose:getData': [void, ComposeSession | null]
|
||||
|
||||
'app:setZoom': [{ factor: number }, void]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,3 +57,11 @@ export interface ComposeData {
|
|||
replyToMessageId?: string // ID письма в store (чтобы поставить \Answered)
|
||||
replyToFolderId?: string
|
||||
}
|
||||
|
||||
// Данные, передаваемые в отдельное compose-окно через IPC
|
||||
export interface ComposeSession extends ComposeData {
|
||||
accountId: string
|
||||
accountEmail: string
|
||||
accountLabel: string
|
||||
mode: 'new' | 'reply' | 'replyAll' | 'forward'
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue