|
|
@ -1,5 +1,6 @@ |
|
|
import 'package:dio/dio.dart'; |
|
|
import 'package:dio/dio.dart'; |
|
|
import 'package:flutter_dotenv/flutter_dotenv.dart'; |
|
|
import 'package:flutter_dotenv/flutter_dotenv.dart'; |
|
|
|
|
|
import 'package:get/get.dart' hide Response; |
|
|
|
|
|
|
|
|
import 'auth_interceptor.dart'; |
|
|
import 'auth_interceptor.dart'; |
|
|
import 'nw_method.dart'; |
|
|
import 'nw_method.dart'; |
|
|
@ -9,7 +10,18 @@ class DioManager { |
|
|
factory DioManager() => _shared; |
|
|
factory DioManager() => _shared; |
|
|
|
|
|
|
|
|
late Dio dio; |
|
|
late Dio dio; |
|
|
final baseUrl = dotenv.env['SERVER_URL'] ?? ""; |
|
|
// 根据地区获取服务器URL |
|
|
|
|
|
String get baseUrl { |
|
|
|
|
|
final countryCode = Get.deviceLocale?.countryCode?.toUpperCase(); |
|
|
|
|
|
final isChinaMainland = countryCode == 'CN'; |
|
|
|
|
|
|
|
|
|
|
|
if (!isChinaMainland) { |
|
|
|
|
|
return dotenv.env['HW_SERVER_URL'] ?? dotenv.env['SERVER_URL'] ?? ''; |
|
|
|
|
|
} else { |
|
|
|
|
|
return dotenv.env['SERVER_URL'] ?? ''; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
DioManager._internal() { |
|
|
DioManager._internal() { |
|
|
BaseOptions options = BaseOptions( |
|
|
BaseOptions options = BaseOptions( |
|
|
baseUrl: baseUrl, |
|
|
baseUrl: baseUrl, |
|
|
|