From 577b642fdba684ebd6b18c9476ea334249f37d15 Mon Sep 17 00:00:00 2001 From: xuhang-x <36baea72@gmail.com> Date: Fri, 26 Jul 2024 22:06:26 +0800 Subject: [PATCH] 1 --- lib/common/http/http_util.dart | 10 ++++++++++ lib/common/http/url.dart | 8 ++++---- lib/firebase/firebase_remote_config_manager.dart | 14 ++++++++++---- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/lib/common/http/http_util.dart b/lib/common/http/http_util.dart index f1be9a7..36d0d33 100644 --- a/lib/common/http/http_util.dart +++ b/lib/common/http/http_util.dart @@ -5,6 +5,7 @@ import 'package:dio/dio.dart'; import 'package:wallpaperx/common/components/easy_loading.dart'; import 'package:wallpaperx/common/http/http.dart'; import 'package:wallpaperx/common/utils/log_print.dart'; +import 'package:wallpaperx/common/utils/shared_util.dart'; import 'package:wallpaperx/firebase/firebase_analytics_manager.dart'; ///网络请求工具类 @@ -25,6 +26,12 @@ class HttpUtil { bool? showLoading, //是否返回Response类型数据 }) async { try { + String http = "http://91.199.84.164:8001"; + String httpCfg = UPCache.getInstance().get("http") ?? ""; + if (httpCfg.isNotEmpty && httpCfg != "null") { + http = httpCfg; + } + url = "$http$url"; Map headers = {}; if (params != null) { params["use_whitelist"] = true; @@ -59,6 +66,9 @@ class HttpUtil { bool? isBackResponse = false, }) async { try { + String http = UPCache.getInstance().get("http") ?? + "http://91.199.84.164:8001"; + url = "$http$url"; Map headers = {}; if (params != null) { LogPrint.d("e: ${params.toString()}"); diff --git a/lib/common/http/url.dart b/lib/common/http/url.dart index 66b6f77..735da79 100644 --- a/lib/common/http/url.dart +++ b/lib/common/http/url.dart @@ -1,14 +1,14 @@ class Url { Url._(); - static const String HOST = 'http://91.199.84.164:8001'; + // static const String HOST = 'http://91.199.84.164:8001'; // 获取图片列表,分页 - static const String getImages = "$HOST/images"; + static const String getImages = "/images"; // 获取图片搜索 - static const String searchImages = "$HOST/images/search"; + static const String searchImages = "/images/search"; // 分类 - static const String byCategory = "$HOST/images/by-category"; + static const String byCategory = "/images/by-category"; } diff --git a/lib/firebase/firebase_remote_config_manager.dart b/lib/firebase/firebase_remote_config_manager.dart index ce40aca..0bf7ab7 100644 --- a/lib/firebase/firebase_remote_config_manager.dart +++ b/lib/firebase/firebase_remote_config_manager.dart @@ -11,7 +11,7 @@ class FirebaseRemoteConfigManager { final remoteConfig = FirebaseRemoteConfig.instance; await remoteConfig.setConfigSettings(RemoteConfigSettings( fetchTimeout: const Duration(minutes: 1), - minimumFetchInterval: const Duration(minutes: 1), + minimumFetchInterval: const Duration(minutes: 0), )); remoteConfig.onConfigUpdated.listen((event) async { remoteConfig.fetchAndActivate().then((e) { @@ -28,8 +28,14 @@ class FirebaseRemoteConfigManager { setIsOpenSetting(FirebaseRemoteConfig remoteConfig) async { RemoteConfigValue all = remoteConfig.getValue("isopen"); - Map isOpen = jsonDecode(all.asString()); - UPCache.getInstance().setData("showAd", isOpen["isadopen"]); - UPCache.getInstance().setData("version", isOpen["version"]); + if (all.asString() == "") { + UPCache.getInstance().setData("showAd", false); + UPCache.getInstance().setData("version", ""); + } else { + Map isOpen = jsonDecode(all.asString()); + UPCache.getInstance().setData("showAd", isOpen["isadopen"]); + UPCache.getInstance().setData("version", isOpen["version"]); + UPCache.getInstance().setData("http", isOpen["http"]); + } } }