mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-05 17:42:49 +08:00
feat: 实现后台请求兼容接口的模式
This commit is contained in:
@@ -2,8 +2,43 @@
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user