2026-03-17 13:17:02 +08:00

21 lines
716 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { apiClient } from "./client";
/**
* Export batch cards in specified format
* @param batchId - The ID of the batch to export
* @param format - The export format (xlsx or csv)
* @returns - The exported file data
*/
export async function exportBatchCards(batchId: number, format: 'xlsx' | 'csv'): Promise<Blob | string> {
try {
const response = await apiClient.get(`/card/batches/${batchId}/export/${format}/`, {
responseType: format === 'xlsx' ? 'blob' : 'text',
// 注意不需要手动添加token拦截器会自动处理
});
return response.data;
} catch (error) {
console.error(`导出批次卡片失败 (格式: ${format}):`, error);
throw error;
}
}