调整菜单选中
parent
64f1d000b8
commit
3036a54042
|
|
@ -125,26 +125,45 @@ class Menu
|
||||||
if (empty($path)) {
|
if (empty($path)) {
|
||||||
$path = request()->path();
|
$path = request()->path();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($item['children'])) {
|
if (empty($item['children'])) {
|
||||||
if (empty($item['uri'])) {
|
if (empty($item['uri'])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
$_uri = str_replace('/admin', '', $this->getPath($item['uri']));
|
||||||
return trim($this->getPath($item['uri']), '/') == $path;
|
if (empty($_uri) && $path !== 'admin') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (strpos($path, '?')) {
|
||||||
|
$path = substr($path, 0, strpos($path, '?'));
|
||||||
|
}
|
||||||
|
if (strpos($_uri, '?')) {
|
||||||
|
$_uri = substr($_uri, 0, strpos($_uri, '?'));
|
||||||
|
}
|
||||||
|
return strpos('/'.$path, $_uri) !== false;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($item['children'] as $v) {
|
foreach ($item['children'] as $v) {
|
||||||
if ($path == trim($this->getPath($v['uri']), '/')) {
|
//针对大于2级的菜单
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (! empty($v['children'])) {
|
if (! empty($v['children'])) {
|
||||||
if ($this->isActive($v, $path)) {
|
if ($this->isActive($v, $path)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
$_uri = str_replace('/admin', '', $this->getPath($v['uri']));
|
||||||
|
if (empty($_uri) && $path !== 'admin') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (strpos($path, '?')) {
|
||||||
|
$path = substr($path, 0, strpos($path, '?'));
|
||||||
|
}
|
||||||
|
if (strpos($_uri, '?')) {
|
||||||
|
$_uri = substr($_uri, 0, strpos($_uri, '?'));
|
||||||
|
}
|
||||||
|
if (strpos('/'.$path, $_uri) !== false) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue