Update connections.controller.ts

This commit is contained in:
Baobhan Sith
2025-05-10 16:58:18 +08:00
parent 63b69fad54
commit 5b6a68b636
@@ -219,14 +219,14 @@ export const testUnsavedConnection = async (req: Request, res: Response): Promis
*/ */
export const exportConnections = async (req: Request, res: Response): Promise<void> => { export const exportConnections = async (req: Request, res: Response): Promise<void> => {
try { try {
const exportedData = await ImportExportService.exportConnections(); const exportedData = await ImportExportService.exportConnectionsAsEncryptedZip();
// 设置响应头,提示浏览器下载文件 // 设置响应头,提示浏览器下载文件
const timestamp = new Date().toISOString().replace(/[:.]/g, '-'); const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
const filename = `nexus-terminal-connections-${timestamp}.json`; const filename = `nexus-terminal-connections-${timestamp}.zip`;
res.setHeader('Content-Disposition', `attachment; filename="${filename}"`); res.setHeader('Content-Disposition', `attachment; filename="${filename}"`);
res.setHeader('Content-Type', 'application/json'); res.setHeader('Content-Type', 'application/zip');
res.status(200).json(exportedData); res.status(200).send(exportedData);
} catch (error: any) { } catch (error: any) {
console.error('Controller: 导出连接时发生错误:', error); console.error('Controller: 导出连接时发生错误:', error);