SystemServiceSetup.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. declare(strict_types=1);
  3. namespace app\miniapi\service;
  4. final class SystemServiceSetup
  5. {
  6. public static function build(array $capabilities): array
  7. {
  8. $messages = [];
  9. if (!($capabilities['wechat_login'] ?? false)) {
  10. $messages['wechat_login'] = [
  11. 'action' => 'configure',
  12. 'summary' => 'WeChat login is not configured.',
  13. 'steps' => [
  14. 'Set the mini program AppID in water-mini/src/manifest.json.',
  15. 'Set MINI_WECHAT_APPID and MINI_WECHAT_SECRET in server/.env; keep the secret on the server.',
  16. 'Configure the HTTPS API domain in the WeChat mini program console and water-mini/.env.local.',
  17. 'Restart the Webman service after saving configuration.',
  18. 'Verify capabilities.wechat_login from GET /api/mini/v1/config.',
  19. 'Use wx.login and bind the new mini user to a business identity in the admin panel.',
  20. ],
  21. ];
  22. }
  23. if (!($capabilities['test_phone_login'] ?? false)) {
  24. $messages['test_phone_login'] = [
  25. 'action' => 'optional',
  26. 'summary' => 'Test phone login is disabled.',
  27. 'steps' => [
  28. 'Set MINI_TEST_PHONE_LOGIN=true to enable the three fixed test accounts.',
  29. 'Test login does not require a specific APP_ENV or client IP.',
  30. 'Reload Webman after changing the setting.',
  31. ],
  32. ];
  33. }
  34. if (($capabilities['sms_login'] ?? false) === false && config('mini_api.sms_login', false) === true) {
  35. $messages['sms_login'] = [
  36. 'action' => 'configure',
  37. 'summary' => 'SMS login is enabled but the provider account is incomplete.',
  38. 'steps' => [
  39. 'Set MINI_SMS_USER and MINI_SMS_PASSWORD in server/.env.',
  40. 'Confirm the provider account has remaining balance.',
  41. 'Bind the phone to a mini user in the admin panel before sending codes to it.',
  42. ],
  43. ];
  44. }
  45. return $messages;
  46. }
  47. }