my_api.dart 605 B

12345678910111213141516171819202122232425262728293031
  1. import 'package:dio/dio.dart';
  2. import 'package:lszlgl/config/app_config.dart';
  3. import 'api.dart';
  4. class MyApi {
  5. MyApi._();
  6. /// 生产url
  7. static String productUrl = 'http://121.36.17.6:49099';
  8. /// 测试url
  9. static String testUrl = 'http://121.36.17.6:19090';
  10. static late String globalUrl;
  11. static void init(AppEnvironment env) {
  12. globalUrl = switch (env) {
  13. AppEnvironment.develop => testUrl,
  14. AppEnvironment.product => productUrl,
  15. };
  16. }
  17. static Api get({Dio? dio, String? baseUrl}) {
  18. return Api(
  19. dio: dio,
  20. baseUrl: baseUrl ?? globalUrl,
  21. );
  22. }
  23. }