From 0237df328eb3c00c0f07f707307a387488df60c9 Mon Sep 17 00:00:00 2001 From: "r.rasputin" Date: Fri, 13 Nov 2026 14:32:11 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=B0=D0=BA=D0=BA=D0=B0=D1=83=D0=BD=D1=82=D0=B0?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=B4=D1=82=D1=8F=D0=B3=D0=B8=D0=B2=D0=B0=D1=8E?= =?UTF-8?q?=D1=82=D1=81=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/services/account-manager.ts | 13 +++++++++---- .../src/components/accounts/EditAccountDialog.vue | 12 +++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/main/services/account-manager.ts b/src/main/services/account-manager.ts index ee37d8e..51cc8c6 100644 --- a/src/main/services/account-manager.ts +++ b/src/main/services/account-manager.ts @@ -51,10 +51,15 @@ export class AccountManager { getAccounts(): AccountConfig[] { const accounts = this.store.get('accounts', []) - return accounts.map((acc) => ({ - ...acc, - credentials: {} as AccountConfig['credentials'] - })) + return accounts.map((account): AccountConfig => { + const raw: string | undefined = this.credentialStore.get(account.id) + if (!raw) throw new Error(`Настройки подключения аккаунта ${account.id} не найдены`) + const credentials: ImapCredentials = JSON.parse(raw) as ImapCredentials + return { + ...account, + credentials: { ...credentials, password: '' } + } + }) } async addAccount(config: AccountConfig): Promise<{ success: boolean; error?: string }> { diff --git a/src/renderer/src/components/accounts/EditAccountDialog.vue b/src/renderer/src/components/accounts/EditAccountDialog.vue index 09c639e..e0fd5b4 100644 --- a/src/renderer/src/components/accounts/EditAccountDialog.vue +++ b/src/renderer/src/components/accounts/EditAccountDialog.vue @@ -16,16 +16,16 @@ const creds = props.account.credentials as ImapCredentials // ── Fields ──────────────────────────────────────────────────────────────── const email = ref(creds.username ?? props.account.email) -const password = ref('') // empty = keep existing +const password = ref('') // Пустое поле сохраняет текущий пароль const label = ref(props.account.label ?? '') const imapHost = ref(creds.host ?? '') const imapPort = ref(creds.port ?? 993) const imapSecure = ref(creds.secure ?? true) -const smtpHost = ref(creds.smtpHost ?? '') +const smtpHost = ref(creds.smtpHost ?? creds.host.replace(/^imap\./i, 'smtp.')) const smtpPort = ref(creds.smtpPort ?? 587) -const smtpSecure = ref(creds.smtpSecure ?? false) +const smtpSecure = ref(creds.smtpSecure ?? smtpPort.value === 465) const smtpAllowSelfSigned = ref(creds.smtpAllowSelfSigned ?? false) // ── Testing checklist ───────────────────────────────────────────────────── @@ -53,19 +53,21 @@ async function handleSubmit(): Promise { error.value = '' const credentials: ImapCredentials = { + ...creds, host: imapHost.value, port: imapPort.value, secure: imapSecure.value, username: email.value, - password: password.value, // empty → backend restores existing + password: password.value, // Backend восстанавливает пароль для пустого поля ...(smtpHost.value ? { smtpHost: smtpHost.value, smtpPort: smtpPort.value, smtpSecure: smtpSecure.value, - ...(smtpAllowSelfSigned.value ? { smtpAllowSelfSigned: true } : {}) + smtpAllowSelfSigned: smtpAllowSelfSigned.value } : {}) } const config: AccountConfig = { + ...props.account, id: props.account.id, type: AccountType.IMAP, label: label.value || email.value,