提交 fc75646a authored 作者: yueweilu's avatar yueweilu

1、没有网络的时候才使用缓存

上级 e74a0d00
......@@ -4,5 +4,5 @@ keyPassword=123456
keyAlias=zijing
#storeFile=/Users/apple/zijiing_key.jks
storeFile=zijiing_key.jks
\ No newline at end of file
storeFile=/Users/apple/zijiing_key.jks
#storeFile=zijiing_key.jks
\ No newline at end of file
PODS:
- audio_session (0.0.1):
- Flutter
- connectivity_plus (0.0.1):
- Flutter
- ReachabilitySwift
- Flutter (1.0.0)
- flutter_app_update (0.0.1):
- Flutter
......@@ -37,9 +40,13 @@ PODS:
- FlutterMacOS
- permission_handler_apple (9.1.1):
- Flutter
- ReachabilitySwift (5.0.0)
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
- sqflite (0.0.3):
- Flutter
- FlutterMacOS
- tobias (0.0.1):
- Flutter
- tobias/normal (= 0.0.1)
......@@ -49,6 +56,7 @@ PODS:
DEPENDENCIES:
- audio_session (from `.symlinks/plugins/audio_session/ios`)
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`)
- Flutter (from `Flutter`)
- flutter_app_update (from `.symlinks/plugins/flutter_app_update/ios`)
- flutter_inapp_purchase (from `.symlinks/plugins/flutter_inapp_purchase/ios`)
......@@ -62,17 +70,21 @@ DEPENDENCIES:
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- sqflite (from `.symlinks/plugins/sqflite/darwin`)
- tobias (from `.symlinks/plugins/tobias/ios`)
SPEC REPOS:
trunk:
- flutter_sound_core
- OrderedSet
- ReachabilitySwift
- WechatOpenSDK-XCFramework
EXTERNAL SOURCES:
audio_session:
:path: ".symlinks/plugins/audio_session/ios"
connectivity_plus:
:path: ".symlinks/plugins/connectivity_plus/ios"
Flutter:
:path: Flutter
flutter_app_update:
......@@ -99,11 +111,14 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/permission_handler_apple/ios"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
sqflite:
:path: ".symlinks/plugins/sqflite/darwin"
tobias:
:path: ".symlinks/plugins/tobias/ios"
SPEC CHECKSUMS:
audio_session: 4f3e461722055d21515cf3261b64c973c062f345
connectivity_plus: bf0076dd84a130856aa636df1c71ccaff908fa1d
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_app_update: 65f61da626cb111d1b24674abc4b01728d7723bc
flutter_inapp_purchase: 5c6a1ac3f11b11d0c8c0321c0c41c1f05805e4c8
......@@ -118,7 +133,9 @@ SPEC CHECKSUMS:
package_info_plus: 115f4ad11e0698c8c1c5d8a689390df880f47e85
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
tobias: 22f69183b14af82a2ac8ff698af084c352744e5f
WechatOpenSDK-XCFramework: acdeeda129efbef9532bca8a10c24e1b4b8c7d69
......
......@@ -489,6 +489,7 @@
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "紫荆数智学堂";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.books";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
......@@ -658,6 +659,7 @@
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "紫荆数智学堂";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.books";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
......@@ -680,6 +682,7 @@
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "紫荆数智学堂";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.books";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
......
......@@ -87,10 +87,10 @@ class LoginController extends GetxController {
// 定时器回调
});
/// 测试账号
if (kDebugMode) {
phoneInput.text = '13521054068';
passwordInput.text = '123456';
}
// if (kDebugMode) {
// phoneInput.text = '13521054068';
// passwordInput.text = '123456';
// }
super.onInit();
}
......
......@@ -67,7 +67,7 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
// 上报开始阅读时间
_addReadTime(type: 'open');
_getChapters();
final netStatus = await _checkCurrentNetStatus();
final netStatus = await Tools.checkCurrentNetStatus();
// 判断是否有离线文件 如果有使用离线阅读
final exist = await _isExistFile(bookId);
// 没有网并且有离线文件 离线阅读
......@@ -435,32 +435,6 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
}
}
// 判断当前网络状态
Future<bool> _checkCurrentNetStatus() async {
final connectivityResult = await (Connectivity().checkConnectivity());
if (connectivityResult == ConnectivityResult.none){
return false;
}
return true;
// if (connectivityResult == ConnectivityResult.mobile) {
// // I am connected to a mobile network.
// } else if (connectivityResult == ConnectivityResult.wifi) {
// // I am connected to a wifi network.
// } else if (connectivityResult == ConnectivityResult.ethernet) {
// // I am connected to a ethernet network.
// } else if (connectivityResult == ConnectivityResult.vpn) {
// // I am connected to a vpn network.
// // Note for iOS and macOS:
// // There is no separate network interface type for [vpn].
// // It returns [other] on any device (also simulator)
// } else if (connectivityResult == ConnectivityResult.bluetooth) {
// // I am connected to a bluetooth.
// } else if (connectivityResult == ConnectivityResult.other) {
// // I am connected to a network which is not in the above mentioned networks.
// } else if (connectivityResult == ConnectivityResult.none) {
// // I am not connected to any network.
// }
}
// 判断是否存在离线文件
Future<bool> _isExistFile(String bookId) async {
......
......@@ -52,8 +52,7 @@ class _ReadPageState extends State<ReadPage> {
floatingActionButton: readController.show&& !readController.toolModel.selected?GestureDetector(
onTap: (){
readController.setShowChat(true);
readController.noteTitle = '你好你问你你等您第五年对哦in我ID呢哦win地哦为内地那打卡你打困哪';
readController.setChatType(1);
readController.setChatType(0);
},
child: Image.asset('assets/images/chat.png'),
):null,
......@@ -118,7 +117,7 @@ class _ReadPageState extends State<ReadPage> {
controller.addJavaScriptHandler(handlerName: 'discussCallBack', callback: (args){
readController.setShowChat(true);
readController.setChatType(0);
readController.titleInput.text = '11111';
readController.titleInput.text = args.toString();
});
},
......
......@@ -103,7 +103,7 @@ class HttpService extends GetxService {
// 如果启用缓存,将cacheEnabled参数添加到请求选项中
if(cacheEnabled){
requestOptions.extra ??= {};
requestOptions.extra!['cacheEnabled'] = false;
requestOptions.extra!['cacheEnabled'] = true;
}
final response = await _dio.post(
url,
......@@ -335,7 +335,8 @@ class _CacheInterceptor extends Interceptor {
void onRequest(RequestOptions options, RequestInterceptorHandler handler) async {
final cacheEnabled = options.extra?['cacheEnabled'] ?? false;
if (cacheEnabled) {
final status = await Tools.checkCurrentNetStatus();
if (cacheEnabled && !status) {
// 在发起请求之前,检查缓存是否存在有效数据
final cachedFile = await DefaultCacheManager().getFileFromCache(options.uri.toString());
if (cachedFile != null && cachedFile.validTill.isAfter(DateTime.now())) {
......
......@@ -7,6 +7,7 @@ import 'dart:io';
import 'dart:ui';
// import 'package:encrypt/encrypt.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:dio/dio.dart';
import 'package:encrypt/encrypt.dart' as encrypt; // 使用别名 'encrypt'
import 'package:flutter/cupertino.dart';
......
......@@ -48,6 +48,33 @@ abstract class Tools {
String formattedDate = DateFormat('yyyyMMddHHmmss').format(now);
return 'voice_$formattedDate.mp4';
}
// 判断当前网络状态
static Future<bool> checkCurrentNetStatus() async {
final connectivityResult = await (Connectivity().checkConnectivity());
if (connectivityResult == ConnectivityResult.none){
return false;
}
return true;
// if (connectivityResult == ConnectivityResult.mobile) {
// // I am connected to a mobile network.
// } else if (connectivityResult == ConnectivityResult.wifi) {
// // I am connected to a wifi network.
// } else if (connectivityResult == ConnectivityResult.ethernet) {
// // I am connected to a ethernet network.
// } else if (connectivityResult == ConnectivityResult.vpn) {
// // I am connected to a vpn network.
// // Note for iOS and macOS:
// // There is no separate network interface type for [vpn].
// // It returns [other] on any device (also simulator)
// } else if (connectivityResult == ConnectivityResult.bluetooth) {
// // I am connected to a bluetooth.
// } else if (connectivityResult == ConnectivityResult.other) {
// // I am connected to a network which is not in the above mentioned networks.
// } else if (connectivityResult == ConnectivityResult.none) {
// // I am not connected to any network.
// }
}
}
......
......@@ -91,9 +91,9 @@ class ValidatorTool {
// 密码
static bool isValidPassword(String value) {
// RegExp passwordPattern = RegExp(r'^[A-Za-z0-9!@#\$%^&*()_+{}\[\]:;<>,.?~\\/-]{8,12}$');
RegExp passwordPattern = RegExp(r'^[A-Za-z0-9!@#\$%^&*()_+{}\[\]:;<>,.?~\\/-]{8,12}$');
// RegExp passwordPattern = RegExp(r'^(?=.*[A-Za-z])(?=.*\d)(?=.*[~@#%$*()_+{}\[\]:;<>,.?\\/-])[A-Za-z0-9~@#%$*()_+{}\[\]:;<>,.?\\/-]{8,12}$');
RegExp passwordPattern = RegExp(r'^\d{6}$');
// RegExp passwordPattern = RegExp(r'^\d{6}$');
return passwordPattern.hasMatch(value);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论