From 88fa46da4422c03149de95e0350a0066b8657262 Mon Sep 17 00:00:00 2001 From: cshaptx4869 <994774638@qq.com> Date: Wed, 1 Mar 2023 10:56:39 +0800 Subject: [PATCH] =?UTF-8?q?Add:=20=E5=A2=9E=E5=8A=A0=E5=90=91js=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=BC=A0=E9=80=92=E5=8F=98=E9=87=8F=E7=9A=84=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/view/layout/default.html | 1 + app/common/controller/AdminController.php | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/app/admin/view/layout/default.html b/app/admin/view/layout/default.html index 6ead6f45..c606a89c 100644 --- a/app/admin/view/layout/default.html +++ b/app/admin/view/layout/default.html @@ -21,6 +21,7 @@ VERSION: "{$version|default='1.0.0'}", CSRF_TOKEN: "{:token()}", }; + window.$variables = {$jsVariables|raw|default='null'}; diff --git a/app/common/controller/AdminController.php b/app/common/controller/AdminController.php index 06bf5fc8..beaa6754 100644 --- a/app/common/controller/AdminController.php +++ b/app/common/controller/AdminController.php @@ -103,6 +103,16 @@ protected function initialize() $this->checkAuth(); } + /** + * 设置js变量 + * @param array $data + * @return mixed + */ + public function setJsVariables(array $data = []) + { + return $this->assign('jsVariables', json_encode($data)); + } + /** * 模板变量赋值 * @param string|array $name 模板变量