Настройки аккаунта подтягиваются
This commit is contained in:
parent
9378455b61
commit
0237df328e
2 changed files with 16 additions and 9 deletions
|
|
@ -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 }> {
|
||||
|
|
|
|||
|
|
@ -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<void> {
|
|||
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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue