getKey();
// 调用服务生成下载链接
$result = CleanupService::generateBackupDownloadUrl($backupId);
if (!$result['success']) {
return $this->response()
->error('生成下载链接失败:' . $result['message']);
}
$data = $result['data'];
return $this->response()
->success('下载链接已生成')
->detail("
备份名称:{$data['backup_name']}
文件大小:{$data['file_size']}
过期时间:{$data['expires_at']}
立即下载
");
} catch (\Exception $e) {
return $this->response()
->error('下载失败:' . $e->getMessage());
}
}
/**
* 确认对话框
*/
public function confirm()
{
return [
'确认下载备份?',
'将生成临时下载链接,请及时下载。'
];
}
/**
* 权限检查
*/
public function allowed()
{
$row = $this->row;
return $row->backup_status == 2; // 只有已完成的备份可以下载
}
/**
* 渲染按钮
*/
public function render()
{
return <<
{$this->title}
HTML;
}
}