fix: error when downloading async migration file (#6586)

This commit is contained in:
Katherine 2025-03-28 15:44:45 +08:00 committed by GitHub
parent 28c633e369
commit b86ea5dd61
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -270,14 +270,15 @@ const AsyncTasksButton = (props) => {
onClick={() => { onClick={() => {
const token = app.apiClient.auth.token; const token = app.apiClient.auth.token;
const collection = cm.getCollection(record.title.collection); const collection = cm.getCollection(record.title.collection);
const compiledTitle = compile(collection.title); const compiledTitle = compile(collection?.title);
const suffix = record?.title?.actionType === 'export-attachments' ? '-attachments.zip' : '.xlsx'; const suffix = record?.title?.actionType === 'export-attachments' ? '-attachments.zip' : '.xlsx';
const fileText = `${compiledTitle}${suffix}`; const fileText = `${compiledTitle}${suffix}`;
const filename = encodeURIComponent(fileText); // 避免中文或特殊字符问题 const filename =
record?.title?.actionType !== 'create migration' ? encodeURIComponent(fileText) : null;
const url = app.getApiUrl( const url = app.getApiUrl(
`asyncTasks:fetchFile/${record.taskId}?token=${token}&__appName=${encodeURIComponent( `asyncTasks:fetchFile/${record.taskId}?token=${token}&__appName=${encodeURIComponent(
appInfo?.data?.name || app.name, appInfo?.data?.name || app.name,
)}&filename=${filename}`, )}${filename ? `&filename=${filename}` : ''}`,
); );
window.open(url); window.open(url);
}} }}