Compare commits

...

2 commits

Author SHA1 Message Date
r.rasputin
213868819b Merge remote-tracking branch 'origin/master'
All checks were successful
Release / release (push) Successful in 3m19s
2026-11-13 14:33:12 +07:00
r.rasputin
0237df328e Настройки аккаунта подтягиваются 2026-11-13 14:32:11 +07:00
2 changed files with 16 additions and 9 deletions

View file

@ -51,10 +51,15 @@ export class AccountManager {
getAccounts(): AccountConfig[] { getAccounts(): AccountConfig[] {
const accounts = this.store.get('accounts', []) const accounts = this.store.get('accounts', [])
return accounts.map((acc) => ({ return accounts.map((account): AccountConfig => {
...acc, const raw: string | undefined = this.credentialStore.get(account.id)
credentials: {} as AccountConfig['credentials'] 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 }> { async addAccount(config: AccountConfig): Promise<{ success: boolean; error?: string }> {

View file

@ -16,16 +16,16 @@ const creds = props.account.credentials as ImapCredentials
// ── Fields ──────────────────────────────────────────────────────────────── // ── Fields ────────────────────────────────────────────────────────────────
const email = ref(creds.username ?? props.account.email) const email = ref(creds.username ?? props.account.email)
const password = ref('') // empty = keep existing const password = ref('') // Пустое поле сохраняет текущий пароль
const label = ref(props.account.label ?? '') const label = ref(props.account.label ?? '')
const imapHost = ref(creds.host ?? '') const imapHost = ref(creds.host ?? '')
const imapPort = ref(creds.port ?? 993) const imapPort = ref(creds.port ?? 993)
const imapSecure = ref(creds.secure ?? true) 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 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) const smtpAllowSelfSigned = ref(creds.smtpAllowSelfSigned ?? false)
// ── Testing checklist ───────────────────────────────────────────────────── // ── Testing checklist ─────────────────────────────────────────────────────
@ -53,19 +53,21 @@ async function handleSubmit(): Promise<void> {
error.value = '' error.value = ''
const credentials: ImapCredentials = { const credentials: ImapCredentials = {
...creds,
host: imapHost.value, host: imapHost.value,
port: imapPort.value, port: imapPort.value,
secure: imapSecure.value, secure: imapSecure.value,
username: email.value, username: email.value,
password: password.value, // empty → backend restores existing password: password.value, // Backend восстанавливает пароль для пустого поля
...(smtpHost.value ? { ...(smtpHost.value ? {
smtpHost: smtpHost.value, smtpHost: smtpHost.value,
smtpPort: smtpPort.value, smtpPort: smtpPort.value,
smtpSecure: smtpSecure.value, smtpSecure: smtpSecure.value,
...(smtpAllowSelfSigned.value ? { smtpAllowSelfSigned: true } : {}) smtpAllowSelfSigned: smtpAllowSelfSigned.value
} : {}) } : {})
} }
const config: AccountConfig = { const config: AccountConfig = {
...props.account,
id: props.account.id, id: props.account.id,
type: AccountType.IMAP, type: AccountType.IMAP,
label: label.value || email.value, label: label.value || email.value,