Index.php 989 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\error\controller;
  3. use think\Controller;
  4. use think\Request;
  5. /**
  6. * 错误模块 - 解决「模块不存在:error」
  7. * 当请求被错误路由到 error 模块时,返回 JSON 提示正确访问方式
  8. */
  9. class Index extends Controller
  10. {
  11. public function index()
  12. {
  13. return $this->jsonError();
  14. }
  15. public function _500()
  16. {
  17. return $this->jsonError();
  18. }
  19. private function jsonError()
  20. {
  21. $base = rtrim(request()->domain() . request()->root(), '/');
  22. return json([
  23. 'code' => 404,
  24. 'msg' => '接口地址错误,请使用下列任一地址',
  25. 'data' => [
  26. 'urls' => [
  27. $base . '/img2img',
  28. $base . '/api/img2img',
  29. $base . '/api/Index/img_to_img'
  30. ],
  31. 'method' => 'POST',
  32. 'params' => ['product_img', 'template_img', 'prompt']
  33. ]
  34. ]);
  35. }
  36. }