route.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. use think\facade\Route;
  12. use think\facade\Config;
  13. use think\Response;
  14. use app\http\middleware\AllowOriginMiddleware;
  15. /**
  16. * 无需授权的接口
  17. */
  18. Route::group(function () {
  19. //升级程序
  20. Route::get('upgrade', 'UpgradeController/index');
  21. Route::get('upgrade/run', 'UpgradeController/upgrade');
  22. //用户名密码登录
  23. Route::post('login', 'Login/login')->name('AdminLogin')->option(['real_name' => '下载表备份记录']);
  24. //后台登录页面数据
  25. Route::get('login/info', 'Login/info')->option(['real_name' => '登录信息']);
  26. //下载文件
  27. Route::get('download/:key', 'PublicController/download')->option(['real_name' => '下载文件']);
  28. //验证码
  29. Route::get('captcha_pro', 'Login/captcha')->name('')->option(['real_name' => '获取验证码']);
  30. //获取验证码
  31. Route::get('ajcaptcha', 'Login/ajcaptcha')->name('ajcaptcha')->option(['real_name' => '获取验证码']);
  32. //一次验证
  33. Route::post('ajcheck', 'Login/ajcheck')->name('ajcheck')->option(['real_name' => '一次验证']);
  34. //获取客服数据
  35. Route::get('get_workerman_url', 'PublicController/getWorkerManUrl')->option(['real_name' => '获取客服数据']);
  36. //测试
  37. Route::get('index', 'Test/index')->option(['real_name' => '测试地址']);
  38. //扫码上传图片
  39. Route::post('image/scan_upload', 'PublicController/scanUpload')->option(['real_name' => '扫码上传图片']);
  40. //路由导入
  41. Route::get('route/import_api', 'PublicController/import')->option(['real_name' => '路由导入']);
  42. })->middleware(AllowOriginMiddleware::class)->option(['mark' => 'login', 'mark_name' => '登录相关']);
  43. /**
  44. * miss 路由
  45. */
  46. Route::miss(function () {
  47. if (app()->request->isOptions()) {
  48. $header = Config::get('cookie.header');
  49. $header['Access-Control-Allow-Origin'] = app()->request->header('origin');
  50. return Response::create('ok')->code(200)->header($header);
  51. } else
  52. return Response::create()->code(404);
  53. });