- variables.css: full glass token system (--glass-bg-*, --glass-border, --glass-specular, --blur-sm/md/lg/xl), transparent --bg-primary, rgba-based surface tokens, deeper base color #09090e - base.css: rich gradient background with subtle lime/blue/purple radial gradients visible through glass panels - AppShell: all 4 panels get backdrop-filter blur + rgba background; account-bar/folder/message/preview each at different opacity levels; resize handle transparent with accent glow on hover - StatusBar: glass panel with backdrop-filter and specular highlight - AccountSwitcher: avatar accent ring with glow (box-shadow triple layer), hover brightens avatar - FolderTreeItem: active item gets accent-tinted glass + specular box-shadow + glowing left indicator bar - MessageList: header gets backdrop-filter; bulk-actions bar accent-tinted glass; buttons styled as glass chips with borders - MessageListItem: transparent base, glass hover, accent-tinted selected state with inset specular highlight - MessageHeader: glass header with backdrop-filter - MessagePreview: empty icon more subtle - AddAccountDialog: overlay with blur, dialog uses strong blur (60px) + glass-specular + deep shadow - SettingsView: transparent background, glass cards for account items, setting rows, swipe demo panels - MessageBody: updated iframe background to #0d0d11 matching base Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
292 lines
7 KiB
Vue
292 lines
7 KiB
Vue
<script setup lang="ts">
|
||
import { ref, computed } from 'vue'
|
||
import { AccountType } from '@shared/types/account'
|
||
import type { AccountConfig, ImapCredentials } from '@shared/types/account'
|
||
import { useAccountsStore } from '../../stores/accounts.store'
|
||
|
||
const emit = defineEmits<{
|
||
close: []
|
||
}>()
|
||
|
||
const accountsStore = useAccountsStore()
|
||
|
||
const step = ref<'credentials' | 'testing'>('credentials')
|
||
const error = ref('')
|
||
const testing = ref(false)
|
||
|
||
const imapHost = ref('')
|
||
const imapPort = ref(993)
|
||
const imapSecure = ref(true)
|
||
const imapUsername = ref('')
|
||
const imapPassword = ref('')
|
||
const imapLabel = ref('')
|
||
|
||
function generateId(): string {
|
||
return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
|
||
}
|
||
|
||
async function handleSubmit(): Promise<void> {
|
||
testing.value = true
|
||
error.value = ''
|
||
step.value = 'testing'
|
||
|
||
try {
|
||
const credentials: ImapCredentials = {
|
||
host: imapHost.value,
|
||
port: imapPort.value,
|
||
secure: imapSecure.value,
|
||
username: imapUsername.value,
|
||
password: imapPassword.value
|
||
}
|
||
const config: AccountConfig = {
|
||
id: generateId(),
|
||
type: AccountType.IMAP,
|
||
label: imapLabel.value || imapUsername.value,
|
||
email: imapUsername.value,
|
||
credentials
|
||
}
|
||
|
||
const testResult = await accountsStore.testConnection(config)
|
||
if (!testResult.success) {
|
||
error.value = testResult.error ?? 'Ошибка подключения'
|
||
step.value = 'credentials'
|
||
return
|
||
}
|
||
|
||
const addResult = await accountsStore.addAccount(config)
|
||
if (addResult.success) {
|
||
emit('close')
|
||
} else {
|
||
error.value = addResult.error ?? 'Не удалось добавить аккаунт'
|
||
step.value = 'credentials'
|
||
}
|
||
} catch (err) {
|
||
error.value = (err as Error).message
|
||
step.value = 'credentials'
|
||
} finally {
|
||
testing.value = false
|
||
}
|
||
}
|
||
|
||
const isFormValid = computed(() => imapHost.value && imapUsername.value && imapPassword.value)
|
||
</script>
|
||
|
||
<template>
|
||
<div class="dialog-overlay" @click.self="emit('close')">
|
||
<div class="dialog">
|
||
<div class="dialog-header">
|
||
<h2>Добавить аккаунт</h2>
|
||
<button class="close-btn" @click="emit('close')">×</button>
|
||
</div>
|
||
|
||
<!-- Форма учётных данных -->
|
||
<div v-if="step === 'credentials'" class="dialog-body">
|
||
<div v-if="error" class="error-msg">{{ error }}</div>
|
||
|
||
<form @submit.prevent="handleSubmit">
|
||
<div class="form-group">
|
||
<label>Название (необязательно)</label>
|
||
<input v-model="imapLabel" type="text" placeholder="Моя почта" />
|
||
</div>
|
||
<div class="form-row">
|
||
<div class="form-group flex-1">
|
||
<label>IMAP сервер</label>
|
||
<input v-model="imapHost" type="text" placeholder="imap.example.com" required />
|
||
</div>
|
||
<div class="form-group" style="width: 80px">
|
||
<label>Порт</label>
|
||
<input v-model.number="imapPort" type="number" />
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="checkbox-label">
|
||
<input v-model="imapSecure" type="checkbox" />
|
||
Использовать SSL/TLS
|
||
</label>
|
||
</div>
|
||
<div class="form-group">
|
||
<label>Имя пользователя / Email</label>
|
||
<input v-model="imapUsername" type="text" placeholder="user@example.com" required />
|
||
</div>
|
||
<div class="form-group">
|
||
<label>Пароль</label>
|
||
<input v-model="imapPassword" type="password" required />
|
||
</div>
|
||
<button type="submit" class="submit-btn" :disabled="!isFormValid || testing">
|
||
{{ testing ? 'Подключение...' : 'Добавить аккаунт' }}
|
||
</button>
|
||
</form>
|
||
</div>
|
||
|
||
<!-- Состояние проверки -->
|
||
<div v-if="step === 'testing'" class="dialog-body testing-state">
|
||
<div class="spinner" />
|
||
<span>Проверка подключения...</span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<style scoped>
|
||
.dialog-overlay {
|
||
position: fixed;
|
||
inset: 0;
|
||
background: rgba(0, 0, 0, 0.5);
|
||
backdrop-filter: var(--blur-md);
|
||
-webkit-backdrop-filter: var(--blur-md);
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
z-index: 100;
|
||
}
|
||
|
||
.dialog {
|
||
background: rgba(255, 255, 255, 0.06);
|
||
backdrop-filter: var(--blur-xl);
|
||
-webkit-backdrop-filter: var(--blur-xl);
|
||
border: 1px solid var(--glass-border-strong);
|
||
border-radius: var(--radius-xl);
|
||
width: 460px;
|
||
max-height: 80vh;
|
||
overflow-y: auto;
|
||
box-shadow:
|
||
var(--glass-specular),
|
||
var(--shadow-xl),
|
||
0 0 0 0.5px rgba(255, 255, 255, 0.04) inset;
|
||
}
|
||
|
||
.dialog-header {
|
||
display: flex;
|
||
align-items: center;
|
||
padding: 18px 22px;
|
||
border-bottom: 1px solid var(--glass-border);
|
||
gap: 12px;
|
||
}
|
||
|
||
.dialog-header h2 {
|
||
flex: 1;
|
||
font-size: 15px;
|
||
font-weight: 600;
|
||
}
|
||
|
||
.close-btn {
|
||
width: 28px;
|
||
height: 28px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
border-radius: var(--radius-sm);
|
||
font-size: 18px;
|
||
color: var(--text-muted);
|
||
line-height: 1;
|
||
}
|
||
|
||
.close-btn:hover {
|
||
background: var(--bg-hover);
|
||
color: var(--text-primary);
|
||
}
|
||
|
||
.dialog-body {
|
||
padding: 22px;
|
||
}
|
||
|
||
.error-msg {
|
||
padding: 10px 14px;
|
||
background: rgba(244, 71, 71, 0.12);
|
||
border: 1px solid rgba(244, 71, 71, 0.4);
|
||
border-radius: var(--radius-md);
|
||
color: var(--danger);
|
||
font-size: 12px;
|
||
margin-bottom: 18px;
|
||
line-height: 1.5;
|
||
}
|
||
|
||
.form-group {
|
||
margin-bottom: 16px;
|
||
}
|
||
|
||
.form-group label {
|
||
display: block;
|
||
font-size: 11px;
|
||
font-weight: 500;
|
||
color: var(--text-muted);
|
||
margin-bottom: 5px;
|
||
text-transform: uppercase;
|
||
letter-spacing: 0.4px;
|
||
}
|
||
|
||
.form-group input[type="text"],
|
||
.form-group input[type="password"],
|
||
.form-group input[type="number"] {
|
||
width: 100%;
|
||
}
|
||
|
||
.form-row {
|
||
display: flex;
|
||
gap: 12px;
|
||
}
|
||
|
||
.flex-1 {
|
||
flex: 1;
|
||
}
|
||
|
||
.checkbox-label {
|
||
display: flex !important;
|
||
align-items: center;
|
||
gap: 8px;
|
||
cursor: pointer;
|
||
}
|
||
|
||
.checkbox-label input[type="checkbox"] {
|
||
width: auto;
|
||
padding: 0;
|
||
}
|
||
|
||
.submit-btn {
|
||
width: 100%;
|
||
padding: 11px;
|
||
background: var(--accent);
|
||
color: var(--accent-text);
|
||
border-radius: var(--radius-md);
|
||
font-weight: 600;
|
||
font-size: 13px;
|
||
margin-top: 6px;
|
||
transition: background var(--transition-fast), transform var(--transition-fast);
|
||
}
|
||
|
||
.submit-btn:hover:not(:disabled) {
|
||
background: var(--accent-hover);
|
||
transform: translateY(-1px);
|
||
}
|
||
|
||
.submit-btn:active:not(:disabled) {
|
||
transform: translateY(0);
|
||
}
|
||
|
||
.submit-btn:disabled {
|
||
opacity: 0.4;
|
||
cursor: not-allowed;
|
||
}
|
||
|
||
.testing-state {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
gap: 12px;
|
||
padding: 40px 20px;
|
||
color: var(--text-muted);
|
||
}
|
||
|
||
.spinner {
|
||
width: 32px;
|
||
height: 32px;
|
||
border: 3px solid var(--border);
|
||
border-top-color: var(--accent);
|
||
border-radius: 50%;
|
||
animation: spin 0.8s linear infinite;
|
||
}
|
||
|
||
@keyframes spin {
|
||
to { transform: rotate(360deg); }
|
||
}
|
||
</style>
|