更改appName等常量为全局变量

This commit is contained in:
rang 2025-11-14 16:34:42 +08:00
parent 896f8837bd
commit e2aa73c01c
35 changed files with 167 additions and 216 deletions

View file

@ -4,6 +4,8 @@ import 'dart:convert';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:http/http.dart';
// import 'package:http_cache_core/http_cache_core.dart';
// import 'package:http_cache_isar_store/http_cache_isar_store.dart';
import 'package:logging/logging.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:shelfsdk/audiobookshelf_api.dart';
@ -33,6 +35,36 @@ Uri makeBaseUrl(String address) {
return Uri.parse(address);
}
// Global options
// final options = CacheOptions(
// // A default store is required for the client.
// store: IsarCacheStore("", name: "http_cache"),
// // All subsequent fields are optional to get a standard behaviour.
// // Default.
// policy: CachePolicy.request,
// // Returns a previous cached response on error for given status codes.
// // Defaults to `[]`.
// hitCacheOnErrorCodes: const [500],
// // Allows to return a cached response on network errors (e.g. offline usage).
// // Defaults to `false`.
// hitCacheOnNetworkFailure: true,
// // Overrides any HTTP directive to delete entry past this duration.
// // Useful only when origin server has no cache config or custom behaviour is desired.
// // Defaults to `null`.
// maxStale: const Duration(days: 7),
// // Default. Allows 3 cache sets and ease cleanup.
// priority: CachePriority.normal,
// // Default. Body and headers encryption with your own algorithm.
// cipher: null,
// // Default. Key builder to retrieve requests.
// keyBuilder: CacheOptions.defaultCacheKeyBuilder,
// // Default. Allows to cache POST requests.
// // Assigning a [keyBuilder] is strongly recommended when `true`.
// allowPostMethod: false,
// );
/// get the api instance for the given base url
@riverpod
AudiobookshelfApi audiobookshelfApi(Ref ref, Uri? baseUrl) {
@ -41,6 +73,7 @@ AudiobookshelfApi audiobookshelfApi(Ref ref, Uri? baseUrl) {
baseUrl ??= apiSettings.activeServer?.serverUrl;
return AudiobookshelfApi(
baseUrl: makeBaseUrl(baseUrl.toString()),
// client:
);
}