route.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. use think\facade\Route;
  3. Route::miss(function () {
  4. $appRequest = request()->pathinfo();
  5. if ($appRequest === null) {
  6. $appName = '';
  7. } else {
  8. $appRequest = str_replace('//', '/', $appRequest);
  9. $appName = explode('/', $appRequest)[0] ?? '';
  10. }
  11. switch (strtolower($appName)) {
  12. case config('app.admin_prefix','admin'):
  13. return view(app()->getRootPath() . 'public' . DS . 'system.html');
  14. case 'home':
  15. if (request()->isMobile()) {
  16. return redirect(app()->route->buildUrl('/'));
  17. } else {
  18. return view(app()->getRootPath() . 'public' . DS . 'home' . DS . 'index.html');
  19. }
  20. case 'kefu':
  21. return view(app()->getRootPath() . 'public' . DS . 'system.html');
  22. case 'pages':
  23. return view(app()->getRootPath() . 'public' .DS . 'index.html');
  24. default:
  25. if (!request()->isMobile() && is_dir(app()->getRootPath() . 'public' . DS . 'home') && !request()->get('type')) {
  26. return view(app()->getRootPath() . 'public' . DS . 'home' . DS . 'index.html');
  27. } else {
  28. return view(app()->getRootPath() . 'public' . DS . 'index.html');
  29. }
  30. }
  31. });