route.php 1.1 KB

12345678910111213141516171819202122232425262728293031
  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 'admin':
  13. return view(app()->getRootPath() . 'public' . DS . 'admin' . DS . 'index.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 . 'admin' . DS . 'index.html');
  22. default:
  23. if (!request()->isMobile() && is_dir(app()->getRootPath() . 'public' . DS . 'home') && !request()->get('type')) {
  24. return redirect(app()->route->buildUrl('/home/'));;
  25. } else {
  26. return view(app()->getRootPath() . 'public' . DS . 'index.html');
  27. }
  28. }
  29. });