From ef3ce9f9106989dd7cd8594cb3148e368b5e5866 Mon Sep 17 00:00:00 2001 From: meoacgx Date: Sat, 27 Dec 2025 00:35:13 +0800 Subject: [PATCH] =?UTF-8?q?feat(accounts):=20=E5=AF=BC=E5=87=BA=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7=E5=8C=85=E5=8C=85=E5=90=AB=202fa.txt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/AccountExportService.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/TelegramPanel.Web/Services/AccountExportService.cs b/src/TelegramPanel.Web/Services/AccountExportService.cs index 789ee2c..33d6712 100644 --- a/src/TelegramPanel.Web/Services/AccountExportService.cs +++ b/src/TelegramPanel.Web/Services/AccountExportService.cs @@ -36,7 +36,7 @@ public class AccountExportService await using (var writer = new StreamWriter(readmeStream, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false))) { await writer.WriteLineAsync("Telegram Panel 账号导出包"); - await writer.WriteLineAsync("结构:每个账号一个子文件夹,包含一个 .json + 一个 .session。"); + await writer.WriteLineAsync("结构:每个账号一个子文件夹,包含 .json + .session;如保存了二级密码,则额外包含 2fa.txt。"); await writer.WriteLineAsync("导入:面板 -> 账号 -> 导入账号 -> 压缩包导入(Zip)。"); await writer.WriteLineAsync($"导出时间(UTC):{DateTime.UtcNow:yyyy-MM-dd HH:mm:ss}"); } @@ -86,6 +86,15 @@ public class AccountExportService await writer.WriteAsync(json); } + + var twoFactorPassword = (account.TwoFactorPassword ?? string.Empty).Trim(); + if (!string.IsNullOrWhiteSpace(twoFactorPassword)) + { + var twoFaEntry = zip.CreateEntry($"{safeFolder}/2fa.txt", CompressionLevel.Fastest); + await using var twoFaStream = twoFaEntry.Open(); + await using var twoFaWriter = new StreamWriter(twoFaStream, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); + await twoFaWriter.WriteAsync(twoFactorPassword); + } } catch (Exception ex) {