111
This commit is contained in:
@@ -23,7 +23,6 @@ class DioClient {
|
||||
DioClient() {
|
||||
_dio = _createDio();
|
||||
_setupInterceptors();
|
||||
debugPrint('DioClient initialized with baseUrl: ${NetworkConfig.baseUrl}');
|
||||
}
|
||||
|
||||
Dio _createDio() {
|
||||
@@ -100,7 +99,6 @@ class DioClient {
|
||||
// 注意:不再自動清除用戶數據,避免誤判
|
||||
// 只有在 HTTP 401 時才清除用戶數據
|
||||
if (apiResponse.isUnauthorized) {
|
||||
debugPrint('業務層未授權響應: ${apiResponse.message}');
|
||||
// 不再自動調用 onUnauthorized,避免刷新時誤判
|
||||
// onUnauthorized?.call();
|
||||
}
|
||||
@@ -110,15 +108,6 @@ class DioClient {
|
||||
}
|
||||
|
||||
ApiResponse<T> _handleError<T>(DioException e) {
|
||||
// 詳細錯誤日誌
|
||||
debugPrint('=== Network Error ===');
|
||||
debugPrint('Type: ${e.type}');
|
||||
debugPrint('Message: ${e.message}');
|
||||
debugPrint('URL: ${e.requestOptions.uri}');
|
||||
debugPrint('StatusCode: ${e.response?.statusCode}');
|
||||
debugPrint('ResponseData: ${e.response?.data}');
|
||||
debugPrint('====================');
|
||||
|
||||
if (_isUnauthorized(e)) {
|
||||
_clearUserData();
|
||||
onUnauthorized?.call();
|
||||
@@ -165,32 +154,16 @@ class DioClient {
|
||||
class _LoggingInterceptor extends Interceptor {
|
||||
@override
|
||||
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
|
||||
debugPrint('┌──────────────────────────────────────────────────────────');
|
||||
debugPrint('│ REQUEST: ${options.method} ${options.uri}');
|
||||
debugPrint('│ Headers: ${options.headers}');
|
||||
if (options.data != null) {
|
||||
debugPrint('│ Data: ${options.data}');
|
||||
}
|
||||
debugPrint('└──────────────────────────────────────────────────────────');
|
||||
super.onRequest(options, handler);
|
||||
}
|
||||
|
||||
@override
|
||||
void onResponse(Response response, ResponseInterceptorHandler handler) {
|
||||
debugPrint('┌──────────────────────────────────────────────────────────');
|
||||
debugPrint('│ RESPONSE: ${response.statusCode} ${response.requestOptions.uri}');
|
||||
debugPrint('│ Data: ${response.data}');
|
||||
debugPrint('└──────────────────────────────────────────────────────────');
|
||||
super.onResponse(response, handler);
|
||||
}
|
||||
|
||||
@override
|
||||
void onError(DioException err, ErrorInterceptorHandler handler) {
|
||||
debugPrint('┌──────────────────────────────────────────────────────────');
|
||||
debugPrint('│ ERROR: ${err.type} ${err.requestOptions.uri}');
|
||||
debugPrint('│ Message: ${err.message}');
|
||||
debugPrint('│ StatusCode: ${err.response?.statusCode}');
|
||||
debugPrint('└──────────────────────────────────────────────────────────');
|
||||
super.onError(err, handler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ class DomainNavigator {
|
||||
static Future<String> init() async {
|
||||
if (kDebugMode) {
|
||||
_activeUrl = _debugUrl;
|
||||
debugPrint('[DomainNavigator] Debug mode, use: $_activeUrl');
|
||||
return _activeUrl;
|
||||
}
|
||||
|
||||
@@ -47,11 +46,9 @@ class DomainNavigator {
|
||||
final ok = await _quickCheck(cached);
|
||||
if (ok) {
|
||||
_activeUrl = cached;
|
||||
debugPrint('[DomainNavigator] Cache hit: $_activeUrl');
|
||||
return _activeUrl;
|
||||
}
|
||||
// 缓存验证失败但不删除,作为后续兜底
|
||||
debugPrint('[DomainNavigator] Cache check failed, keeping as fallback: $cached');
|
||||
}
|
||||
|
||||
// 竞速请求导航地址
|
||||
@@ -61,7 +58,6 @@ class DomainNavigator {
|
||||
// 缓存到本地
|
||||
await LocalStorage.setString(_cachedDomainKey, _activeUrl);
|
||||
|
||||
debugPrint('[DomainNavigator] Resolved: $_activeUrl');
|
||||
return _activeUrl;
|
||||
}
|
||||
|
||||
@@ -75,18 +71,15 @@ class DomainNavigator {
|
||||
|
||||
if (result.isNotEmpty) return result;
|
||||
} catch (_) {
|
||||
debugPrint('[DomainNavigator] Race resolve timeout or failed');
|
||||
}
|
||||
|
||||
// 所有导航失败,尝试使用上次缓存
|
||||
final cached = LocalStorage.getString(_cachedDomainKey);
|
||||
if (cached != null && cached.isNotEmpty) {
|
||||
debugPrint('[DomainNavigator] All nav failed, use cache: $cached');
|
||||
return cached;
|
||||
}
|
||||
|
||||
// 没有缓存,返回空字符串(应用会显示网络错误)
|
||||
debugPrint('[DomainNavigator] All nav failed, no cache available');
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -113,7 +106,7 @@ class DomainNavigator {
|
||||
if (url.startsWith('http')) return url;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return 'https://admin.doskrleti.com';
|
||||
}
|
||||
|
||||
/// 快速检查域名是否可达(3s 超时)
|
||||
|
||||
Reference in New Issue
Block a user