route.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. use think\facade\Route;
  3. Route::get('surl/:id', function(\app\Request $request){
  4. return app()->make(\app\api\controller\v1\PublicController::class)->getSchemeUrl($request->param('id'));
  5. });
  6. Route::miss(function () {
  7. $appRequest = request()->pathinfo();
  8. if ($appRequest === null) {
  9. $appName = '';
  10. } else {
  11. $appRequest = str_replace('//', '/', $appRequest);
  12. $appName = explode('/', $appRequest)[0] ?? '';
  13. }
  14. switch (strtolower($appName)) {
  15. case config('app.admin_prefix', 'admin'):
  16. case 'kefu':
  17. case 'app':
  18. return view(app()->getRootPath() . 'public' . DS . config('app.admin_prefix', 'admin') . DS . 'index.html');
  19. case 'home':
  20. if (request()->isMobile()) {
  21. return redirect(app()->route->buildUrl('/'));
  22. } else {
  23. return view(app()->getRootPath() . 'public' . DS . 'home' . DS . 'index.html');
  24. }
  25. case 'pages':
  26. return view(app()->getRootPath() . 'public' . DS . 'index.html');
  27. default:
  28. if (!request()->isMobile()) {
  29. if (is_dir(app()->getRootPath() . 'public' . DS . 'home') && !request()->get('mdType')) {
  30. return view(app()->getRootPath() . 'public' . DS . 'home' . DS . 'index.html');
  31. } else {
  32. if (request()->get('type')) {
  33. return view(app()->getRootPath() . 'public' . DS . 'index.html');
  34. } else {
  35. return view(app()->getRootPath() . 'public' . DS . 'mobile.html', ['siteName' => sys_config('site_name'), 'siteUrl' => sys_config('site_url') . '/pages/index/index']);
  36. }
  37. }
  38. } else {
  39. return view(app()->getRootPath() . 'public' . DS . 'index.html');
  40. }
  41. }
  42. });