Compare commits
2 commits
67e63c76a6
...
213868819b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
213868819b | ||
|
|
0237df328e |
2 changed files with 16 additions and 9 deletions
|
|
@ -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 }> {
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue