From 785f0996462a1940a34e63c9aa80a0e1ae72055a Mon Sep 17 00:00:00 2001 From: hongfs Date: Wed, 19 Jan 2022 05:15:18 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9F=90=E4=BA=9B=E7=89=B9?= =?UTF-8?q?=E6=AE=8A=E6=83=85=E5=86=B5=E4=B8=8B=E4=BC=9A=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E9=87=8D=E6=96=B0=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/controller/Api.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/application/common/controller/Api.php b/application/common/controller/Api.php index 87e9c6f74..418313f32 100644 --- a/application/common/controller/Api.php +++ b/application/common/controller/Api.php @@ -19,6 +19,11 @@ use think\Validate; */ class Api { + /** + * 是否已初始化 + * @var bool + */ + protected static $has_init = false; /** * @var Request Request 实例 @@ -71,6 +76,12 @@ class Api */ public function __construct(Request $request = null) { + if(self::$has_init) { + return true; + } + + self::$has_init = true; + $this->request = is_null($request) ? Request::instance() : $request; // 控制器初始化 -- Gitee