mirror of
https://github.com/simon-ding/polaris.git
synced 2026-03-06 17:40:46 +08:00
feat: add auth header
This commit is contained in:
@@ -39,6 +39,7 @@ class APIs {
|
||||
}
|
||||
|
||||
static Dio? dio1;
|
||||
static Map<String, String> authHeaders = {};
|
||||
|
||||
static Future<Dio> getDio() async {
|
||||
if (dio1 != null) {
|
||||
@@ -46,6 +47,9 @@ class APIs {
|
||||
}
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
var token = prefs.getString("token");
|
||||
|
||||
authHeaders["Authorization"] = "Bearer $token";
|
||||
|
||||
var dio = Dio();
|
||||
dio.interceptors.add(InterceptorsWrapper(
|
||||
onRequest: (options, handler) {
|
||||
|
||||
@@ -112,6 +112,7 @@ class _TvDetailsPageState extends ConsumerState<TvDetailsPage> {
|
||||
child: Image.network(
|
||||
"${APIs.imagesUrl}/${details.id}/poster.jpg",
|
||||
fit: BoxFit.contain,
|
||||
headers: APIs.authHeaders,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -38,6 +38,7 @@ class WelcomePage extends ConsumerWidget {
|
||||
child: Image.network(
|
||||
"${APIs.imagesUrl}/${item.id}/poster.jpg" ,
|
||||
fit: BoxFit.contain,
|
||||
headers: APIs.authHeaders,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
|
||||
Reference in New Issue
Block a user