地址切换

This commit is contained in:
2026-01-12 09:13:37 +08:00
parent baee5dba83
commit 285a20f070
7 changed files with 199 additions and 7 deletions

View File

@@ -1,6 +1,7 @@
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:getx_scaffold/getx_scaffold.dart';
import 'package:ln_jq_app/storage_service.dart';
/// 专门用于处理和添加 Token 的拦截器
@@ -13,7 +14,7 @@ class TokenInterceptor extends Interceptor {
TokenInterceptor({this.tokenKey = 'Authorization', this.sourceKey = 'source'});
@override
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
void onRequest(RequestOptions options, RequestInterceptorHandler handler) async{
// 从 StorageService 中获取已保存的 token
final String? token = StorageService.to.token;
@@ -38,6 +39,9 @@ class TokenInterceptor extends Interceptor {
options.headers[sourceKey] = platformSource;
}
options.headers['appVersion'] = await getVersion();
options.headers['brand'] = await getDeviceModel();
// 调用 handler.next(options) 以继续执行请求
// 这一步至关重要,否则请求会被中断
super.onRequest(options, handler);