my_api.dart 764 B

123456789101112131415161718192021222324252627282930313233343536
  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:9399';
  8. /// 紫光 生产正式 url
  9. // static String productUrl = 'http://101.36.160.117:39099';
  10. /// 测试url
  11. // static String testUrl = 'http://101.36.160.117:31070';
  12. static String testUrl = 'http://121.36.17.6:9398';
  13. static late String globalUrl;
  14. static void init(AppEnvironment env) {
  15. globalUrl = switch (env) {
  16. AppEnvironment.develop => testUrl,
  17. AppEnvironment.product => productUrl,
  18. };
  19. }
  20. static Api get({Dio? dio, String? baseUrl}) {
  21. return Api(
  22. dio: dio,
  23. baseUrl: baseUrl ?? globalUrl,
  24. );
  25. }
  26. }