app.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. use think\facade\Route;
  3. Route::any('/index/all', "index/all");
  4. Route::any('/manager', 'index/index');
  5. Route::any("/privacy", "index/privacy");
  6. Route::any('/noteApp', "index/index");
  7. Route::any("/api/background$", "api/background");
  8. Route::any("/qq_login$", "user/qq_login");
  9. Route::any("/favicon", "index/favicon");
  10. Route::get("/plugins/:dir/static/[:file]", "\PluginStaticSystem@index")->pattern(['dir' => '\w+', 'file' => '[\w||\s\-].*']); //插件静态资源路由文件
  11. Route::any("/manifest.json", "index/manifest")->cache(60 * 10);
  12. Route::any("/searchEngine/searchEngine", "searchEngine/searchEngine");
  13. Route::group("/plugins", function () {
  14. $pluginsDir = root_path() . "plugins/";
  15. if (is_dir($pluginsDir)) {
  16. $url = request()->baseUrl();
  17. $urlArr = explode('/', $url);
  18. $pluginsDirName = '';
  19. if (isset($urlArr[2])) {
  20. $pluginsDirName = $urlArr[2];
  21. }
  22. foreach (scandir($pluginsDir) as $item) {
  23. if (mb_strtolower($item) == mb_strtolower($pluginsDirName)) {
  24. $router = $pluginsDir . $item . '/route.php';
  25. if (file_exists($router)) {
  26. $_ENV['plugins_dir_name'] = $pluginsDir . $item;
  27. include_once $router;
  28. break;
  29. }
  30. }
  31. }
  32. }
  33. Route::miss(function () {
  34. return view(app_path() . "view/cardNotFound.html")->code(200);
  35. });
  36. });
  37. Route::any('/', 'index/index');
  38. Route::options("[:s]", function () {
  39. return response('', 200);
  40. })->cache(60 * 60);