diff --git a/application/common.php b/application/common.php index a93d329..60ed700 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 904ff9b..2867a5d 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 20fccf6..e818dfe 100755 --- a/application/common/view/tpl/think_exception.tpl +++ b/application/common/view/tpl/think_exception.tpl @@ -1,6 +1,6 @@ <?php $cdnurl = function_exists('config') ? config('view_replace_str.__CDN__') : ''; -$publicurl = function_exists('config') ? config('view_replace_str.__PUBLIC__') : '/'; +$publicurl = function_exists('config') ? (config('view_replace_str.__PUBLIC__')?:'/') : '/'; $debug = function_exists('config') ? config('app_debug') : false; $lang = [ @@ -98,4 +98,4 @@ $langSet == 'en' && $lang = array_combine(array_keys($lang), array_keys($lang)); </div> </div> </body> -</html> \ No newline at end of file +</html> diff --git a/application/index/view/common/sidenav.html b/application/index/view/common/sidenav.html index 8593b7c..6ab9362 100644 --- a/application/index/view/common/sidenav.html +++ b/application/index/view/common/sidenav.html @@ -2,10 +2,10 @@ {:hook('user_sidenav_before')} <ul class="list-group"> <li class="list-group-heading">{:__('Member center')}</li> - <li class="list-group-item {:$config['actionname']=='index'?'active':''}"> <a href="{:url('user/index')}"><i class="fa fa-user-circle fa-fw"></i> {:__('User center')}</a> </li> - <li class="list-group-item {:$config['actionname']=='profile'?'active':''}"> <a href="{:url('user/profile')}"><i class="fa fa-user-o fa-fw"></i> {:__('Profile')}</a> </li> - <li class="list-group-item {:$config['actionname']=='changepwd'?'active':''}"> <a href="{:url('user/changepwd')}"><i class="fa fa-key fa-fw"></i> {:__('Change password')}</a> </li> - <li class="list-group-item {:$config['actionname']=='logout'?'active':''}"> <a href="{:url('user/logout')}"><i class="fa fa-sign-out fa-fw"></i> {:__('Sign out')}</a> </li> + <li class="list-group-item {:check_nav_active('user/index')}"> <a href="{:url('user/index')}"><i class="fa fa-user-circle fa-fw"></i> {:__('User center')}</a> </li> + <li class="list-group-item {:check_nav_active('user/profile')}"> <a href="{:url('user/profile')}"><i class="fa fa-user-o fa-fw"></i> {:__('Profile')}</a> </li> + <li class="list-group-item {:check_nav_active('user/changepwd')}"> <a href="{:url('user/changepwd')}"><i class="fa fa-key fa-fw"></i> {:__('Change password')}</a> </li> + <li class="list-group-item {:check_nav_active('user/logout')}"> <a href="{:url('user/logout')}"><i class="fa fa-sign-out fa-fw"></i> {:__('Sign out')}</a> </li> </ul> {:hook('user_sidenav_after')} -</div> \ No newline at end of file +</div>