mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
add login
This commit is contained in:
13
lib/base/http/token_interceptor.dart
Normal file
13
lib/base/http/token_interceptor.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:qinglong_app/main.dart';
|
||||
|
||||
class TokenInterceptor extends Interceptor {
|
||||
@override
|
||||
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
|
||||
if (userInfoViewModel.token != null) {
|
||||
options.headers["Authorization"] = "Bearer " + userInfoViewModel.token!;
|
||||
}
|
||||
options.queryParameters["t"] = DateTime.now().millisecondsSinceEpoch;
|
||||
return handler.next(options);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user