routes.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. use App\Admin\Controllers\DistAppearanceTemplateController;
  3. use App\Admin\Controllers\RpcController;
  4. use App\Admin\Services\RpcService;
  5. use Illuminate\Routing\Router;
  6. use Illuminate\Support\Facades\Route;
  7. use Dcat\Admin\Admin;
  8. use JsonRPC\Server;
  9. Admin::routes();
  10. Route::group([
  11. 'prefix' => config('admin.route.prefix'),
  12. 'namespace' => config('admin.route.namespace'),
  13. 'middleware' => config('admin.route.middleware'),
  14. ], function (Router $router) {
  15. //主页
  16. $router->get('/', 'HomeController@index');
  17. // 定义切换语言的路由
  18. $router->get('language-switch','LanguageController@index');
  19. // 不需要登录的路由
  20. $router->get('captcha','CaptchaController@generate');
  21. //文件夹
  22. $router->resource('site-folder', 'SiteAlbumFolderController');
  23. //相册
  24. $router->resource('site-album', 'SiteAlbumController');
  25. //相册日志
  26. $router->get('site-album-log', 'SiteAlbumLogController@index');
  27. //相删用户
  28. $router->resource('site-users', 'SiteUserController');
  29. });
  30. // 定义RPC服务
  31. Route::post('/rpc', function (Request $request) {
  32. // 创建 JSON-RPC 服务端
  33. $server = new Server();
  34. // 注册服务类
  35. $server->getProcedureHandler()
  36. ->withClassAndMethod('siteAlbumPaginate', new RpcService(), 'siteAlbumPaginate')
  37. ->withClassAndMethod('siteAlbumGet', new RpcService(), 'siteAlbumGet')
  38. ->withClassAndMethod('siteAlbumFolderSelectOptions', new RpcService(), 'siteAlbumFolderSelectOptions')
  39. ->withClassAndMethod('siteAlbumFolderSelectOptionsAll', new RpcService(), 'siteAlbumFolderSelectOptionsAll')
  40. ->withClassAndMethod('siteAlbumGetByIds', new RpcService(), 'siteAlbumGetByIds')
  41. ->withClassAndMethod('siteAlbumFolderAllNodes', new RpcService(), 'siteAlbumFolderAllNodes');
  42. // 处理请求并返回响应
  43. return response()->json(json_decode($server->execute()));
  44. });
  45. /*
  46. * 重写上传路由,修改tinymce上传路径
  47. */
  48. $attributes = [
  49. 'prefix' => admin_base_path('dcat-api'),
  50. 'middleware' => config('admin.route.middleware'),
  51. 'as' => 'dcat-api.',
  52. ];
  53. app('router')->group($attributes, function ($router) {
  54. $router->post('editor-md/upload', function () {exit;})->name('editor-md.upload');
  55. $router->post('tinymce/upload', 'App\Http\Controllers\TinymceController@upload')->name('tinymce.upload');
  56. });