zroute.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. use app\http\middleware\InstallMiddleware;
  3. use think\facade\Route;
  4. use think\Response;
  5. /**
  6. * 系统默认路由配置
  7. */
  8. Route::get('install/index', 'InstallController/index');//安装程序
  9. Route::post('install/index', 'InstallController/index');//安装程序
  10. Route::get('install/compiler', 'InstallController/swooleCompiler');//swooleCompiler安装提示
  11. Route::get('upgrade/index', 'UpgradeController/index');
  12. Route::get('up', 'UpgradeVersionController/index');
  13. Route::get('up/render', 'UpgradeVersionController/render');
  14. Route::get('upgrade/upgrade', 'UpgradeController/upgrade');
  15. Route::group('/', function () {
  16. Route::group('install', function () {
  17. Route::miss(function () {
  18. return view(app()->getRootPath() . 'public' . DS . 'install');
  19. });
  20. });
  21. //扫码上传
  22. Route::group('app', function () {
  23. Route::miss(function () {
  24. $pathInfo = request()->pathinfo();
  25. $pathInfoArr = explode('/', $pathInfo);
  26. $admin = $pathInfoArr[0] ?? '';
  27. if ($admin === 'app') {
  28. return view(app()->getRootPath() . 'public' . DS . 'system.html');
  29. } else {
  30. return Response::create()->code(404);
  31. }
  32. });
  33. });
  34. //平台
  35. Route::group(config('admin.admin_prefix'), function () {
  36. Route::miss(function () {
  37. $pathInfo = request()->pathinfo();
  38. $pathInfoArr = explode('/', $pathInfo);
  39. $admin = $pathInfoArr[0] ?? '';
  40. if ($admin === config('admin.admin_prefix')) {
  41. return view(app()->getRootPath() . 'public' . DS . 'system.html');
  42. } else {
  43. return Response::create()->code(404);
  44. }
  45. });
  46. });
  47. //客服
  48. Route::group(config('admin.kefu_prefix'), function () {
  49. Route::miss(function () {
  50. $pathInfo = request()->pathinfo();
  51. $pathInfoArr = explode('/', $pathInfo);
  52. $admin = $pathInfoArr[0] ?? '';
  53. if ($admin === config('admin.kefu_prefix')) {
  54. return view(app()->getRootPath() . 'public' . DS . 'system.html');
  55. } else {
  56. return Response::create()->code(404);
  57. }
  58. });
  59. });
  60. //移动端h5
  61. Route::group('pages', function () {
  62. Route::miss(function () {
  63. $pathInfo = request()->pathinfo();
  64. $pathInfoArr = explode('/', $pathInfo);
  65. $admin = $pathInfoArr[0] ?? '';
  66. if ('pages' === $admin) {
  67. return view(app()->getRootPath() . 'public' . DS . 'index.html');
  68. } else {
  69. return Response::create()->code(404);
  70. }
  71. });
  72. });
  73. //pc
  74. Route::group('home', function () {
  75. Route::miss(function () {
  76. if (request()->isMobile()) {
  77. return redirect(app()->route->buildUrl('/'));
  78. } else {
  79. return view(app()->getRootPath() . 'public' . DS . 'home' . DS . 'index.html');
  80. }
  81. });
  82. });
  83. //供应商
  84. Route::group(config('admin.supplier_prefix'), function () {
  85. Route::miss(function () {
  86. $pathInfo = request()->pathinfo();
  87. $pathInfoArr = explode('/', $pathInfo);
  88. $admin = $pathInfoArr[0] ?? '';
  89. if ($admin === config('admin.supplier_prefix')) {
  90. return view(app()->getRootPath() . 'public' . DS . 'supplier.html');
  91. } else {
  92. return Response::create()->code(404);
  93. }
  94. });
  95. });
  96. //门店
  97. Route::group(config('admin.store_prefix'), function () {
  98. Route::miss(function () {
  99. $pathInfo = request()->pathinfo();
  100. $pathInfoArr = explode('/', $pathInfo);
  101. $admin = $pathInfoArr[0] ?? '';
  102. if ($admin === config('admin.store_prefix')) {
  103. return view(app()->getRootPath() . 'public' . DS . 'store.html');
  104. } else {
  105. return Response::create()->code(404);
  106. }
  107. });
  108. });
  109. //收银台
  110. Route::group(config('admin.cashier_prefix'), function () {
  111. Route::miss(function () {
  112. $pathInfo = request()->pathinfo();
  113. $pathInfoArr = explode('/', $pathInfo);
  114. $admin = $pathInfoArr[0] ?? '';
  115. if ($admin === config('admin.cashier_prefix')) {
  116. return view(app()->getRootPath() . 'public' . DS . 'cashier.html');
  117. } else {
  118. return Response::create()->code(404);
  119. }
  120. });
  121. });
  122. Route::miss(function () {
  123. if (!request()->isMobile() && is_dir(app()->getRootPath() . 'public' . DS . 'home') && !request()->get('type')) {
  124. if (file_exists(app()->getRootPath() . 'public' . DS . 'home'. DS . 'index.html')) {
  125. return view(app()->getRootPath() . 'public' . DS . 'home' . DS . 'index.html');
  126. } else {
  127. return view(app()->getRootPath() . 'public' . DS . 'index.html');
  128. }
  129. } else {
  130. return view(app()->getRootPath() . 'public' . DS . 'index.html');
  131. }
  132. });
  133. })->middleware(InstallMiddleware::class);