Compare commits
No commits in common. "213868819b3c8a5fbfa13d35d47366976e2aecdd" and "67e63c76a6081191ada8d2421e043ffa2b16f6fe" have entirely different histories.
213868819b
...
67e63c76a6
2 changed files with 9 additions and 16 deletions
|
|
@ -51,15 +51,10 @@ export class AccountManager {
|
||||||
|
|
||||||
getAccounts(): AccountConfig[] {
|
getAccounts(): AccountConfig[] {
|
||||||
const accounts = this.store.get('accounts', [])
|
const accounts = this.store.get('accounts', [])
|
||||||
return accounts.map((account): AccountConfig => {
|
return accounts.map((acc) => ({
|
||||||
const raw: string | undefined = this.credentialStore.get(account.id)
|
...acc,
|
||||||
if (!raw) throw new Error(`Настройки подключения аккаунта ${account.id} не найдены`)
|
credentials: {} as AccountConfig['credentials']
|
||||||
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 }> {
|
||||||
|
|
|
||||||
|
|
@ -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('') // Пустое поле сохраняет текущий пароль
|
const password = ref('') // empty = keep existing
|
||||||
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 ?? creds.host.replace(/^imap\./i, 'smtp.'))
|
const smtpHost = ref(creds.smtpHost ?? '')
|
||||||
const smtpPort = ref(creds.smtpPort ?? 587)
|
const smtpPort = ref(creds.smtpPort ?? 587)
|
||||||
const smtpSecure = ref(creds.smtpSecure ?? smtpPort.value === 465)
|
const smtpSecure = ref(creds.smtpSecure ?? false)
|
||||||
const smtpAllowSelfSigned = ref(creds.smtpAllowSelfSigned ?? false)
|
const smtpAllowSelfSigned = ref(creds.smtpAllowSelfSigned ?? false)
|
||||||
|
|
||||||
// ── Testing checklist ─────────────────────────────────────────────────────
|
// ── Testing checklist ─────────────────────────────────────────────────────
|
||||||
|
|
@ -53,21 +53,19 @@ 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, // Backend восстанавливает пароль для пустого поля
|
password: password.value, // empty → backend restores existing
|
||||||
...(smtpHost.value ? {
|
...(smtpHost.value ? {
|
||||||
smtpHost: smtpHost.value,
|
smtpHost: smtpHost.value,
|
||||||
smtpPort: smtpPort.value,
|
smtpPort: smtpPort.value,
|
||||||
smtpSecure: smtpSecure.value,
|
smtpSecure: smtpSecure.value,
|
||||||
smtpAllowSelfSigned: smtpAllowSelfSigned.value
|
...(smtpAllowSelfSigned.value ? { smtpAllowSelfSigned: true } : {})
|
||||||
} : {})
|
} : {})
|
||||||
}
|
}
|
||||||
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,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue