fix:优化和对齐版本
This commit is contained in:
1 parent
364fc837b3
commit
bd6bb0ffce
115 files changed
+155
-3647
No files matched your search
@@ -5,6 +5,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import '../config/app_config.dart';
|
||||
import '../storage/secure_identity_storage.dart';
|
||||
import 'auth_interceptor.dart';
|
||||
import 'kratos_error_interceptor.dart';
|
||||
|
||||
@@ -12,12 +13,20 @@ part 'dio_provider.g.dart';
|
||||
|
||||
const _protobufContentType = 'application/x-protobuf';
|
||||
|
||||
/// Per-request override for native protobuf-over-HTTP endpoints.
|
||||
Options protobufOptions() => Options(
|
||||
responseType: ResponseType.bytes,
|
||||
contentType: _protobufContentType,
|
||||
headers: const {'Accept': _protobufContentType},
|
||||
);
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
AppConfig appConfig(Ref ref) => AppConfig.fromEnvironment();
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
Dio dio(Ref ref) {
|
||||
final config = ref.watch(appConfigProvider);
|
||||
final identityStorage = ref.watch(secureIdentityStorageProvider);
|
||||
final d = Dio(
|
||||
BaseOptions(
|
||||
baseUrl: config.apiBaseUrl,
|
||||
@@ -31,7 +40,7 @@ Dio dio(Ref ref) {
|
||||
},
|
||||
),
|
||||
);
|
||||
d.interceptors.add(AuthInterceptor());
|
||||
d.interceptors.add(AuthInterceptor(identityStorage));
|
||||
d.interceptors.add(KratosErrorInterceptor());
|
||||
if (!kReleaseMode) {
|
||||
d.interceptors.add(LogInterceptor(requestBody: false, responseBody: false));
|
||||
|
||||
Reference in new issue
Block a user