Menu.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: lts
  5. * Date: 19/9/18
  6. * Time: 下午7:06
  7. */
  8. namespace app\common\constants;
  9. class Menu
  10. {
  11. const MENU_URL_PATH_RECENT = '/index/user/recent';
  12. const MENU_URL_PATH_KEEPREADING = '/index/user/keepReading';
  13. public static $allLinks = [
  14. 1 => [
  15. 'title' => '最近阅读',
  16. 'menu_url' => self::MENU_URL_PATH_RECENT,
  17. ],
  18. 2 => [
  19. 'title' => '男频分类',
  20. 'menu_url' => '/index/category?sex=1',
  21. ],
  22. 3 => [
  23. 'title' => '女频分类',
  24. 'menu_url' => '/index/category?sex=2',
  25. ],
  26. 4 => [
  27. 'title' => '首页',
  28. 'menu_url' => null,
  29. ],
  30. 5 => [
  31. 'title' => '个人中心',
  32. 'menu_url' => '/index/user/index',
  33. ],
  34. 6 => [
  35. 'title' => '充值',
  36. 'menu_url' => '/index/recharge/pay',
  37. ],
  38. 7 => [
  39. 'title' => '搜索',
  40. 'menu_url' => '/index/index/search',
  41. ],
  42. 8 => [
  43. 'title' => '签到',
  44. 'menu_url' => '/index/user/sign',
  45. ],
  46. 9 => [
  47. 'title' => '女频专区',
  48. 'menu_url' => '?type=girl',
  49. ],
  50. 10 => [
  51. 'title' => '男频专区',
  52. 'menu_url' => '?type=boy',
  53. ],
  54. 11 => [
  55. 'title' => '限免专区',
  56. 'menu_url' => '/index/book/list?type=free',
  57. ],
  58. ];
  59. /**
  60. * 判断相对路径是否为菜单链接
  61. * @param $pathQuery
  62. * @return bool
  63. */
  64. public static function pathQueryIsMenu($pathQuery)
  65. {
  66. foreach (self::$allLinks as $link) {
  67. if (empty($link['menu_url'])) {
  68. continue;
  69. }
  70. if (strpos($pathQuery, $link['menu_url']) !== false) {
  71. return true;
  72. }
  73. }
  74. return false;
  75. }
  76. }