From 9ddcb1953fa451f5eedc98b24e7edad38835e9e5 Mon Sep 17 00:00:00 2001 From: Karson Date: Wed, 19 Aug 2020 22:23:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BC=9A=E5=91=98=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E8=BE=B9=E6=A0=8F=E9=AB=98=E4=BA=AE=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E6=96=B9=E6=B3=95=20=E4=BC=98=E5=8C=96=E8=B7=A8=E5=9F=9F?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common.php | 17 +++++++++++++++-- application/common/controller/Api.php | 2 +- application/common/view/tpl/think_exception.tpl | 4 ++-- application/index/view/common/sidenav.html | 10 +++++----- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/application/common.php b/application/common.php index a93d3292..60ed7005 100755 --- a/application/common.php +++ b/application/common.php @@ -363,11 +363,24 @@ if (!function_exists('hsv2rgb')) { } } -if (!function_exists('cors_request_check')) { +if (!function_exists('check_nav_active')) { /** * 跨域检测 */ - function cors_request_check() + function check_nav_active($url, $classname = 'active') + { + $auth = \app\common\library\Auth::instance(); + $requestUrl = $auth->getRequestUri(); + $url = ltrim($url, '/'); + return $requestUrl === str_replace(".", "/", $url) ? $classname : ''; + } +} + +if (!function_exists('check_cors_request')) { + /** + * 跨域检测 + */ + function check_cors_request() { if (isset($_SERVER['HTTP_ORIGIN']) && $_SERVER['HTTP_ORIGIN']) { $info = parse_url($_SERVER['HTTP_ORIGIN']); diff --git a/application/common/controller/Api.php b/application/common/controller/Api.php index 904ff9bd..2867a5d9 100644 --- a/application/common/controller/Api.php +++ b/application/common/controller/Api.php @@ -92,7 +92,7 @@ class Api protected function _initialize() { //跨域请求检测 - cors_request_check(); + check_cors_request(); //移除HTML标签 $this->request->filter('trim,strip_tags,htmlspecialchars'); diff --git a/application/common/view/tpl/think_exception.tpl b/application/common/view/tpl/think_exception.tpl index 20fccf65..e818dfe3 100755 --- a/application/common/view/tpl/think_exception.tpl +++ b/application/common/view/tpl/think_exception.tpl @@ -1,6 +1,6 @@ - \ No newline at end of file + diff --git a/application/index/view/common/sidenav.html b/application/index/view/common/sidenav.html index 8593b7c9..6ab93624 100644 --- a/application/index/view/common/sidenav.html +++ b/application/index/view/common/sidenav.html @@ -2,10 +2,10 @@ {:hook('user_sidenav_before')} {:hook('user_sidenav_after')} - \ No newline at end of file +