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