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 +