Blame view

lib/common/request/token_interceptor.dart 629 Bytes
056970d8   Key   feat: api
1
  import 'package:dio/dio.dart';
934e2b47   liangchengyou   feat:权限调整+课程进度接口对接
2
  import 'package:package_info_plus/package_info_plus.dart';
94342c3f   Key   feat: user util
3
  import 'package:wow_english/common/core/user_util.dart';
934e2b47   liangchengyou   feat:权限调整+课程进度接口对接
4
  import 'package:wow_english/common/request/basic_config.dart';
056970d8   Key   feat: api
5
6
7
8
  
  class TokenInterceptor extends Interceptor {
    @override
    void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
05f9b20a   Key   fixed: api调用方式,未完善
9
      // 判断token不为空插入, todo token的取法应该跟user在一起,这里取不到user
94342c3f   Key   feat: user util
10
11
      if (UserUtil.token.isNotEmpty) {
        options.headers["Auth-token"] = UserUtil.token;
05f9b20a   Key   fixed: api调用方式,未完善
12
      }
056970d8   Key   feat: api
13
14
15
16
      options.headers["version"] = '1.0.0';
      super.onRequest(options, handler);
    }
  }