Files
ulthon_admin/extend/base/common/provider/RequestBase.php
2025-03-10 18:06:51 +08:00

45 lines
787 B
PHP

<?php
namespace base\common\provider;
use think\facade\Config;
// 应用请求对象类
class RequestBase extends \think\Request
{
protected $filter = [];
/**
* 当前是否JSON请求
* @return bool
*/
public function isJson(): bool
{
$acceptType = $this->type();
$is_json = str_contains($acceptType, 'json');
if (!$is_json) {
return false;
}
if (!Config::get('app.auto_parse_api')) {
return true;
}
if ($this->has('get_page_data')) {
return false;
}
return true;
}
/**
* 仅通过实际请求参数判断请求
*
* @return bool
*/
public function isJsonPure()
{
return parent::isJson();
}
}