12345678910111213141516171819202122 |
- import 'dart:async';
- import 'package:flustars/flustars.dart';
- import 'package:get/get_connect/http/src/request/request.dart';
- import 'package:ftrecruiter/comm/constants/sp_constant.dart';
- import 'package:ftrecruiter/comm/utils/device_utils.dart';
- //自动添加Token,自动刷新Token
- FutureOr<Request> authInterceptor(Request request) async {
- final token = SpUtil.getString(SPConstant.SP_KEY_TOKEN);
- if (!TextUtil.isEmpty(token)) {
- request.headers['Authorization'] = 'bearer$token';
- }
- if (!Device.isWeb) {
- request.headers['User-Agent'] = 'Mozilla/5.0';
- }
- return request;
- }
|