Merge branch 'master' of https://gitee.com/v_cms/zyt
This commit is contained in:
@@ -21,6 +21,7 @@ use app\common\enum\ExportEnum;
|
||||
use app\common\lists\BaseDataLists;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
use app\common\lists\ListsExtendInterface;
|
||||
use think\facade\Config;
|
||||
use think\Response;
|
||||
use think\response\Json;
|
||||
use think\exception\HttpResponseException;
|
||||
@@ -120,12 +121,16 @@ class JsonService
|
||||
{
|
||||
//获取导出信息
|
||||
if ($lists->export == ExportEnum::INFO && $lists instanceof ListsExcelInterface) {
|
||||
self::relaxLimitsForExcelExport();
|
||||
|
||||
return self::data($lists->excelInfo());
|
||||
}
|
||||
|
||||
//获取导出文件的下载链接
|
||||
if ($lists->export == ExportEnum::EXPORT && $lists instanceof ListsExcelInterface) {
|
||||
self::relaxLimitsForExcelExport();
|
||||
$exportDownloadUrl = $lists->createExcel($lists->setExcelFields(), $lists->lists());
|
||||
|
||||
return self::success('', ['url' => $exportDownloadUrl], 2);
|
||||
}
|
||||
|
||||
@@ -141,4 +146,21 @@ class JsonService
|
||||
}
|
||||
return self::success('', $data, 1, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Excel 导出:拉数 + PhpSpreadsheet 易超过默认 max_execution_time=30
|
||||
*/
|
||||
private static function relaxLimitsForExcelExport(): void
|
||||
{
|
||||
@set_time_limit(0);
|
||||
$max = Config::get('project.lists.export_max_execution_time', 600);
|
||||
$max = is_numeric($max) ? (int) $max : 600;
|
||||
if ($max > 0) {
|
||||
@ini_set('max_execution_time', (string) $max);
|
||||
}
|
||||
$mem = Config::get('project.lists.export_memory_limit', '512M');
|
||||
if (is_string($mem) && $mem !== '') {
|
||||
@ini_set('memory_limit', $mem);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user