diff --git a/android/agconnect-services.json b/android/agconnect-services.json new file mode 100644 index 0000000..3fe0733 --- /dev/null +++ b/android/agconnect-services.json @@ -0,0 +1,96 @@ +{ + "agcgw": { + "url": "connect-drcn.dbankcloud.cn", + "backurl": "connect-drcn.hispace.hicloud.com", + "websocketurl": "connect-ws-drcn.hispace.dbankcloud.cn", + "websocketbackurl": "connect-ws-drcn.hispace.dbankcloud.com" + }, + "agcgw_all": { + "SG": "connect-dra.dbankcloud.cn", + "SG_back": "connect-dra.hispace.hicloud.com", + "CN": "connect-drcn.dbankcloud.cn", + "CN_back": "connect-drcn.hispace.hicloud.com", + "RU": "connect-drru.hispace.dbankcloud.ru", + "RU_back": "connect-drru.hispace.dbankcloud.cn", + "DE": "connect-dre.dbankcloud.cn", + "DE_back": "connect-dre.hispace.hicloud.com" + }, + "websocketgw_all": { + "SG": "connect-ws-dra.hispace.dbankcloud.cn", + "SG_back": "connect-ws-dra.hispace.dbankcloud.com", + "CN": "connect-ws-drcn.hispace.dbankcloud.cn", + "CN_back": "connect-ws-drcn.hispace.dbankcloud.com", + "RU": "connect-ws-drru.hispace.dbankcloud.ru", + "RU_back": "connect-ws-drru.hispace.dbankcloud.cn", + "DE": "connect-ws-dre.hispace.dbankcloud.cn", + "DE_back": "connect-ws-dre.hispace.dbankcloud.com" + }, + "client": { + "cp_id": "30086000818558366", + "product_id": "461323198430218911", + "client_id": "1752291009686950144", + "client_secret": "2D92A4B951C2B074A5234F598A0E44013881695DBA64641CE8DC3C634D34F9A0", + "project_id": "461323198430218911", + "app_id": "112547949", + "api_key": "DgEDACTa5j3V2cs2rlYwcsYwsuVj29t4cw4JDcBeRG1H3YurPML3W8D5iS6whNQPnwpZTrvPZiGoRF9bDVvi/hDJSJZp+/D+T71/lw==", + "package_name": "com.taihe.mianhuatang" + }, + "oauth_client": { + "client_id": "112547949", + "client_type": 1 + }, + "app_info": { + "app_id": "112547949", + "package_name": "com.taihe.mianhuatang" + }, + "service": { + "analytics": { + "collector_url": "datacollector-drcn.dt.hicloud.com,datacollector-drcn.dt.dbankcloud.cn", + "collector_url_cn": "datacollector-drcn.dt.hicloud.com,datacollector-drcn.dt.dbankcloud.cn", + "collector_url_de": "datacollector-dre.dt.hicloud.com,datacollector-dre.dt.dbankcloud.cn", + "collector_url_ru": "datacollector-drru.dt.dbankcloud.ru,datacollector-drru.dt.hicloud.com", + "collector_url_sg": "datacollector-dra.dt.hicloud.com,datacollector-dra.dt.dbankcloud.cn", + "resource_id": "p1", + "channel_id": "" + }, + "ml": { + "mlservice_url": "ml-api-drcn.ai.dbankcloud.com,ml-api-drcn.ai.dbankcloud.cn" + }, + "cloudstorage": { + "storage_url": "https://agc-storage-drcn.platform.dbankcloud.cn", + "storage_url_ru": "https://agc-storage-drru.cloud.huawei.ru", + "storage_url_sg": "https://ops-dra.agcstorage.link", + "storage_url_de": "https://ops-dre.agcstorage.link", + "storage_url_cn": "https://agc-storage-drcn.platform.dbankcloud.cn", + "storage_url_ru_back": "https://agc-storage-drru.cloud.huawei.ru", + "storage_url_sg_back": "https://agc-storage-dra.cloud.huawei.asia", + "storage_url_de_back": "https://agc-storage-dre.cloud.huawei.eu", + "storage_url_cn_back": "https://agc-storage-drcn.cloud.huawei.com.cn" + }, + "search": { + "url": "https://search-drcn.cloud.huawei.com" + }, + "edukit": { + "edu_url": "edukit.cloud.huawei.com.cn", + "dh_url": "edukit.cloud.huawei.com.cn" + } + }, + "region": "CN", + "configuration_version": "3.0", + "appInfos": [ + { + "package_name": "com.taihe.mianhuatang", + "client": { + "app_id": "112547949" + }, + "app_info": { + "package_name": "com.taihe.mianhuatang", + "app_id": "112547949" + }, + "oauth_client": { + "client_type": 1, + "client_id": "112547949" + } + } + ] +} \ No newline at end of file diff --git a/android/app/agconnect-services.json b/android/app/agconnect-services.json new file mode 100644 index 0000000..3fe0733 --- /dev/null +++ b/android/app/agconnect-services.json @@ -0,0 +1,96 @@ +{ + "agcgw": { + "url": "connect-drcn.dbankcloud.cn", + "backurl": "connect-drcn.hispace.hicloud.com", + "websocketurl": "connect-ws-drcn.hispace.dbankcloud.cn", + "websocketbackurl": "connect-ws-drcn.hispace.dbankcloud.com" + }, + "agcgw_all": { + "SG": "connect-dra.dbankcloud.cn", + "SG_back": "connect-dra.hispace.hicloud.com", + "CN": "connect-drcn.dbankcloud.cn", + "CN_back": "connect-drcn.hispace.hicloud.com", + "RU": "connect-drru.hispace.dbankcloud.ru", + "RU_back": "connect-drru.hispace.dbankcloud.cn", + "DE": "connect-dre.dbankcloud.cn", + "DE_back": "connect-dre.hispace.hicloud.com" + }, + "websocketgw_all": { + "SG": "connect-ws-dra.hispace.dbankcloud.cn", + "SG_back": "connect-ws-dra.hispace.dbankcloud.com", + "CN": "connect-ws-drcn.hispace.dbankcloud.cn", + "CN_back": "connect-ws-drcn.hispace.dbankcloud.com", + "RU": "connect-ws-drru.hispace.dbankcloud.ru", + "RU_back": "connect-ws-drru.hispace.dbankcloud.cn", + "DE": "connect-ws-dre.hispace.dbankcloud.cn", + "DE_back": "connect-ws-dre.hispace.dbankcloud.com" + }, + "client": { + "cp_id": "30086000818558366", + "product_id": "461323198430218911", + "client_id": "1752291009686950144", + "client_secret": "2D92A4B951C2B074A5234F598A0E44013881695DBA64641CE8DC3C634D34F9A0", + "project_id": "461323198430218911", + "app_id": "112547949", + "api_key": "DgEDACTa5j3V2cs2rlYwcsYwsuVj29t4cw4JDcBeRG1H3YurPML3W8D5iS6whNQPnwpZTrvPZiGoRF9bDVvi/hDJSJZp+/D+T71/lw==", + "package_name": "com.taihe.mianhuatang" + }, + "oauth_client": { + "client_id": "112547949", + "client_type": 1 + }, + "app_info": { + "app_id": "112547949", + "package_name": "com.taihe.mianhuatang" + }, + "service": { + "analytics": { + "collector_url": "datacollector-drcn.dt.hicloud.com,datacollector-drcn.dt.dbankcloud.cn", + "collector_url_cn": "datacollector-drcn.dt.hicloud.com,datacollector-drcn.dt.dbankcloud.cn", + "collector_url_de": "datacollector-dre.dt.hicloud.com,datacollector-dre.dt.dbankcloud.cn", + "collector_url_ru": "datacollector-drru.dt.dbankcloud.ru,datacollector-drru.dt.hicloud.com", + "collector_url_sg": "datacollector-dra.dt.hicloud.com,datacollector-dra.dt.dbankcloud.cn", + "resource_id": "p1", + "channel_id": "" + }, + "ml": { + "mlservice_url": "ml-api-drcn.ai.dbankcloud.com,ml-api-drcn.ai.dbankcloud.cn" + }, + "cloudstorage": { + "storage_url": "https://agc-storage-drcn.platform.dbankcloud.cn", + "storage_url_ru": "https://agc-storage-drru.cloud.huawei.ru", + "storage_url_sg": "https://ops-dra.agcstorage.link", + "storage_url_de": "https://ops-dre.agcstorage.link", + "storage_url_cn": "https://agc-storage-drcn.platform.dbankcloud.cn", + "storage_url_ru_back": "https://agc-storage-drru.cloud.huawei.ru", + "storage_url_sg_back": "https://agc-storage-dra.cloud.huawei.asia", + "storage_url_de_back": "https://agc-storage-dre.cloud.huawei.eu", + "storage_url_cn_back": "https://agc-storage-drcn.cloud.huawei.com.cn" + }, + "search": { + "url": "https://search-drcn.cloud.huawei.com" + }, + "edukit": { + "edu_url": "edukit.cloud.huawei.com.cn", + "dh_url": "edukit.cloud.huawei.com.cn" + } + }, + "region": "CN", + "configuration_version": "3.0", + "appInfos": [ + { + "package_name": "com.taihe.mianhuatang", + "client": { + "app_id": "112547949" + }, + "app_info": { + "package_name": "com.taihe.mianhuatang", + "app_id": "112547949" + }, + "oauth_client": { + "client_type": 1, + "client_id": "112547949" + } + } + ] +} \ No newline at end of file diff --git a/android/app/build.gradle b/android/app/build.gradle index d8cf165..885a069 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -4,6 +4,8 @@ plugins { // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. id "dev.flutter.flutter-gradle-plugin" } +//打包太和e护需要屏蔽这个插件 +apply plugin: 'com.huawei.agconnect' def localProperties = new Properties() def localPropertiesFile = rootProject.file("local.properties") @@ -36,8 +38,8 @@ if (flutterVersionName == null) { } android { - namespace = "com.taihe.vbvs_app" - // namespace = "com.taihe.mianhuatang" + // namespace = "com.taihe.vbvs_app" + namespace = "com.taihe.mianhuatang" // compileSdk = flutter.compileSdkVersion compileSdk = localProperties.getProperty('flutter.compileSdkVersion').toInteger() @@ -56,8 +58,8 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "com.taihe.vbvs_app" - // applicationId "com.taihe.mianhuatang" + // applicationId "com.taihe.vbvs_app" + applicationId "com.taihe.mianhuatang" // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. // minSdk = flutter.minSdkVersion @@ -66,6 +68,27 @@ android { targetSdk = localProperties.getProperty('flutter.targetSdkVersion').toInteger() versionCode = flutterVersionCode.toInteger() versionName = flutterVersionName + + ndk { + //选择要添加的对应 cpu 类型的 .so 库。 + abiFilters 'armeabi', 'armeabi-v7a', 'x86', 'x86_64', 'mips', 'mips64', 'arm64-v8a' + } + + manifestPlaceholders = [ + JPUSH_PKGNAME : "com.taihe.mianhuatang", + JPUSH_APPKEY : "ef31d487137311ed3d63ea7d", // NOTE: JPush 上注册的包名对应的 Appkey. + JPUSH_CHANNEL : "developer-default", //暂时填写默认值即可. + XIAOMI_APPKEY : "MI-5152036593702", // 小米平台注册的appkey,注意不要将前缀去掉 MI-appkey + XIAOMI_APPID : "MI-2882303761520365702", // 小米平台注册的appid,注意不要将前缀去掉 MI-appid + VIVO_APPKEY : "a296a05be8eca520e4d44b0c6495353f", + VIVO_APPID : "105824696", + HONOR_APPID : "900905976", + OPPO_APPKEY : "OP-5233131f213a440dbdb74eb1552b9dee", // OPPO平台注册的appkey + OPPO_APPID : "OP-32509325", // OPPO平台注册的appid + OPPO_APPSECRET: "OP-ba89d834fa4248318074dd19d2f1ac92"//OPPO平台注册的appsecret + ] + + resValue "string", "applicationName", "com.taihe.mianhuatang.MyApplication" } signingConfigs { @@ -107,3 +130,40 @@ static def releaseTime() { flutter { source = "../.." } + +dependencies { + // implementation fileTree(dir: "libs", include: ["*.jar", "*.aar"]) + // 此处以JPush 5.6.0 版本为例,注意:从 5.0.0 版本开始可以自动拉取 JCore 包,无需另外配置 + implementation 'cn.jiguang.sdk:jpush:5.6.0' + + //若不集成厂商通道,可直接跳过以下依赖 + // 极光厂商插件版本与接入 JPush 版本保持一致,下同 + // 接入华为厂商 + implementation 'com.huawei.hms:push:6.13.0.300' + implementation 'cn.jiguang.sdk.plugin:huawei:5.6.0' + + // 接入 FCM 厂商 + implementation 'com.google.firebase:firebase-messaging:24.1.0' + implementation 'cn.jiguang.sdk.plugin:fcm:5.6.0' + + // 接入 VIVO 厂商 + implementation 'cn.jiguang.sdk.plugin:vivo:5.6.0' + + + // 接入小米厂商 + implementation 'cn.jiguang.sdk.plugin:xiaomi:5.6.0' + + // // 接入 OPPO 厂商 + implementation 'cn.jiguang.sdk.plugin:oppo:5.6.0' + // // JPush Android SDK v4.6.0 开始,需要单独引入 oppo 厂商 aar ,请下载官网 SDK 包并把 jpush-android-xxx-release/third-push/oppo/libs 下的 aar 文件单独拷贝一份到应用 module/libs 下 + implementation(name: 'com.heytap.msp_3.5.3', ext: 'aar') + // //以下为 OPPO 3.1.0 aar需要依赖 + implementation 'com.google.code.gson:gson:2.10.1' + implementation 'commons-codec:commons-codec:1.6' + implementation 'androidx.annotation:annotation:1.1.0' + + // 接入荣耀厂商 + implementation 'cn.jiguang.sdk.plugin:honor:5.6.0' + // //需要单独引入荣耀厂商 aar ,请下载官网 SDK 包并把 jpush-android-xxx-release/third-push/honor/libs 下的 aar 文件单独拷贝一份到应用 module/libs 下 + implementation(name: 'HiPushSDK-8.0.12.307', ext: 'aar') + } \ No newline at end of file diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 12e1dc6..d81786d 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } android { - namespace = "com.taihe.vbvs_app" + namespace = "com.taihe.mianhuatang" compileSdk = flutter.compileSdkVersion ndkVersion = flutter.ndkVersion @@ -21,7 +21,7 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId = "com.taihe.vbvs_app" + applicationId = "com.taihe.mianhuatang" // You can update the following values to match your application needs. // For more information, see: https://flutter.dev/to/review-gradle-config. minSdk = flutter.minSdkVersion diff --git a/android/app/libs/HiPushSDK-8.0.12.307.aar b/android/app/libs/HiPushSDK-8.0.12.307.aar new file mode 100644 index 0000000..c6514d7 Binary files /dev/null and b/android/app/libs/HiPushSDK-8.0.12.307.aar differ diff --git a/android/app/libs/com.heytap.msp_3.5.3.aar b/android/app/libs/com.heytap.msp_3.5.3.aar new file mode 100644 index 0000000..b2b7631 Binary files /dev/null and b/android/app/libs/com.heytap.msp_3.5.3.aar differ diff --git a/android/app/src/agconnect-services.json b/android/app/src/agconnect-services.json new file mode 100644 index 0000000..a037629 --- /dev/null +++ b/android/app/src/agconnect-services.json @@ -0,0 +1 @@ +{"agcgw":{"url":"connect-drcn.dbankcloud.cn","backurl":"connect-drcn.hispace.hicloud.com","websocketurl":"connect-ws-drcn.hispace.dbankcloud.cn","websocketbackurl":"connect-ws-drcn.hispace.dbankcloud.com"},"agcgw_all":{"SG":"connect-dra.dbankcloud.cn","SG_back":"connect-dra.hispace.hicloud.com","CN":"connect-drcn.dbankcloud.cn","CN_back":"connect-drcn.hispace.hicloud.com","RU":"connect-drru.hispace.dbankcloud.ru","RU_back":"connect-drru.hispace.dbankcloud.cn","DE":"connect-dre.dbankcloud.cn","DE_back":"connect-dre.hispace.hicloud.com"},"websocketgw_all":{"SG":"connect-ws-dra.hispace.dbankcloud.cn","SG_back":"connect-ws-dra.hispace.dbankcloud.com","CN":"connect-ws-drcn.hispace.dbankcloud.cn","CN_back":"connect-ws-drcn.hispace.dbankcloud.com","RU":"connect-ws-drru.hispace.dbankcloud.ru","RU_back":"connect-ws-drru.hispace.dbankcloud.cn","DE":"connect-ws-dre.hispace.dbankcloud.cn","DE_back":"connect-ws-dre.hispace.dbankcloud.com"},"client":{"cp_id":"30086000818558366","product_id":"461323198430218911","client_id":"1752291009686950144","client_secret":"2D92A4B951C2B074A5234F598A0E44013881695DBA64641CE8DC3C634D34F9A0","project_id":"461323198430218911","app_id":"112547949","api_key":"DgEDACTa5j3V2cs2rlYwcsYwsuVj29t4cw4JDcBeRG1H3YurPML3W8D5iS6whNQPnwpZTrvPZiGoRF9bDVvi/hDJSJZp+/D+T71/lw==","package_name":"com.taihe.mianhuatang"},"oauth_client":{"client_id":"112547949","client_type":1},"app_info":{"app_id":"112547949","package_name":"com.taihe.mianhuatang"},"service":{"analytics":{"collector_url":"datacollector-drcn.dt.hicloud.com,datacollector-drcn.dt.dbankcloud.cn","collector_url_cn":"datacollector-drcn.dt.hicloud.com,datacollector-drcn.dt.dbankcloud.cn","collector_url_de":"datacollector-dre.dt.hicloud.com,datacollector-dre.dt.dbankcloud.cn","collector_url_ru":"datacollector-drru.dt.dbankcloud.ru,datacollector-drru.dt.hicloud.com","collector_url_sg":"datacollector-dra.dt.hicloud.com,datacollector-dra.dt.dbankcloud.cn","resource_id":"p1","channel_id":""},"ml":{"mlservice_url":"ml-api-drcn.ai.dbankcloud.com,ml-api-drcn.ai.dbankcloud.cn"},"cloudstorage":{"storage_url":"https://agc-storage-drcn.platform.dbankcloud.cn","storage_url_ru":"https://agc-storage-drru.cloud.huawei.ru","storage_url_sg":"https://ops-dra.agcstorage.link","storage_url_de":"https://ops-dre.agcstorage.link","storage_url_cn":"https://agc-storage-drcn.platform.dbankcloud.cn","storage_url_ru_back":"https://agc-storage-drru.cloud.huawei.ru","storage_url_sg_back":"https://agc-storage-dra.cloud.huawei.asia","storage_url_de_back":"https://agc-storage-dre.cloud.huawei.eu","storage_url_cn_back":"https://agc-storage-drcn.cloud.huawei.com.cn"},"search":{"url":"https://search-drcn.cloud.huawei.com"},"edukit":{"edu_url":"edukit.cloud.huawei.com.cn","dh_url":"edukit.cloud.huawei.com.cn"}},"region":"CN","configuration_version":"3.0","appInfos":[{"package_name":"com.taihe.mianhuatang","client":{"app_id":"112547949"},"app_info":{"package_name":"com.taihe.mianhuatang","app_id":"112547949"},"oauth_client":{"client_type":1,"client_id":"112547949"}}]} \ No newline at end of file diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index cfd945b..2369378 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -40,15 +40,18 @@ + + + + _getLogFile() async { final dir = await getApplicationDocumentsDirectory(); final date = DateFormat('yyyy-MM-dd').format(DateTime.now()); - final filePath = '${dir.path}/$date.log'; - final file = File(filePath); + final file = File('${dir.path}/$date.log'); if (!await file.exists()) { await file.create(recursive: true); } return file; } - // 写入日志核心方法,带日志等级 + // 写日志核心方法,带日志等级,固定 UTF-8 static Future _writeLogWithLevel(String level, String content) async { final file = await _getLogFile(); final now = DateTime.now(); final time = DateFormat('HH:mm:ss').format(now); final logLine = '[$time][$level] $content\n'; - await file.writeAsString(logLine, mode: FileMode.append); + await file.writeAsString(logLine, mode: FileMode.append, encoding: utf8); } - // 写入 info 日志(原 writeLog 保留) + // Info 日志 static Future writeLog(String content) async { - print("[dailylog-->info] $content]"); + print("[dailylog-->info] $content"); await _writeLogWithLevel('INFO', content); } - // 写入 warning 日志 + // Warning 日志 static Future writeWarning(String content) async { - print("[dailylog-->waring] $content]"); + print("[dailylog-->warning] $content"); await _writeLogWithLevel('WARNING', content); } - // 写入 error 日志 + // Error 日志 static Future writeError(String content) async { - print("[dailylog-->error] $content]"); + print("[dailylog-->error] $content"); await _writeLogWithLevel('ERROR', content); } - // 写入 debug 日志 + // Debug 日志 static Future writeDebug(String content) async { - print("[dailylog-->debug] $content]"); + print("[dailylog-->debug] $content"); await _writeLogWithLevel('DEBUG', content); } - static Future printLog(String content) async { - print("logger--->" + content); - // await writeLog(content); - } - - // 读取当天日志 + // 读取当天日志,容错 UTF-8 static Future readTodayLog() async { final file = await _getLogFile(); - return await file.readAsString(); + try { + return await file.readAsString(encoding: utf8); + } catch (e) { + final bytes = await file.readAsBytes(); + return utf8.decode(bytes, allowMalformed: true); + } } - // 获取所有日志文件(返回 File 列表) + // 获取所有日志文件 static Future> listLogFiles() async { final dir = await getApplicationDocumentsDirectory(); final files = dir.listSync(); @@ -75,7 +76,7 @@ class DailyLogUtils { } } - /// 获取指定日期范围内的日志文件(包含起止日期) + // 获取指定日期范围内日志文件 static Future> getLogsBetween( DateTime fromDate, DateTime toDate) async { final dir = await getApplicationDocumentsDirectory(); @@ -85,16 +86,14 @@ class DailyLogUtils { for (DateTime date = fromDate; !date.isAfter(toDate); date = date.add(Duration(days: 1))) { - final fileName = '${dateFormat.format(date)}.log'; - final file = File('${dir.path}/$fileName'); - if (await file.exists()) { - logFiles.add(file); - } + final file = File('${dir.path}/${dateFormat.format(date)}.log'); + if (await file.exists()) logFiles.add(file); } return logFiles; } + // 读取日期范围内日志,合并返回 static Future readLogsByDateRange( DateTime fromDate, DateTime toDate) async { try { @@ -102,43 +101,80 @@ class DailyLogUtils { final dateFormat = DateFormat('yyyy-MM-dd'); String combinedLogs = ''; - // 遍历从 fromDate 到 toDate 的日期 for (DateTime date = fromDate; !date.isAfter(toDate); date = date.add(Duration(days: 1))) { - final dateStr = dateFormat.format(date); // 格式化日期 - final file = File('${dir.path}/$dateStr.log'); // 日志文件路径 - + final file = File('${dir.path}/${dateFormat.format(date)}.log'); if (await file.exists()) { - final logContent = await file.readAsString(); - combinedLogs += '日志日期: $dateStr\n$logContent\n\n'; // 合并日志内容 + String content; + try { + content = await file.readAsString(encoding: utf8); + } catch (_) { + final bytes = await file.readAsBytes(); + content = utf8.decode(bytes, allowMalformed: true); + } + combinedLogs += '日志日期: ${dateFormat.format(date)}\n$content\n\n'; } } - if (combinedLogs.isNotEmpty) { - return combinedLogs; // 返回合并后的日志 - } else { - return '该时间段内没有日志记录'; // 如果没有日志 - } + return combinedLogs.isNotEmpty ? combinedLogs : '该时间段内没有日志记录'; } catch (e) { return '读取日志失败: $e'; } } - // 添加分享功能 - // static Future exportLog(DateTime date) async { - // try { - // final dir = await getApplicationDocumentsDirectory(); - // final dateStr = DateFormat('yyyy-MM-dd').format(date); - // final file = File('${dir.path}/$dateStr.log'); - // if (await file.exists()) { - // await Share.shareXFiles( - // [XFile(file.path)], - // text: '应用日志 $dateStr', - // ); - // } - // } catch (e) { - // print('导出日志失败: $e'); - // } - // } + // 导出所有日志为 zip 并分享(系统分享) + static Future exportAllLogs() async { + try { + final dir = await getApplicationDocumentsDirectory(); + final dateStr = DateFormat('yyyy-MM-dd_HH-mm-ss').format(DateTime.now()); + final zipPath = '${dir.path}/logs_$dateStr.zip'; + + final archive = Archive(); + + // 遍历日志文件 + final logFiles = dir + .listSync() + .whereType() + .where((f) => f.path.endsWith('.log') && f.existsSync()); + + if (logFiles.isEmpty) { + print("没有日志文件可压缩!"); + return; + } + + for (var file in logFiles) { + final name = file.path.split('/').last; + final bytes = await file.readAsBytes(); // 读取原始字节 + final content = + utf8.decode(bytes, allowMalformed: true); // 转 UTF-8,允许非 UTF-8 + final utf8Bytes = utf8.encode(content); // 写入压缩包 + archive.addFile(ArchiveFile(name, utf8Bytes.length, utf8Bytes)); + print("添加日志文件: ${file.path}, 大小: ${utf8Bytes.length}"); + } + + // 写入 zip 文件 + final zipData = ZipEncoder().encode(archive); + final zipFile = File(zipPath); + await zipFile.writeAsBytes(zipData!); + + print("压缩包生成成功: ${zipFile.path}, 大小: ${await zipFile.length()} 字节"); + + // 分享 + await Share.shareXFiles([XFile(zipFile.path)], text: '应用日志打包 $dateStr'); + } catch (e) { + print('导出日志失败: $e'); + } + } + + static Future printLog(String content) async { + print("logger---> $content"); + // 如果你希望顺便写入 info 日志,也可以取消下面注释 + // await writeLog(content); + } + + static Future readLogByDate(DateTime date) async { + // 调用 readLogsByDateRange,fromDate 和 toDate 都是同一天 + return await readLogsByDateRange(date, date); + } } diff --git a/lib/common/util/JPushUtil.dart b/lib/common/util/JPushUtil.dart new file mode 100644 index 0000000..6975322 --- /dev/null +++ b/lib/common/util/JPushUtil.dart @@ -0,0 +1,196 @@ +import 'dart:convert'; +import 'dart:io'; + +import 'package:EasyDartModule/EasyDartModule.dart'; +import 'package:get/get.dart'; +import 'package:get_storage/get_storage.dart'; +import 'package:jpush_flutter/jpush_flutter.dart'; +import 'package:jpush_flutter/jpush_interface.dart'; +import 'package:permission_handler/permission_handler.dart'; +import 'package:vbvs_app/common/util/DailyLogUtils.dart'; +import 'package:vbvs_app/common/util/NotificationRouteManager.dart'; +import 'package:vbvs_app/controller/user_info_controller.dart'; + +class JPushUtil { + static final JPushFlutterInterface _jpush = JPush.newJPush(); + static final GetStorage box = GetStorage(); + + /// 初始化极光推送 + static Future initJPush() async { + // 先申请通知权限 + await _requestNotificationPermission(); + + // 初始化 JPush + _jpush.setup( + appKey: 'ef31d487137311ed3d63ea7d', // 替换为你在极光控制台获取的 appKey + channel: 'developer-default', + production: true, + debug: false, + ); + + // 获取 RegistrationID + _jpush.getRegistrationID().then((rid) { + EasyDartModule.logger.info("[消息推送]flutter get registration id: $rid"); + print("flutter get registration id : $rid"); + box.write('rid', rid); + }); + + // 添加推送消息回调 + _jpush.addEventHandler( + onReceiveNotification: (Map message) async { + print("接收到通知: $message"); + EasyDartModule.logger.info("[消息推送]接收到通知: $message"); + }, + onOpenNotification: (Map message) async { + print("通知打开: $message"); + EasyDartModule.logger.info("[消息推送]通知打开: $message"); + openAppRouteByNotification(message); + }, + onReceiveMessage: (Map message) async { + print("接收到自定义消息: $message"); + EasyDartModule.logger.info("[消息推送]接收到自定义消息: $message"); + }, + ); + } + + /// 请求通知权限 + static Future _requestNotificationPermission() async { + if (Platform.isIOS) { + _jpush.applyPushAuthority(const NotificationSettingsIOS( + sound: true, + alert: true, + badge: true, + )); + } else if (Platform.isAndroid) { + var status = await Permission.notification.status; + if (status.isDenied) { + await Permission.notification.request(); + } + } + } + + /// 根据通知跳转页面 + // static Future openAppRouteByNotification( + // Map message) async { + // try { + // int type = message['extras']['cn.jpush.android.EXTRA']['mType']; + // if (type == 1) { + // var person = + // jsonDecode(message['extras']['cn.jpush.android.EXTRA']['person']); + // String mac = person['mac']; + // UserInfoController userInfoController = Get.find(); + + // if (userInfoController.model.login == 0) { + // box.write("needSleepReport", "true"); + // box.write("needSleepReport_person", person); + // box.write("needSleepReport_mac", mac); + // Get.toNamed("/loginPage"); + // } else { + // Get.toNamed( + // "/newSleepReportPage", + // arguments: { + // 'mac': mac, + // 'type': 1, + // "person": person, + // 'backgroundImg': 'assets/images/new_background.png', + // 'date': DateTime.now().millisecondsSinceEpoch, + // 'person_show': false, + // 'reportPadding': false, + // }, + // ); + // } + // } + // } catch (e) { + // EasyDartModule.logger.error("[打开APP异常]:$e"); + // DailyLogUtils.writeError("[打开APP异常]:$e"); + // } + // } + // static Future openAppRouteByNotification( + // Map message) async { + // try { + // int type = message['extras']['cn.jpush.android.EXTRA']['mType']; + // if (type == 1) { + // var person = + // jsonDecode(message['extras']['cn.jpush.android.EXTRA']['person']); + // String mac = person['mac']; + // UserInfoController userInfoController = Get.find(); + + // if (userInfoController.model.login == 0) { + // // 登录状态为 0,先保存需要跳转的标记 + // box.write("needSleepReport", "true"); + // box.write("needSleepReport_person", person); + // box.write("needSleepReport_mac", mac); + + // // 这里不要直接跳转,改为保存一个待跳转路由 + // box.write("pendingRoute", { + // "route": "/loginPage", + // "arguments": null, + // }); + // } else { + // // 已登录,保存跳转参数 + // box.write("pendingRoute", { + // "route": "/newSleepReportPage", + // "arguments": { + // 'mac': mac, + // 'type': 1, + // "person": person, + // 'backgroundImg': 'assets/images/new_background.png', + // 'date': DateTime.now().millisecondsSinceEpoch, + // 'person_show': false, + // 'reportPadding': false, + // } + // }); + // } + // } + // } catch (e) { + // EasyDartModule.logger.error("[打开APP异常]:$e"); + // DailyLogUtils.writeError("[打开APP异常]:$e"); + // } + // } + static Future openAppRouteByNotification( + Map message) async { + try { + int type = message['extras']['cn.jpush.android.EXTRA']['mType']; + if (type == 1) { + var person = + jsonDecode(message['extras']['cn.jpush.android.EXTRA']['person']); + String mac = person['mac']; + UserInfoController userInfoController = Get.find(); + + if (userInfoController.model.login == 0) { + NotificationRouteManager().box.write("needSleepReport", "true"); + NotificationRouteManager() + .box + .write("needSleepReport_person", person); + NotificationRouteManager().box.write("needSleepReport_mac", mac); + + NotificationRouteManager().savePendingRoute("/loginPage"); + } else { + NotificationRouteManager().savePendingRoute( + "/newSleepReportPage", + arguments: { + 'mac': mac, + 'type': 1, + "person": person, + 'backgroundImg': 'assets/images/new_background.png', + 'date': DateTime.now().millisecondsSinceEpoch, + 'person_show': false, + 'reportPadding': false, + }, + ); + } + + /// 如果 APP 已经在前台,立即处理跳转 + NotificationRouteManager().handlePendingRoute(); + } + } catch (e) { + EasyDartModule.logger.error("[打开APP异常]:$e"); + DailyLogUtils.writeError("[打开APP异常]:$e"); + } + } + + /// 获取 RegistrationID + static Future getRegistrationID() async { + return await _jpush.getRegistrationID(); + } +} diff --git a/lib/common/util/MyUtils.dart b/lib/common/util/MyUtils.dart index cdacbb1..8ec7d57 100644 --- a/lib/common/util/MyUtils.dart +++ b/lib/common/util/MyUtils.dart @@ -20,6 +20,11 @@ LanguageController languageController = Get.find(); MHLanguageController mhLanguageController = Get.find(); class MyUtils { + + static String formatTimestampToSleep(int milliseconds) { + final date = DateTime.fromMillisecondsSinceEpoch(milliseconds); + return "${date.year}-${date.month}-${date.day}"; + } static String formatDate(DateTime dateTime) { return "${dateTime.year}-${dateTime.month}-${dateTime.day.toString().padLeft(2, '0')}"; } diff --git a/lib/common/util/NotificationRouteManager.dart b/lib/common/util/NotificationRouteManager.dart new file mode 100644 index 0000000..b0aab74 --- /dev/null +++ b/lib/common/util/NotificationRouteManager.dart @@ -0,0 +1,33 @@ +import 'package:ef/ef.dart'; +import 'package:get_storage/get_storage.dart'; + +/// 单例通知路由管理 +class NotificationRouteManager { + static final NotificationRouteManager _instance = + NotificationRouteManager._internal(); + factory NotificationRouteManager() => _instance; + NotificationRouteManager._internal(); + + final box = GetStorage(); + + /// 保存待跳转的路由 + void savePendingRoute(String route, {Map? arguments}) { + box.write("pendingRoute", { + "route": route, + "arguments": arguments, + }); + } + + /// 立即尝试执行跳转(如果 GetMaterialApp 已就绪) + void handlePendingRoute() { + var pending = box.read("pendingRoute"); + if (pending != null) { + String route = pending["route"]; + var args = pending["arguments"]; + Future.delayed(const Duration(milliseconds: 200), () { + Get.toNamed(route, arguments: args); + }); + box.remove("pendingRoute"); + } + } +} diff --git a/lib/controller/device/blueteeth_bind_controller.dart b/lib/controller/device/blueteeth_bind_controller.dart index c866d8a..a8c6b29 100644 --- a/lib/controller/device/blueteeth_bind_controller.dart +++ b/lib/controller/device/blueteeth_bind_controller.dart @@ -110,8 +110,8 @@ class BlueteethBindController extends GetControllerEx { updateAll(); } else { safeShowNotification(res.msg ?? "获取设备状态异常"); - EasyDartModule.logger.info("获取设备状态异常: $res"); - DailyLogUtils.writeLog("获取设备状态异常: $res"); + // EasyDartModule.logger.info("获取设备状态异常: $res"); + // DailyLogUtils.writeLog("获取设备状态异常: $res"); } }); @@ -122,8 +122,8 @@ class BlueteethBindController extends GetControllerEx { updateAll(); } else { safeShowNotification(res.msg ?? "获取设备状态异常"); - EasyDartModule.logger.info("获取设备状态异常: $res"); - DailyLogUtils.writeLog("获取设备状态异常: $res"); + // EasyDartModule.logger.info("获取设备状态异常: $res"); + // DailyLogUtils.writeLog("获取设备状态异常: $res"); } }).catchError((e, stack) { print("updateDeviceStatus 执行异常: $e\n$stack"); @@ -140,127 +140,6 @@ class BlueteethBindController extends GetControllerEx { _statusTimer = null; } - // Future updateDeviceStatus() async { - // try { - // String serviceAddress = ServiceConstant.service_address; - // String serviceName = ServiceConstant.server_service; - // String serviceApi = ServiceConstant.get_bluetooth_device_status; - // String queryUrl = "$serviceAddress$serviceName$serviceApi"; - - // if (model.devicelist != null && model.devicelist!.isNotEmpty) { - // final macParams = model.devicelist! - // .map((device) => "mac=${Uri.encodeQueryComponent(device.mac!)}") - // .join("&"); - - // if (queryUrl.contains('?')) { - // queryUrl += '&$macParams'; - // } else { - // queryUrl += '?$macParams'; - // } - // String? language = ""; - // if (languageController.selectLanguage != null) { - // language = languageController.selectLanguage.value!.language_code; - // } - // if (language != null && language.isNotEmpty) { - // if (queryUrl.contains("?")) { - // queryUrl += "&lang=$language"; - // } else { - // queryUrl += "?lang=$language"; - // } - // } - - // var response = await EasyDartModule.dio.get(queryUrl); - // var responseData = - // response.data is String ? jsonDecode(response.data) : response.data; - // ApiResponse res = - // ApiResponse.fromJson(responseData, (object) => object); - // if (res.code != HttpStatusCodes.ok) return res; - - // if (response.data['data'] != null && response.data['data'] is List) { - // List responseList = response.data['data']; - - // // 构建 mac -> 设备的映射 - // Map deviceMap = { - // for (var d in model.devicelist!) - // if (d.mac != null) d.mac!.toLowerCase(): d, - // }; - - // // 用于记录已经设置过主从关系的 mac,避免重复 - // Set processedMacs = {}; - - // for (var item in responseList) { - // String mac = item['mac'].toLowerCase(); - // String? bindMac = item['bindMac']?.toLowerCase(); - // bool? bind = item['bind']; - - // if (!deviceMap.containsKey(mac)) continue; - - // BleDeviceData currentDevice = deviceMap[mac]!; - // currentDevice.bind = bind; - - // if (bindMac != null && deviceMap.containsKey(bindMac)) { - // final isMutualBind = responseList.any((e) => - // e['mac']?.toString().toLowerCase() == bindMac && - // e['bindMac']?.toString().toLowerCase() == mac); - - // if (isMutualBind) { - // if (processedMacs.contains(mac) || - // processedMacs.contains(bindMac)) { - // continue; - // } - - // final masterMac = (mac.compareTo(bindMac) < 0) ? mac : bindMac; - // final slaveMac = (mac.compareTo(bindMac) < 0) ? bindMac : mac; - - // if (deviceMap.containsKey(masterMac) && - // deviceMap.containsKey(slaveMac)) { - // deviceMap[masterMac]!.slave = deviceMap[slaveMac]; - // processedMacs.add(masterMac); - // processedMacs.add(slaveMac); - // } - // } else { - // if (!processedMacs.contains(mac)) { - // BleDeviceData masterDevice = deviceMap[bindMac]!; - // masterDevice.slave = currentDevice; - // processedMacs.add(mac); - // processedMacs.add(bindMac); - // } - // } - // } - // } - - // // 获取所有被作为 slave 的 mac,用于排除掉 - // final Set allSlaveMacs = { - // for (var d in deviceMap.values) - // if (d.slave?.mac != null) d.slave!.mac!.toLowerCase() - // }; - - // // 构造最终列表,只保留主设备和未被作为 slave 的独立设备 - // final List finalList = deviceMap.values.where((d) { - // final mac = d.mac?.toLowerCase(); - // if (mac == null) return false; - // if (d.slave != null) return true; // 主设备 - // return !allSlaveMacs.contains(mac); // 不是别人 slave 的独立设备 - // }).toList(); - - // model.betDevicelist = finalList; - // } else { - // model.betDevicelist = []; - // } - - // updateAll(); - // return res; - // } - // } catch (e) { - // print("获取设备状态异常: $e"); - // EasyDartModule.logger.info("获取设备状态异常: $e"); - // DailyLogUtils.writeLog("获取设备状态异常: $e"); - // return ApiResponse(code: -1, msg: "请求失败".tr); - // } - - // return ApiResponse(code: -1, msg: "未知错误".tr); - // } - Future updateDeviceStatus() async { try { String serviceAddress = ServiceConstant.service_address; @@ -334,8 +213,8 @@ class BlueteethBindController extends GetControllerEx { } } catch (e) { print("获取设备状态异常: $e"); - EasyDartModule.logger.info("获取设备状态异常: $e"); - DailyLogUtils.writeLog("获取设备状态异常: $e"); + // EasyDartModule.logger.info("获取设备状态异常: $e"); + // DailyLogUtils.writeLog("获取设备状态异常: $e"); return ApiResponse(code: -1, msg: "请求失败".tr); } diff --git a/lib/controller/message/common_message_setting_controller.dart b/lib/controller/message/common_message_setting_controller.dart index 26ed352..b5c0846 100644 --- a/lib/controller/message/common_message_setting_controller.dart +++ b/lib/controller/message/common_message_setting_controller.dart @@ -1,17 +1,19 @@ import 'package:ef/ef.dart'; import 'package:json_annotation/json_annotation.dart'; +import 'package:vbvs_app/common/color/ServiceConstant.dart'; +import 'package:vbvs_app/common/util/requestWithLog.dart'; part 'common_message_setting_controller.g.dart'; // 由json_serializable自动生成的部分 @JsonSerializable() class CommonMessageSettingModel { - int? setting = 0;//总设置 0 关闭 1 开启 - int? appSetting = 0;//app消息设置 - int? serviceSetting = 0;//服务号消息 - int? tipSetting = 0;//设备放置说明 - int? deviceUpgradeSetting = 0;//设备升级提示 - int? deviceIssueSetting = 0;//设备故障提示 - + int? setting = 0; //总设置 0 关闭 1 开启 + int? appSetting = 0; //app消息设置 + int? serviceSetting = 0; //服务号消息 + int? tipSetting = 0; //设备放置说明 + int? deviceUpgradeSetting = 0; //设备升级提示 + int? deviceIssueSetting = 0; //设备故障提示 + int? sleepReportSetting = 0; //睡眠报告通知 CommonMessageSettingModel(); @@ -30,9 +32,58 @@ class CommonMessageSettingModel { Map toJson() => _$CommonMessageSettingModelToJson(this); } -class CommonMessageSettingController extends GetControllerEx { +class CommonMessageSettingController + extends GetControllerEx { CommonMessageSettingController() { attr = GetModel(CommonMessageSettingModel()).obs; } + Future getAppSleepNotify() async { + String serviceAddress = ServiceConstant.service_address; + String serviceName = ServiceConstant.server_service; + String serviceApi = ServiceConstant.user_setting; + String type = "sleep_report_notify"; + String queryUrl = "${serviceAddress}${serviceName}${serviceApi}?type=$type"; + await requestWithLog( + logTitle: "查询用户睡眠通知消息配置", + method: MyHttpMethod.get, + queryUrl: queryUrl, + onSuccess: (res) { + if (res.data == null) { + model.sleepReportSetting = 1; + } else { + model.sleepReportSetting = res.data["setting"]; + } + updateAll(); + }, + onFailure: (res) { + print(res); + }, + ); + } + + Future updateSleepNotify(bool val) async { + String serviceAddress = ServiceConstant.service_address; + String serviceName = ServiceConstant.server_service; + String serviceApi = ServiceConstant.user_setting; + String type = "sleep_report_notify"; + String queryUrl = "${serviceAddress}${serviceName}${serviceApi}?type=$type"; + var data = { + "type": type, + "setting": val == true ? 1 : 0, + "time": DateTime.now().millisecondsSinceEpoch, + }; + await requestWithLog( + logTitle: "查询用户睡眠通知消息配置", + method: MyHttpMethod.put, + queryUrl: queryUrl, + data: data, + onSuccess: (res) { + updateAll(); + }, + onFailure: (res) { + print(res); + }, + ); + } } diff --git a/lib/controller/user_info_controller.dart b/lib/controller/user_info_controller.dart index 284ac70..53eecf6 100644 --- a/lib/controller/user_info_controller.dart +++ b/lib/controller/user_info_controller.dart @@ -19,6 +19,7 @@ import 'package:vbvs_app/enum/APPPackageType.dart'; import 'package:vbvs_app/model/api_response.dart'; import 'package:vbvs_app/model/user_data.dart'; import 'package:vbvs_app/pages/mh_page/homepage/controller/mht_home_controller.dart'; +import 'package:vbvs_app/pages/mh_page/user/controller/mht_login_controller.dart'; part 'user_info_controller.g.dart'; @@ -241,6 +242,7 @@ class UserInfoController extends GetControllerEx { } ApiResponse logOut() { + updateAppSystemNotify(false); int code = AppConstants().ent_type; if (APPPackageType.MHT.code == code) { MHTHomeController mhtHomeController = Get.find(); @@ -266,6 +268,7 @@ class UserInfoController extends GetControllerEx { messageController.model.system_message_read = 0; CountdownController countdownController = Get.find(); countdownController.countdown.value = 0; + return apiResponse; } diff --git a/lib/main.dart b/lib/main.dart index 993d198..3976f6d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -18,8 +18,10 @@ import 'package:vbvs_app/common/color/appConstants.dart'; import 'package:vbvs_app/common/color/app_uri_status.dart'; import 'package:vbvs_app/common/util/CheckNetwork.dart'; import 'package:vbvs_app/common/util/CommonVariables.dart'; +import 'package:vbvs_app/common/util/DailyLogUtils.dart'; import 'package:vbvs_app/common/util/Dio.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; +import 'package:vbvs_app/common/util/JPushUtil.dart'; import 'package:vbvs_app/common/util/requestWithLog.dart'; import 'package:vbvs_app/controller/date/CalendarController.dart'; import 'package:vbvs_app/controller/device/blueteeth_bind_controller.dart'; @@ -187,8 +189,8 @@ Future initWX() async { Fluwx fluwx = Fluwx(); fluwx.registerApi( //请填写自己的微信appid - appId: "wxeb2688220799e2c5", //太和 - // appId: "wx929c548fea6af9c7", //眠花糖 + // appId: "wxeb2688220799e2c5", //太和 + appId: "wx929c548fea6af9c7", //眠花糖 doOnAndroid: true, doOnIOS: true, // universalLink: "https://app.he-info.com/theh/", @@ -627,17 +629,21 @@ void initEasyDartModule() { try { EasyDartModule.init( loggerConfig: - LoggerConfig(host: ServiceConstant.logService, serviceName: "web"), + LoggerConfig(host: ServiceConstant.logService, serviceName: "智慧眠花糖在线"), webSocketConfig: WebSocketConfig(ServiceConstant.webSocketService, (data) { // 接收到服务消息 var json = jsonDecode(data); ef.log("[websokcet]:${json}"); + EasyDartModule.logger.info("[websokcet数据]:${json}"); + DailyLogUtils.writeLog("[websokcet数据]:${json}"); if (json['wsId'] != null) { ef.kvRoot.websocketId = json['wsId']; } if (json['code'] != null && json['code'] != 200) { - EasyDartModule.logger.error("websocket连接失败--》" + json); + EasyDartModule.logger + .error("[websokcet数据]:websocket连接失败--》" + json); + DailyLogUtils.writeLog("[websokcet数据]:websocket连接失败--》" + json); } if (json["path"] != null) { var call = CommonVariables.callMap[json["path"]]; @@ -653,6 +659,8 @@ void initEasyDartModule() { } } else { print("未找到当前路径: ${json["path"]} 回调函数"); + EasyDartModule.logger.error("未找到当前路径: ${json["path"]} 回调函数"); + DailyLogUtils.writeLog("未找到当前路径: ${json["path"]} 回调函数"); } } // print(data); @@ -664,8 +672,9 @@ void initEasyDartModule() { })); } catch (e) { print(e); + EasyDartModule.logger.error("websocket连接失败--》:$e"); + DailyLogUtils.writeLog("websocket连接失败--》:$e"); } - //初始化 } Future initLogin() async { @@ -692,6 +701,8 @@ Future initLogin() async { EasyDartModule.dio.token = null; } else { userInfoController.model.login = 1; + await JPushUtil.initJPush(); + updateAppSystemNotify(true); } } else { // 如果没有 token,则将用户标记为未登录 @@ -836,6 +847,7 @@ class MyApp extends StatelessWidget { Get.lazyPut(() => UserPdfController()), Get.lazyPut(() => PrivacyPdfController()), Get.lazyPut(() => AuthBindTelController()), + Get.lazyPut(() => CommonMessageSettingController()), ])); } diff --git a/lib/pages/device/instant_body_page.dart b/lib/pages/device/instant_body_page.dart index 344bdc4..8960096 100644 --- a/lib/pages/device/instant_body_page.dart +++ b/lib/pages/device/instant_body_page.dart @@ -40,14 +40,6 @@ class _InstantBodyPageState extends State DeviceTypeController deviceTypeController = Get.find(); int maxBodyMotion = 1; - // String breathState = "否"; - // String inBed = "离床".tr; - // String onlineState = "离线".tr; - // Timer? _onlineTimer; // 添加 Timer 引用 - // int bodyMotion = 0; - // int breathrate = 0; - // String snores = "否".tr; - // int heartrate = 0; String breathState = "-"; String inBed = "-"; String onlineState = "离线".tr; @@ -71,9 +63,22 @@ class _InstantBodyPageState extends State void _initWebSocket() { // 发送WebSocket请求 + if (widget.personInfo['status'] != null) { + try { + onlineState = + widget.personInfo['status']['status'] == 1 ? "在线".tr : "离线".tr; + if (widget.personInfo['status']['status'] != 0) { + inBed = widget.personInfo['status']['inBed'] == 1 ? "在床".tr : "离床".tr; + } + } catch (e) { + edm.EasyDartModule.logger + .error("[webscoekt]格式化数据错误-->${{"mac": widget.personInfo['mac']}}"); + } + } edm.EasyDartModule.logger .info("[webscoekt]发送请求:数据-->${{"mac": widget.personInfo['mac']}}"); - DailyLogUtils.writeLog("[webscoekt]发送请求:数据-->${{"mac": widget.personInfo['mac']}}"); + DailyLogUtils.writeLog( + "[webscoekt]发送请求:数据-->${{"mac": widget.personInfo['mac']}}"); edm.EasyDartModule.websocket.sendData(jsonEncode(WebSocketMessage( path: "/vsbs/web/rt/marttress", type: 1, @@ -105,10 +110,10 @@ class _InstantBodyPageState extends State void _startOnlineTimer() { _onlineTimer?.cancel(); // 取消之前的定时器 - _onlineTimer = Timer.periodic(Duration(seconds: 30), (timer) { + _onlineTimer = Timer.periodic(Duration(seconds: 60), (timer) { if (mounted) { setState(() { - edm.EasyDartModule.logger.info("30 秒内没有接收到数据,设置为离线"); + edm.EasyDartModule.logger.info("60 秒内没有接收到数据,设置为离线"); onlineState = "离线".tr; // 30 秒内没有接收到数据,设置为离线 inBed = "-"; bodyMotion = -1; @@ -124,35 +129,50 @@ class _InstantBodyPageState extends State @override Widget build(BuildContext context) { Map device = widget.personInfo; - CommonVariables.callMap["/vsbs/web/rt/marttress"] = (data) { - inBed = data["inBed"]; - // 心率 呼吸 体动 呼吸暂停 - if ("离床".tr == inBed) { - breathState = "否".tr; - bodyMotion = 0; - breathrate = 0; - heartrate = 0; - snores = "否".tr; - } else { - breathState = data["breathState"] == null || data["breathState"] == "" - ? "-" - : data["breathState"].toString().tr; - - bodyMotion = data['bodyMotion'] == null ? 0 : data['bodyMotion']; - breathrate = data["breathRate"] == null ? 0 : data["breathRate"]; - heartrate = data['heartRate'] == null ? 0 : data['heartRate']; - snores = data['snores'] == null || data['snores'] == "" - ? "否".tr - : data['snores'].tr; - } - - if (mounted) { - setState(() { + try { + CommonVariables.callMap["/vsbs/web/rt/marttress"] = (data) { + if (data['status'] == "离线") { + inBed = "-"; + bodyMotion = -1; + heartrate = -1; + snores = "-"; + breathrate = -1; + breathState = "-"; + return; + } + inBed = data["inBed"]; + // 心率 呼吸 体动 呼吸暂停 + if ("离床".tr == inBed) { + breathState = "否".tr; + bodyMotion = 0; + breathrate = 0; + heartrate = 0; + snores = "否".tr; + } else { onlineState = "在线".tr; // 接收到数据,设置为在线 - }); - } - _startOnlineTimer(); // 重置定时器 - }; + breathState = data["breathState"] == null || data["breathState"] == "" + ? "-" + : data["breathState"].toString().tr; + + bodyMotion = data['bodyMotion'] == null ? -1 : data['bodyMotion']; + breathrate = data["breathRate"] == null ? -1 : data["breathRate"]; + heartrate = data['heartRate'] == null ? -1 : data['heartRate']; + snores = + data['snores'] == null || data['snores'] == "" ? "否".tr : "是".tr; + } + + if (mounted) { + setState(() { + onlineState = "在线".tr; // 接收到数据,设置为在线 + }); + } + _startOnlineTimer(); // 重置定时器 + }; + } catch (e) { + print(e); + edm.EasyDartModule.logger + .error("[webscoekt]格式化数据错误-->${{"mac": widget.personInfo['mac']}}"); + } return LayoutBuilder( builder: (context, bodySize) => GestureDetector( @@ -215,20 +235,6 @@ class _InstantBodyPageState extends State top: true, child: Stack( children: [ - // 背景图只占一半高度 - // Align( - // alignment: Alignment.center, - // child: SizedBox( - // height: 1000.rpx, // 你可以根据需要调整图片最大高度 - // width: 1000.rpx, // 或设置 double.infinity 占满宽度 - // child: Image.asset( - // (onlineState == "离线".tr || inBed == '离床'.tr) - // ? 'assets/img/black_body_still.png' - // : 'assets/img/body_black.gif', - // fit: BoxFit.contain, // 保持原始比例,不拉伸 - // ), - // ), - // ), Align( alignment: Alignment.center, child: FractionallySizedBox( @@ -435,16 +441,6 @@ class _InstantBodyPageState extends State padding: EdgeInsetsDirectional.fromSTEB( 30.rpx, 0, 30.rpx, 0), child: Container( - // decoration: BoxDecoration( - // image: DecorationImage( - // image: AssetImage( - // onlineState == "离线".tr - // ? 'assets/img/black_body_still.png' // 静态图 - // : 'assets/img/body_black.gif', // 动图 - // ), - // fit: BoxFit.cover, - // ), - // ), child: Column( children: [ Row( diff --git a/lib/pages/device_bind/after/after_wifi_page_person.dart b/lib/pages/device_bind/after/after_wifi_page_person.dart index cabb1a3..8184951 100644 --- a/lib/pages/device_bind/after/after_wifi_page_person.dart +++ b/lib/pages/device_bind/after/after_wifi_page_person.dart @@ -8,6 +8,7 @@ import 'package:flutter_svg/svg.dart'; import 'package:flutterflow_ui/flutterflow_ui.dart'; import 'package:vbvs_app/common/color/ServiceConstant.dart'; import 'package:vbvs_app/common/color/appConstants.dart'; +import 'package:vbvs_app/common/util/DailyLogUtils.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; import 'package:vbvs_app/common/util/requestWithLog.dart'; @@ -23,6 +24,7 @@ import 'package:vbvs_app/controller/user_info_controller.dart'; import 'package:vbvs_app/model/BleDeviceData.dart'; import 'package:vbvs_app/pages/device_bind/blueteeth_device_page.dart'; import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart'; +import 'package:EasyDartModule/EasyDartModule.dart' as edm; class AfterWifiPagePerson extends StatefulWidget { var type; @@ -118,24 +120,24 @@ class _AfterWifiPagePersonState extends State { return SizedBox( width: 24.rpx, height: 24.rpx, - child:CircularProgressIndicator( - strokeWidth: 2, - valueColor: AlwaysStoppedAnimation( - themeController.currentColor.sc1, - ), - ), + child: CircularProgressIndicator( + strokeWidth: 2, + valueColor: AlwaysStoppedAnimation( + themeController.currentColor.sc1, + ), + ), ); } if (blueteethBindController.netType.value == 0) { return SizedBox( width: 24.rpx, height: 24.rpx, - child:CircularProgressIndicator( - strokeWidth: 2, - valueColor: AlwaysStoppedAnimation( - themeController.currentColor.sc1, - ), - ), + child: CircularProgressIndicator( + strokeWidth: 2, + valueColor: AlwaysStoppedAnimation( + themeController.currentColor.sc1, + ), + ), ); } if (blueteethBindController.wifiConnectStatus.value == @@ -143,12 +145,12 @@ class _AfterWifiPagePersonState extends State { return SizedBox( width: 24.rpx, height: 24.rpx, - child:CircularProgressIndicator( - strokeWidth: 2, - valueColor: AlwaysStoppedAnimation( - themeController.currentColor.sc1, - ), - ), + child: CircularProgressIndicator( + strokeWidth: 2, + valueColor: AlwaysStoppedAnimation( + themeController.currentColor.sc1, + ), + ), ); } return Container(); @@ -638,12 +640,16 @@ class _AfterWifiPagePersonState extends State { width: 32.rpx, height: 32.rpx, child: - CircularProgressIndicator( - strokeWidth: 2, - valueColor: AlwaysStoppedAnimation( - themeController.currentColor.sc1, - ), - ), + CircularProgressIndicator( + strokeWidth: 2, + valueColor: + AlwaysStoppedAnimation< + Color>( + themeController + .currentColor + .sc1, + ), + ), ) else getWifiIconByRsso( @@ -835,6 +841,8 @@ class _AfterWifiPagePersonState extends State { if (onData.status == BleEventType.recvLineLog) { final line = onData.val; print("[bleee]:" + line); + edm.EasyDartModule.logger.info("[bleee]:" + line); + DailyLogUtils.writeLog("[bleee]:" + line); } }); } @@ -980,6 +988,8 @@ class _AfterWifiPagePersonState extends State { if (onData.status == BleEventType.recvLineLog) { final line = onData.val; print("[bleee]:" + line); + edm.EasyDartModule.logger.info("[bleee]:" + line); + DailyLogUtils.writeLog("[bleee]:" + line); } if (onData.status == BleEventType.ready) { aa = await getDeviceNetVersion( diff --git a/lib/pages/device_bind/blueteeth_device_page.dart b/lib/pages/device_bind/blueteeth_device_page.dart index a7cc6cd..5755d25 100644 --- a/lib/pages/device_bind/blueteeth_device_page.dart +++ b/lib/pages/device_bind/blueteeth_device_page.dart @@ -172,24 +172,29 @@ class _BlueteethDevicePageState extends State { } // 显示权限被拒绝的提示 + // void _showPermissionDeniedDialog(BuildContext context) { + // showDialog( + // context: context, + // builder: (BuildContext context) { + // return AlertDialog( + // title: Text("权限提示".tr), + // content: Text("应用需要蓝牙和位置权限才能扫描设备。请授予权限。".tr), + // actions: [ + // TextButton( + // onPressed: () { + // Navigator.of(context).pop(); + // }, + // child: Text("确定".tr), + // ), + // ], + // ); + // }, + // ); + // } void _showPermissionDeniedDialog(BuildContext context) { - showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - title: Text("权限提示".tr), - content: Text("应用需要蓝牙和位置权限才能扫描设备。请授予权限。".tr), - actions: [ - TextButton( - onPressed: () { - Navigator.of(context).pop(); - }, - child: Text("确定".tr), - ), - ], - ); - }, - ); + TopSlideNotification.show(context, + text: "应用需要蓝牙和位置权限才能扫描设备。请授予权限。".tr, + textColor: themeController.currentColor.sc9); } // 开始扫描蓝牙设备 diff --git a/lib/pages/device_bind/wifi_page.dart b/lib/pages/device_bind/wifi_page.dart index 8f51458..27a667a 100644 --- a/lib/pages/device_bind/wifi_page.dart +++ b/lib/pages/device_bind/wifi_page.dart @@ -8,6 +8,7 @@ import 'package:flutter_svg/svg.dart'; import 'package:flutterflow_ui/flutterflow_ui.dart'; import 'package:vbvs_app/common/color/ServiceConstant.dart'; import 'package:vbvs_app/common/color/appConstants.dart'; +import 'package:vbvs_app/common/util/DailyLogUtils.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; import 'package:vbvs_app/common/util/requestWithLog.dart'; @@ -23,6 +24,7 @@ import 'package:vbvs_app/controller/user_info_controller.dart'; import 'package:vbvs_app/model/BleDeviceData.dart'; import 'package:vbvs_app/pages/device_bind/blueteeth_device_page.dart'; import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart'; +import 'package:EasyDartModule/EasyDartModule.dart' as edm; class WifiPage extends StatefulWidget { var type; //为空,首次绑定 不为空,从设备列表进入 @@ -64,6 +66,8 @@ class _WifiPageState extends State { if (onData.status == BleEventType.recvLineLog) { final line = onData.val; print("[bleee]:" + line); + edm.EasyDartModule.logger.info("[bleee]:" + line); + DailyLogUtils.writeLog("[bleee]:" + line); } if (onData.status == BleEventType.ready) { aa = await getDeviceNetVersion( @@ -880,6 +884,8 @@ class _WifiPageState extends State { if (onData.status == BleEventType.recvLineLog) { final line = onData.val; print("[bleee]:" + line); + edm.EasyDartModule.logger.info("[bleee]:" + line); + DailyLogUtils.writeLog("[bleee]:" + line); } // if (onData.status == BleEventType.ready) { // // showLoadingDialog(context, title: "获取wifi列表中...".tr); @@ -965,7 +971,7 @@ class _WifiPageState extends State { decoration: BoxDecoration(shape: BoxShape.circle), child: Image.asset("assets/img/wifi3.png"), ); - } else if (rssi >=AppConstants().wifi3) { + } else if (rssi >= AppConstants().wifi3) { return Container( width: 40.rpx, height: 40.rpx, diff --git a/lib/pages/device_bind/wifi_page_person.dart b/lib/pages/device_bind/wifi_page_person.dart index 46a2963..41a4187 100644 --- a/lib/pages/device_bind/wifi_page_person.dart +++ b/lib/pages/device_bind/wifi_page_person.dart @@ -8,6 +8,7 @@ import 'package:flutter_svg/svg.dart'; import 'package:flutterflow_ui/flutterflow_ui.dart'; import 'package:vbvs_app/common/color/ServiceConstant.dart'; import 'package:vbvs_app/common/color/appConstants.dart'; +import 'package:vbvs_app/common/util/DailyLogUtils.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; import 'package:vbvs_app/common/util/requestWithLog.dart'; @@ -23,6 +24,7 @@ import 'package:vbvs_app/controller/user_info_controller.dart'; import 'package:vbvs_app/model/BleDeviceData.dart'; import 'package:vbvs_app/pages/device_bind/blueteeth_device_page.dart'; import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart'; +import 'package:EasyDartModule/EasyDartModule.dart' as edm; class WifiPagePerson extends StatefulWidget { var type; @@ -835,6 +837,8 @@ class _WifiPagePersonState extends State { if (onData.status == BleEventType.recvLineLog) { final line = onData.val; print("[bleee]:" + line); + edm.EasyDartModule.logger.info("[bleee]:" + line); + DailyLogUtils.writeLog("[bleee]:" + line); } }); } @@ -980,6 +984,8 @@ class _WifiPagePersonState extends State { if (onData.status == BleEventType.recvLineLog) { final line = onData.val; print("[bleee]:" + line); + edm.EasyDartModule.logger.info("[bleee]:" + line); + DailyLogUtils.writeLog("[bleee]:" + line); } if (onData.status == BleEventType.ready) { aa = await getDeviceNetVersion( diff --git a/lib/pages/main_bottom/component/main_page_b_bottom_change.dart b/lib/pages/main_bottom/component/main_page_b_bottom_change.dart index 1dba1fd..627e55a 100644 --- a/lib/pages/main_bottom/component/main_page_b_bottom_change.dart +++ b/lib/pages/main_bottom/component/main_page_b_bottom_change.dart @@ -6,6 +6,7 @@ import 'package:ef/ef.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:get_storage/get_storage.dart'; +import 'package:vbvs_app/common/color/appConstants.dart'; import 'package:vbvs_app/common/util/CommonVariables.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; @@ -13,6 +14,7 @@ import 'package:vbvs_app/controller/mh_controller/mh_language_controller.dart'; import 'package:vbvs_app/controller/user_info_controller.dart'; import 'package:vbvs_app/model/WebSocketMessage.dart'; import 'package:vbvs_app/pages/common/bezier_bottom_navigation_bar.dart'; +import 'package:vbvs_app/pages/common/selectDialog.dart'; import 'package:vbvs_app/pages/mh_page/MattressControl.dart'; import 'package:vbvs_app/pages/mh_page/homepage/mht_sleep_report_page.dart'; import 'package:vbvs_app/pages/mh_page/homepage/new_Home_page.dart'; @@ -124,27 +126,27 @@ class _HomePageState extends State final getStorage = GetStorage(); @override Widget build(BuildContext context) { - // Future.delayed(const Duration(milliseconds: 0), () { - // String? isShowYingShiDialog = getStorage.read("isShowYingShiDialog"); - // if (isShowYingShiDialog == null || isShowYingShiDialog != "true") { - // String btnName = "同意".tr; - // String cancelName = "取消".tr; - // if (Platform.isAndroid) { - // cancelName = "退出".tr; - // } - // showCustomConfirmOfWebViewDialog(context, "隐私协议".tr, getPrivacy(1), - // btnName: btnName, showCancel: true, cancelName: cancelName) - // .then((e) { - // if (e == "confirm") { - // getStorage.write("isShowYingShiDialog", "true"); - // } else { - // if (cancelName == "退出") { - // SystemNavigator.pop(); - // } - // } - // }); - // } - // }); + Future.delayed(const Duration(milliseconds: 0), () { + String? isShowYingShiDialog = getStorage.read("isShowYingShiDialog"); + if (isShowYingShiDialog == null || isShowYingShiDialog != "true") { + String btnName = "同意".tr; + String cancelName = "取消".tr; + if (Platform.isAndroid) { + cancelName = "退出".tr; + } + showCustomConfirmOfWebViewDialog(context, "隐私协议".tr, getPrivacy(1), + btnName: btnName, showCancel: true, cancelName: cancelName) + .then((e) { + if (e == "confirm") { + getStorage.write("isShowYingShiDialog", "true"); + } else { + if (cancelName == "退出") { + SystemNavigator.pop(); + } + } + }); + } + }); return Obx(() { final currentLanguage = languageController.selectLanguage.value; // 监听此变量变化 diff --git a/lib/pages/main_bottom/home_page.dart b/lib/pages/main_bottom/home_page.dart index 0594d3c..31228d4 100644 --- a/lib/pages/main_bottom/home_page.dart +++ b/lib/pages/main_bottom/home_page.dart @@ -383,7 +383,7 @@ class _HomePageState extends State { .currentColor.sc4, ), ), - + ].divide(SizedBox( width: 20.rpx, )), diff --git a/lib/pages/main_bottom/main_page_bottom_change.dart b/lib/pages/main_bottom/main_page_bottom_change.dart index f74775c..f48dbd8 100644 --- a/lib/pages/main_bottom/main_page_bottom_change.dart +++ b/lib/pages/main_bottom/main_page_bottom_change.dart @@ -81,27 +81,27 @@ class MainPageBottomChange extends GetView { final getStorage = GetStorage(); @override Widget build(BuildContext context) { - Future.delayed(const Duration(milliseconds: 0), () { - String? isShowYingShiDialog = getStorage.read("isShowYingShiDialog"); - if (isShowYingShiDialog == null || isShowYingShiDialog != "true") { - String btnName = "同意".tr; - String cancelName = "取消".tr; - if (Platform.isAndroid) { - cancelName = "退出".tr; - } - showCustomConfirmOfWebViewDialog(context, "隐私协议".tr, getPrivacy(1), - btnName: btnName, showCancel: true, cancelName: cancelName) - .then((e) { - if (e == "confirm") { - getStorage.write("isShowYingShiDialog", "true"); - } else { - if (cancelName == "退出") { - SystemNavigator.pop(); - } - } - }); - } - }); + // Future.delayed(const Duration(milliseconds: 0), () { + // String? isShowYingShiDialog = getStorage.read("isShowYingShiDialog"); + // if (isShowYingShiDialog == null || isShowYingShiDialog != "true") { + // String btnName = "同意".tr; + // String cancelName = "取消".tr; + // if (Platform.isAndroid) { + // cancelName = "退出".tr; + // } + // showCustomConfirmOfWebViewDialog(context, "隐私协议".tr, getPrivacy(1), + // btnName: btnName, showCancel: true, cancelName: cancelName) + // .then((e) { + // if (e == "confirm") { + // getStorage.write("isShowYingShiDialog", "true"); + // } else { + // if (cancelName == "退出") { + // SystemNavigator.pop(); + // } + // } + // }); + // } + // }); return PopScope( canPop: false, diff --git a/lib/pages/main_bottom/mine_page.dart b/lib/pages/main_bottom/mine_page.dart index b974efe..90865b4 100644 --- a/lib/pages/main_bottom/mine_page.dart +++ b/lib/pages/main_bottom/mine_page.dart @@ -5,6 +5,7 @@ import 'package:flutter_svg/svg.dart'; import 'package:flutterflow_ui/flutterflow_ui.dart'; import 'package:vbvs_app/common/color/ServiceConstant.dart'; import 'package:vbvs_app/common/color/appConstants.dart'; +import 'package:vbvs_app/common/util/DailyLogUtils.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; import 'package:vbvs_app/common/util/requestWithLog.dart'; @@ -610,7 +611,7 @@ class _MinePageState extends State { .currentColor.sc21, // 点击时的背景色 padding: EdgeInsetsDirectional.fromSTEB( 40.rpx, 0.rpx, 40.rpx, 0.rpx), - onTap: () { + onTap: () async { UserInfoController userInfoController = Get.find(); if (userInfoController.model.login != @@ -622,7 +623,20 @@ class _MinePageState extends State { themeController.currentColor.sc9, ); Get.toNamed("/loginPage"); - } else {} + } else { + String logContent = + await DailyLogUtils.readLogByDate( + DateTime(2025, 9, 4)); + print(logContent); + // DailyLogUtils.readTodayLog(); + // DailyLogUtils.listLogFiles(); + await DailyLogUtils.writeLog( + "测试日志内容"); // 确保写入日志 + await DailyLogUtils + .exportAllLogs(); // 导出并分享 + + // DailyLogUtils.exportAllLogs(); + } }, child: Container( child: Padding( @@ -660,7 +674,7 @@ class _MinePageState extends State { mainAxisSize: MainAxisSize.max, children: [ Text( - 'V1.0.2506.06', + 'V1.0.2509.04', style: TextStyle( fontFamily: 'Inter', color: Color(0xFFD9E3EB), diff --git a/lib/pages/mh_page/CommonMessageSettingPage.dart b/lib/pages/mh_page/CommonMessageSettingPage.dart new file mode 100644 index 0000000..542379e --- /dev/null +++ b/lib/pages/mh_page/CommonMessageSettingPage.dart @@ -0,0 +1,282 @@ +import 'dart:async'; + +import 'package:ef/ef.dart'; +import 'package:flutter/material.dart'; +import 'package:flutterflow_ui/flutterflow_ui.dart'; +import 'package:vbvs_app/common/color/ServiceConstant.dart'; +import 'package:vbvs_app/common/color/appConstants.dart'; +import 'package:vbvs_app/common/util/FitTool.dart'; +import 'package:vbvs_app/common/util/MyUtils.dart'; +import 'package:vbvs_app/common/util/requestWithLog.dart'; +import 'package:vbvs_app/component/base/GradientSwitch.dart'; +import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; +import 'package:vbvs_app/controller/message/common_message_setting_controller.dart'; +import 'package:vbvs_app/controller/theme_controller/ThemeController.dart'; +import 'package:vbvs_app/pages/mh_page/user/controller/mht_login_controller.dart'; + +class MHTCommonMessageSettingPage extends StatefulWidget { + MHTCommonMessageSettingPage({super.key}); + + @override + State createState() => + _CommonMessageSettingPageState(); +} + +class _CommonMessageSettingPageState + extends State { + final ThemeController themeController = Get.find(); + CommonMessageSettingController commonMessageSettingController = Get.find(); + + @override + void initState() { + super.initState(); + commonMessageSettingController.getAppSleepNotify(); + _fetchDeviceList(); + } + + Future _fetchDeviceList() async { + String serviceAddress = ServiceConstant.service_address; + String serviceName = ServiceConstant.server_service; + String serviceApi = ServiceConstant.user_setting; + String type = "user_message_setting"; + String queryUrl = "${serviceAddress}${serviceName}${serviceApi}?type=$type"; + requestWithLog( + logTitle: "查询用户消息配置", + method: MyHttpMethod.get, + queryUrl: queryUrl, + onSuccess: (res) { + if (res.data == null || res.data.isEmpty) { + var data = { + "type": type, + "setting": 1, + "appSetting": 1, + "serviceSetting": 1, + "tipSetting": 1, + "deviceUpgradeSetting": 1, + "deviceIssueSetting": 1, + }; + requestWithLog( + logTitle: "更新用户消息配置", + method: MyHttpMethod.put, + queryUrl: queryUrl, + data: data, + onSuccess: (res) { + requestWithLog( + logTitle: "查询用户消息配置", + method: MyHttpMethod.get, + queryUrl: queryUrl, + onSuccess: (res) { + if (res.data != null && res.data.isNotEmpty) { + var datalist = res.data; + commonMessageSettingController.model.setting = + datalist['setting']; + commonMessageSettingController.model.appSetting = + datalist['appSetting']; + commonMessageSettingController.model.serviceSetting = + datalist['serviceSetting']; + commonMessageSettingController.model.tipSetting = + datalist['tipSetting']; + commonMessageSettingController.model.deviceUpgradeSetting = + datalist['deviceUpgradeSetting']; + commonMessageSettingController.model.deviceIssueSetting = + datalist['deviceIssueSetting']; + commonMessageSettingController.updateAll(); + } + }, + ); + + // + }, + ); + } else { + var datalist = res.data; + commonMessageSettingController.model.setting = datalist['setting']; + commonMessageSettingController.model.appSetting = + datalist['appSetting']; + commonMessageSettingController.model.serviceSetting = + datalist['serviceSetting']; + commonMessageSettingController.model.tipSetting = + datalist['tipSetting']; + commonMessageSettingController.model.deviceUpgradeSetting = + datalist['deviceUpgradeSetting']; + commonMessageSettingController.model.deviceIssueSetting = + datalist['deviceIssueSetting']; + commonMessageSettingController.updateAll(); + } + }, + onFailure: (res) { + print(res); + }, + ); + } + + @override + void dispose() { + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return LayoutBuilder( + builder: (context, bodysize) => GestureDetector( + // onTap: () => FocusScope.of(context).unfocus(),, + child: Container( + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/images/new_background.png'), // 本地图片 + fit: BoxFit.fill, + ), + ), + child: Scaffold( + backgroundColor: Colors.transparent, + appBar: AppBar( + backgroundColor: Colors.transparent, + automaticallyImplyLeading: false, + iconTheme: IconThemeData( + color: themeController.currentColor.sc3, + ), + titleSpacing: 0, + title: Container( + width: double.infinity, + height: 180.rpx, + child: Stack( + alignment: Alignment.center, + children: [ + /// 居中标题 + Text( + '消息通知'.tr, + style: TextStyle( + fontFamily: 'ReadexPro', + color: themeController.currentColor.sc3, + letterSpacing: 0, + fontSize: 30.rpx, + ), + ), + Positioned( + left: 0, + child: returnIconButtomAddCallback(() {}), + ), + ], + ), + ), + actions: [], + centerTitle: false, + ), + body: GestureDetector( + child: SafeArea( + top: true, + child: Padding( + padding: EdgeInsetsDirectional.fromSTEB(0.rpx, 0, 0.rpx, 0), + child: SingleChildScrollView( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Padding( + padding: + EdgeInsetsDirectional.fromSTEB(0, 30.rpx, 0, 0), + child: Container( + width: double.infinity, + constraints: BoxConstraints( + minHeight: 90.rpx, + ), + decoration: BoxDecoration( + color: themeController.currentColor.sc5), + child: Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 30.rpx, 15.rpx, 30.rpx, 15.rpx), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Text( + "睡眠报告通知".tr, + style: TextStyle( + color: + themeController.currentColor.sc3, + fontSize: AppConstants() + .title_text_fontSize), + ), + ), + Obx(() { + return GradientSwitch( + value: commonMessageSettingController + .model.sleepReportSetting == + 1 + ? true + : false, + onChanged: (val) async { + // String serviceAddress = + // ServiceConstant.service_address; + // String serviceName = + // ServiceConstant.server_service; + // String serviceApi = ServiceConstant + // .app_system_push_message; + // String queryUrl = + // "${serviceAddress}${serviceName}${serviceApi}"; + // var data = { + // "type": type, + // "setting": val == true ? 1 : 0, + // "appSetting": + // commonMessageSettingController + // .model.appSetting, + // "serviceSetting": + // commonMessageSettingController + // .model.serviceSetting, + // "tipSetting": + // commonMessageSettingController + // .model.tipSetting, + // "deviceUpgradeSetting": + // commonMessageSettingController + // .model.deviceUpgradeSetting, + // "deviceIssueSetting": + // commonMessageSettingController + // .model.deviceIssueSetting, + // }; + // requestWithLog( + // logTitle: "更新消息推送状态", + // method: MyHttpMethod.put, + // queryUrl: queryUrl, + // data: data, + // onSuccess: (res) { + // _fetchDeviceList(); + // commonMessageSettingController + // .updateAll(); + // }); + await commonMessageSettingController + .updateSleepNotify(val); + await commonMessageSettingController + .getAppSleepNotify(); + commonMessageSettingController + .updateAll(); + }, + activeGradient: LinearGradient( + colors: [ + themeController.currentColor.sc1, + themeController.currentColor.sc2 + ], + ), + activeThumbColor: Colors.white, + inactiveThumbColor: + stringToColor("#A2A4A9"), + inactiveColor: stringToColor("#161B28"), + ); + }), + ], + ), + ), + ), + ), + ], + ), + ), + ), + ), + ), + ), + ), + ), + ); + } +} diff --git a/lib/pages/mh_page/device/mht_wifi_page.dart b/lib/pages/mh_page/device/mht_wifi_page.dart index d421637..62f7f6d 100644 --- a/lib/pages/mh_page/device/mht_wifi_page.dart +++ b/lib/pages/mh_page/device/mht_wifi_page.dart @@ -25,6 +25,7 @@ import 'package:vbvs_app/model/BleDeviceData.dart'; import 'package:vbvs_app/pages/device_bind/blueteeth_device_page.dart'; import 'package:vbvs_app/pages/mh_page/component/mht_bind_dialog.dart'; import 'package:vbvs_app/pages/mh_page/device/model/BlueToothDataModel.dart'; +import 'package:EasyDartModule/EasyDartModule.dart' as edm; class MHTWifiPage extends StatefulWidget { BlueToothDataModel deviceInfo; @@ -648,7 +649,7 @@ class _MHTWifiPageState extends State { valueColor: AlwaysStoppedAnimation< Color>( - Colors.white, + Colors.white, ), ), ) @@ -847,6 +848,8 @@ class _MHTWifiPageState extends State { if (onData.status == BleEventType.recvLineLog) { final line = onData.val; print("[bleee]:" + line); + edm.EasyDartModule.logger.info("[bleee]:" + line); + DailyLogUtils.writeLog("[bleee]:" + line); } }); } @@ -982,6 +985,8 @@ class _MHTWifiPageState extends State { if (onData.status == BleEventType.recvLineLog) { final line = onData.val; print("[bleee]:" + line); + edm.EasyDartModule.logger.info("[bleee]:" + line); + DailyLogUtils.writeLog("[bleee]:" + line); } if (onData.status == BleEventType.ready) { var aa = await getDeviceNetVersion( diff --git a/lib/pages/mh_page/device/mht_wifi_page_after.dart b/lib/pages/mh_page/device/mht_wifi_page_after.dart index 8f22cb1..86ebf8d 100644 --- a/lib/pages/mh_page/device/mht_wifi_page_after.dart +++ b/lib/pages/mh_page/device/mht_wifi_page_after.dart @@ -23,6 +23,7 @@ import 'package:vbvs_app/controller/user_info_controller.dart'; import 'package:vbvs_app/model/BleDeviceData.dart'; import 'package:vbvs_app/pages/device_bind/blueteeth_device_page.dart'; import 'package:vbvs_app/pages/mh_page/component/mht_bind_dialog.dart'; +import 'package:EasyDartModule/EasyDartModule.dart' as edm; class MHTWifiAfterPage extends StatefulWidget { var deviceInfo; @@ -823,6 +824,8 @@ class _MHTWifiAfterPageState extends State { if (onData.status == BleEventType.recvLineLog) { final line = onData.val; print("[bleee]:" + line); + edm.EasyDartModule.logger.info("[bleee]:" + line); + DailyLogUtils.writeLog("[bleee]:" + line); } }); } @@ -917,8 +920,6 @@ class _MHTWifiAfterPageState extends State { _scanSubscription = FlutterBluePlus.scanResults.listen((results) async { if (_isDisposed) return; - - for (var r in results) { if (r.advertisementData.manufacturerData.containsKey(0xFFED)) { List rawData = r.advertisementData.manufacturerData[0xFFED]!; @@ -958,6 +959,8 @@ class _MHTWifiAfterPageState extends State { if (onData.status == BleEventType.recvLineLog) { final line = onData.val; print("[bleee]:" + line); + edm.EasyDartModule.logger.info("[bleee]:" + line); + DailyLogUtils.writeLog("[bleee]:" + line); } if (onData.status == BleEventType.ready) { var aa = await getDeviceNetVersion( diff --git a/lib/pages/mh_page/homepage/controller/mht_home_controller.dart b/lib/pages/mh_page/homepage/controller/mht_home_controller.dart index 80381cb..ce7ceb6 100644 --- a/lib/pages/mh_page/homepage/controller/mht_home_controller.dart +++ b/lib/pages/mh_page/homepage/controller/mht_home_controller.dart @@ -12,6 +12,7 @@ import 'package:vbvs_app/common/util/MyUtils.dart'; import 'package:vbvs_app/common/util/requestWithLog.dart'; import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; import 'package:vbvs_app/model/api_response.dart'; +import 'package:vbvs_app/pages/main_bottom/component/main_page_b_bottom_change.dart'; part 'mht_home_controller.g.dart'; // 由json_serializable自动生成的部分 @@ -59,6 +60,15 @@ class MHTHomeController extends GetControllerEx { bool initDeviceFlag = false; + RxMap selectedReportData = {}.obs; + RxInt refreshReportTrigger = 0.obs; + + void openReport(Map data) { + selectedReportData.value = data; + refreshReportTrigger.value++; // 每次+1,触发监听 + MainPageBBottomChange.jumpTo(1); // 切到报告页 + } + Future getDeviceNum() async { try { ApiResponse apiResponse = ApiResponse(code: -1, msg: "设备列表请求失败".tr); diff --git a/lib/pages/mh_page/homepage/new_Home_page.dart b/lib/pages/mh_page/homepage/new_Home_page.dart index cfc6c07..662f079 100644 --- a/lib/pages/mh_page/homepage/new_Home_page.dart +++ b/lib/pages/mh_page/homepage/new_Home_page.dart @@ -8,13 +8,12 @@ import 'package:flutterflow_ui/flutterflow_ui.dart'; import 'package:vbvs_app/common/color/appConstants.dart'; import 'package:vbvs_app/common/color/app_uri_status.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; +import 'package:vbvs_app/common/util/JPushUtil.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; -import 'package:vbvs_app/component/NullDataComponentWidget.dart'; import 'package:vbvs_app/component/tool/ClickableContainer.dart'; import 'package:vbvs_app/controller/user_info_controller.dart'; import 'package:vbvs_app/controller/weather/weather_controller.dart'; import 'package:vbvs_app/enum/APPPackageType.dart'; -import 'package:vbvs_app/pages/mh_page/FloatingSvgIcon.dart'; import 'package:vbvs_app/pages/mh_page/component/mht_bind_dialog.dart'; import 'package:vbvs_app/pages/mh_page/homepage/component/HomeDeviceWidget.dart'; import 'package:vbvs_app/pages/mh_page/homepage/controller/mht_home_controller.dart'; @@ -75,6 +74,9 @@ class _NewHomePageState extends State { homeController.homeSleepDays.value.length - 1; } }); + WidgetsBinding.instance.addPostFrameCallback((_) { + _onReady(); + }); try { _newVersionSubscription = ef.kvRoot.appmanger.onAppUpdate.listen((MiniAppPkg pkg) { @@ -573,7 +575,19 @@ class _NewHomePageState extends State { 'reportPadding': false, }, ); - } + // 保存当前选中的mac到全局状态 + // homeController.selectDevcie + // .value = + // formFieldController + // .value!; + // homeController.selectPerson + // .value = + // personInfo.value; + + // // 使用底部tab跳转到第二个页面 + // MainPageBBottomChange + // .jumpTo(1); + } }, child: Row( mainAxisSize: @@ -983,6 +997,23 @@ class _NewHomePageState extends State { if (value is String) return int.tryParse(value); return null; } + + void _onReady() { + // 页面渲染完成后执行的逻辑,比如处理通知跳转 + _handlePendingRoute(); + } + + void _handlePendingRoute() { + var pending = JPushUtil.box.read("pendingRoute"); + if (pending != null) { + String route = pending["route"]; + var args = pending["arguments"]; + Future.delayed(const Duration(milliseconds: 300), () { + Get.toNamed(route, arguments: args); + }); + JPushUtil.box.remove("pendingRoute"); + } + } } class ScoreItem { diff --git a/lib/pages/mh_page/new_settingPage.dart b/lib/pages/mh_page/new_settingPage.dart index b3e9d07..0d849a8 100644 --- a/lib/pages/mh_page/new_settingPage.dart +++ b/lib/pages/mh_page/new_settingPage.dart @@ -156,6 +156,67 @@ class _SettingPageState extends State { ), ), ), + ClickableContainer( + backgroundColor: + Colors.transparent, // 容器背景色 + highlightColor: themeController + .currentColor.sc21, // 点击时的背景色 + padding: EdgeInsetsDirectional.fromSTEB( + 40.rpx, 0.rpx, 40.rpx, 0.rpx), + onTap: () { + Get.toNamed("/commonMessageSettingPage"); + }, + child: Container( + child: Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 0.rpx, 30.rpx, 0.rpx, 30.rpx), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Row( + mainAxisSize: MainAxisSize.max, + children: [ + Text('通知设置'.tr, + style: TextStyle( + fontSize: 30.rpx, + color: Colors.white, + height: 1)), + ].divide(SizedBox(width: 22.rpx)), + ), + SvgPicture.asset( + 'assets/img/icon/arrow_right.svg', + width: 8.rpx, + height: 15 + .rpx, // 如果 SVG 中没有固定颜色,可以这样设置 + color: themeController + .currentColor.sc3, + ), + // Row( + // mainAxisSize: MainAxisSize.max, + // children: [ + // Text( + // '深色', + // style: FlutterFlowTheme.of( + // context) + // .bodyMedium + // .override( + // fontFamily: 'Inter', + // color: + // Color(0xFFD9E3EB), + // fontSize: 26.rpx, + // letterSpacing: 0.0, + // ), + // ), + + // ].divide(SizedBox(width: 28.rpx)), + // ), + ], + ), + ), + ), + ), ClickableContainer( backgroundColor: Colors.transparent, // 容器背景色 diff --git a/lib/pages/mh_page/test/WebviewTestModel.dart b/lib/pages/mh_page/test/WebviewTestModel.dart index 7bd55dc..43b1206 100644 --- a/lib/pages/mh_page/test/WebviewTestModel.dart +++ b/lib/pages/mh_page/test/WebviewTestModel.dart @@ -45,8 +45,8 @@ class WebviewTestController extends GetControllerEx { isheadless: false, jsbridge: buildsdk( // father: this, - // clientId: '123', // clientId: '494641114', + // clientId: '123', // dbgserverUrl: 'ws://192.168.1.2:9001', ), settings: buildsettings(), @@ -69,9 +69,7 @@ class WebviewTestController extends GetControllerEx { bridge: bridge, onConnect: (args1, args2) { final devices = args1.devices as Map; - final mac = args2 as String; - - // Android: key 就是 mac,直接找 + final mac = args2 as String; if (devices.containsKey(mac)) { final device = devices[mac]; ef.log('Minibleapp connected(Android): $mac -> $device'); diff --git a/lib/pages/mh_page/user/controller/mht_login_controller.dart b/lib/pages/mh_page/user/controller/mht_login_controller.dart index 50269c7..f18871a 100644 --- a/lib/pages/mh_page/user/controller/mht_login_controller.dart +++ b/lib/pages/mh_page/user/controller/mht_login_controller.dart @@ -141,7 +141,7 @@ class MHTLoginController extends GetControllerEx { "type": type, "userName": account, "password": password, - 'khCode':'mht', + 'khCode': 'mht', }; String serviceAddress = ServiceConstant.service_address; String serviceName = ServiceConstant.server_service; @@ -164,6 +164,8 @@ class MHTLoginController extends GetControllerEx { final box = GetStorage(); box.write('token', token); // 存储 token box.write('user', userInfoController.model.user!.toJson()); // 存储用户信息 + //todo 更新消息通知 + updateAppSystemNotify(true); }, onFailure: (res) { message = res.msg!; @@ -341,3 +343,26 @@ class MHTLoginController extends GetControllerEx { corpId: CommonVariables.wxCorpId, url: CommonVariables.wxKfUrl)); } } + +Future updateAppSystemNotify(bool status) async { + final box = GetStorage(); + var data = { + "pid": box.read("rid"), + "status": status, + }; + String serviceAddress = ServiceConstant.service_address; + String serviceName = ServiceConstant.server_service; + String serviceApi = ServiceConstant.app_system_push_message; + String queryUrl = "${serviceAddress}${serviceName}${serviceApi}"; + await requestWithLog( + logTitle: "激活消息通知", + method: MyHttpMethod.put, + queryUrl: queryUrl, + data: data, + onSuccess: (res) { + print(res); + }, + onFailure: (res) { + print(res); + }); +} diff --git a/lib/pages/mh_page/user/page/mht_login_page.dart b/lib/pages/mh_page/user/page/mht_login_page.dart index 49e097c..88b5d27 100644 --- a/lib/pages/mh_page/user/page/mht_login_page.dart +++ b/lib/pages/mh_page/user/page/mht_login_page.dart @@ -8,12 +8,14 @@ import 'package:vbvs_app/common/color/appFontsize.dart'; import 'package:vbvs_app/common/util/CheckNetwork.dart'; import 'package:vbvs_app/common/util/CommonVariables.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; +import 'package:vbvs_app/common/util/JPushUtil.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; import 'package:vbvs_app/component/tool/ClickableContainer.dart'; import 'package:vbvs_app/component/tool/CustomCard.dart'; import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; import 'package:vbvs_app/controller/time/countdown_controller.dart'; import 'package:vbvs_app/controller/user_info_controller.dart'; +import 'package:vbvs_app/enum/APPPackageType.dart'; import 'package:vbvs_app/pages/mh_page/user/controller/mht_login_controller.dart'; import 'package:vbvs_app/pages/mh_page/user/controller/mht_register_controller.dart'; @@ -95,6 +97,9 @@ class MHTLoginPage extends GetView { controller.fluwxCancelable?.cancel(); // 登录成功移出网络检查监听 Checknetwork.subscription?.cancel(); + if (AppConstants().ent_type == APPPackageType.MHT.code) { + await JPushUtil.initJPush(); + } Get.offAndToNamed("/mianPageBottomChange"); } // TODO 操作全部跳转页面前成功以后移除监听,防止重复监听,其他方式登录成功也需要移出监听 @@ -1261,10 +1266,39 @@ class MHTLoginPage extends GetView { registerController = Get.find(); registerController .model.register_agree = false; + if (AppConstants().ent_type == + APPPackageType.MHT.code) { + await JPushUtil.initJPush(); + } Get.offAndToNamed( "/mianPageBottomChange"); - //登陆成功 - // + // box.write( + // "needSleepReport", "true"); + // if (box.read("needSleepReport") != + // null && + // box.read("needSleepReport") == + // "true") { + // box.remove("needSleepReport"); + // await box.save(); + // var person = box.read( + // "needSleepReport_person"); + // var mac = box + // .read("needSleepReport_mac"); + // Get.toNamed( + // "/newSleepReportPage", + // arguments: { + // 'mac': mac, + // 'type': 1, + // "person": person, + // 'backgroundImg': + // 'assets/images/new_background.png', + // 'date': DateTime.now() + // .millisecondsSinceEpoch, + // 'person_show': false, + // 'reportPadding': false, + // }, + // ); + // } } }, colors: [ diff --git a/lib/pages/setting/common_mesaage_setting.dart b/lib/pages/setting/common_mesaage_setting.dart index 2b16c3c..4b6b86c 100644 --- a/lib/pages/setting/common_mesaage_setting.dart +++ b/lib/pages/setting/common_mesaage_setting.dart @@ -141,7 +141,7 @@ class _CommonMessageSettingPageState extends State { children: [ /// 居中标题 Text( - '消息通知'.tr, + '通知设置'.tr, style: TextStyle( fontFamily: 'ReadexPro', color: themeController.currentColor.sc3, diff --git a/lib/routers/mh_routers.dart b/lib/routers/mh_routers.dart index 8d6fc7e..ede8986 100644 --- a/lib/routers/mh_routers.dart +++ b/lib/routers/mh_routers.dart @@ -7,6 +7,7 @@ import 'package:vbvs_app/controller/theme_controller/ThemeController.dart'; import 'package:vbvs_app/controller/user_info_controller.dart'; import 'package:vbvs_app/main.dart'; import 'package:vbvs_app/pages/main_bottom/component/main_page_b_bottom_change.dart'; +import 'package:vbvs_app/pages/mh_page/CommonMessageSettingPage.dart'; import 'package:vbvs_app/pages/mh_page/HomeDeviceType.dart'; import 'package:vbvs_app/pages/mh_page/LanguagePage.dart'; import 'package:vbvs_app/pages/mh_page/ShareDeviceDetailWidget.dart'; @@ -138,6 +139,7 @@ var mhroutes = { UserPrivacyNewPage(sleepUri: arguments), "/privacyPolicyPageNew": (contxt, {arguments}) => PrivacyPolicyNewPage(sleepUri: arguments), + "/commonMessageSettingPage": (contxt) => MHTCommonMessageSettingPage(), }; var mhonGenerateRoute = (RouteSettings settings) { final String? name = settings.name; // 获取路由名称,如 /news 或 /search @@ -159,8 +161,7 @@ var mhonGenerateRoute = (RouteSettings settings) { settings.name != "/privacyPolicyPage" && settings.name != "/auth_bind_tel" && settings.name != "/userPolicyPageNew" && - settings.name != "/privacyPolicyPageNew" - ) { + settings.name != "/privacyPolicyPageNew") { // TopSlideNotification.show( // navigatorKey.currentContext!, // text: "必须登录提示".tr, diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index c2c22b0..503943b 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -12,14 +12,12 @@ import flutter_inappwebview_macos import flutter_localization import geolocator_apple import mobile_scanner -import package_info_plus import path_provider_foundation import rive_common +import share_plus import shared_preferences_foundation import sqflite_darwin import url_launcher_macos -import video_player_avfoundation -import wakelock_plus import webview_flutter_wkwebview func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { @@ -30,13 +28,11 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FlutterLocalizationPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalizationPlugin")) GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin")) MobileScannerPlugin.register(with: registry.registrar(forPlugin: "MobileScannerPlugin")) - FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) RivePlugin.register(with: registry.registrar(forPlugin: "RivePlugin")) + SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) - FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin")) - WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin")) WebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "WebViewFlutterPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index 090d8f7..49a08c5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -271,14 +271,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.0.3" - chewie: - dependency: "direct main" - description: - name: chewie - sha256: "645fbca3f22309381edb5af59a4c8aa544a3d3872d7b7b7c986c2b18b3bdd265" - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.10.0" clock: dependency: transitive description: @@ -1087,6 +1079,14 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.1.2" + jpush_flutter: + dependency: "direct main" + description: + name: jpush_flutter + sha256: "1cb79c45351bca20861fece94d4cf92e6330e95f0a3e15893cca0ce877f54cb4" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.3.6" js: dependency: transitive description: @@ -1335,22 +1335,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.2.0" - package_info_plus: - dependency: transitive - description: - name: package_info_plus - sha256: "16eee997588c60225bda0488b6dcfac69280a6b7a3cf02c741895dd370a02968" - url: "https://pub.flutter-io.cn" - source: hosted - version: "8.3.1" - package_info_plus_platform_interface: - dependency: transitive - description: - name: package_info_plus_platform_interface - sha256: "202a487f08836a592a6bd4f901ac69b3a8f146af552bbd14407b6b41e1c3f086" - url: "https://pub.flutter-io.cn" - source: hosted - version: "3.2.1" packages_extensions: dependency: transitive description: @@ -1703,6 +1687,22 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.2.3" + share_plus: + dependency: "direct main" + description: + name: share_plus + sha256: d7dc0630a923883c6328ca31b89aa682bacbf2f8304162d29f7c6aaff03a27a1 + url: "https://pub.flutter-io.cn" + source: hosted + version: "11.1.0" + share_plus_platform_interface: + dependency: transitive + description: + name: share_plus_platform_interface + sha256: "88023e53a13429bd65d8e85e11a9b484f49d4c190abbd96c7932b74d6927cc9a" + url: "https://pub.flutter-io.cn" + source: hosted + version: "6.1.0" shared_preferences: dependency: transitive description: @@ -2132,46 +2132,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.1.4" - video_player: - dependency: "direct main" - description: - name: video_player - sha256: "7d78f0cfaddc8c19d4cb2d3bebe1bfef11f2103b0a03e5398b303a1bf65eeb14" - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.9.5" - video_player_android: - dependency: transitive - description: - name: video_player_android - sha256: "391e092ba4abe2f93b3e625bd6b6a6ec7d7414279462c1c0ee42b5ab8d0a0898" - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.7.16" - video_player_avfoundation: - dependency: transitive - description: - name: video_player_avfoundation - sha256: "9ee764e5cd2fc1e10911ae8ad588e1a19db3b6aa9a6eb53c127c42d3a3c3f22f" - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.7.1" - video_player_platform_interface: - dependency: transitive - description: - name: video_player_platform_interface - sha256: df534476c341ab2c6a835078066fc681b8265048addd853a1e3c78740316a844 - url: "https://pub.flutter-io.cn" - source: hosted - version: "6.3.0" - video_player_web: - dependency: transitive - description: - name: video_player_web - sha256: e8bba2e5d1e159d5048c9a491bb2a7b29c535c612bb7d10c1e21107f5bd365ba - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.3.5" vm_service: dependency: transitive description: @@ -2188,22 +2148,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.4.6" - wakelock_plus: - dependency: transitive - description: - name: wakelock_plus - sha256: a474e314c3e8fb5adef1f9ae2d247e57467ad557fa7483a2b895bc1b421c5678 - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.3.2" - wakelock_plus_platform_interface: - dependency: transitive - description: - name: wakelock_plus_platform_interface - sha256: e10444072e50dbc4999d7316fd303f7ea53d31c824aa5eb05d7ccbdd98985207 - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.2.3" watcher: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 1334426..fbe799f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -8,8 +8,8 @@ environment: sdk: ^3.5.4 fluwx: - # app_id: 'wx929c548fea6af9c7' #填写自己的 WeChat app id.眠花糖 - app_id: 'wxeb2688220799e2c5' #填写自己的 WeChat app id.太和e护 + app_id: 'wx929c548fea6af9c7' #填写自己的 WeChat app id.眠花糖 + # app_id: 'wxeb2688220799e2c5' #填写自己的 WeChat app id.太和e护 debug_logging: false # Logging in debug mode. android: # interrupt_wx_request: true # Defaults to true. @@ -70,17 +70,17 @@ dependencies: weather: ^3.1.1 lpinyin: ^2.0.3 geocoding: ^4.0.0 - video_player: ^2.9.5 - chewie: ^1.10.0 + # video_player: ^2.9.5 + # chewie: ^1.10.0 map_launcher: ^3.5.0 - - gif: ^2.3.0 easyweb: git: url: https://gitea.wslpc.real.he-info.cn:94/flutter/easyweb.git ref: main archive: ^4.0.0 + jpush_flutter: ^3.3.6 + share_plus: ^11.1.0 dev_dependencies: flutter_test: diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 203b6e9..daf6461 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -12,6 +12,7 @@ #include #include #include +#include #include void RegisterPlugins(flutter::PluginRegistry* registry) { @@ -27,6 +28,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); RivePluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("RivePlugin")); + SharePlusWindowsPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi")); UrlLauncherWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("UrlLauncherWindows")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index c4066a3..efa76a7 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -9,6 +9,7 @@ list(APPEND FLUTTER_PLUGIN_LIST geolocator_windows permission_handler_windows rive_common + share_plus url_launcher_windows ) diff --git a/windows/runner/Runner.rc b/windows/runner/Runner.rc index fc9e0ec..96ac45d 100644 --- a/windows/runner/Runner.rc +++ b/windows/runner/Runner.rc @@ -90,12 +90,12 @@ BEGIN BLOCK "040904e4" BEGIN VALUE "CompanyName", "com.example" "\0" - VALUE "FileDescription", "com.taihe.vbvs_app" "\0" + VALUE "FileDescription", "com.taihe.mianhuatang" "\0" VALUE "FileVersion", VERSION_AS_STRING "\0" - VALUE "InternalName", "com.taihe.vbvs_app" "\0" + VALUE "InternalName", "com.taihe.mianhuatang" "\0" VALUE "LegalCopyright", "Copyright (C) 2025 com.example. All rights reserved." "\0" - VALUE "OriginalFilename", "com.taihe.vbvs_app.exe" "\0" - VALUE "ProductName", "com.taihe.vbvs_app" "\0" + VALUE "OriginalFilename", "com.taihe.mianhuatang.exe" "\0" + VALUE "ProductName", "com.taihe.mianhuatang" "\0" VALUE "ProductVersion", VERSION_AS_STRING "\0" END END