From 0dd00b4250b3bfb2572dc4dbe66389cc62f3a49a Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Fri, 21 Jun 2024 10:36:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=E5=AE=8C=E6=88=90=20=20=E5=BA=9F?= =?UTF-8?q?=E5=BC=83=20api=20=E6=A3=80=E6=B5=8B=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pre_build.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 pre_build.sh diff --git a/pre_build.sh b/pre_build.sh new file mode 100644 index 00000000..8bdf7f47 --- /dev/null +++ b/pre_build.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +# 废弃 api 检测脚本+项目编译脚本 +# 首次使用记得安装jq: brew install jq +# + +# 设置 +environment="xhj" +main_file="lib/main_xhj_full.dart" +version_string="1.0.51" +file_path="lib/network/api.dart" + +urls=$(curl -s -X POST -d "version=$version_string" 'https://lock.xhjcn.ltd/api/app/getDeprecatedApiList' | jq -r '.data[].url') +echo "* 成功获取废弃 api 数据" + +string_array=() +# 使用egrep搜索被单引号包裹的字符串 +while IFS= read -r line; do + string_array+=("$line") +done < <(egrep -o "'[^']*'" "$file_path") +echo "* 解析 api 文件数据,开始对比" + +# 比较urls和string_array中的元素 +for url in $urls; do + for string in "${string_array[@]}"; do + # 移除单引号以便比较 + cleaned_string=$(echo "$string" | tr -d "'") + if [[ "$cleaned_string" == "$url" ]]; then + echo "错误: 存在废弃 api: $url" + exit 1 + fi + done +done +echo "* 没有发现 废弃 api,开始编译" + +flutter clean && flutter pub get +flutter build apk --flavor $environment -t $main_file +flutter build ios --flavor $environment -t $main_file + From fd449954cfd88bd981625905a5d4439004f2e74b Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Fri, 21 Jun 2024 10:41:11 +0800 Subject: [PATCH 2/2] =?UTF-8?q?1=EF=BC=8C=E6=96=B0=E5=A2=9E=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E5=AF=BC=E5=87=BA=E8=AE=B0=E5=BD=95=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E9=80=BB=E8=BE=91=202=EF=BC=8CiOS=E7=AB=AF=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E8=AE=B0=E5=BD=95=E5=8F=8A=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E5=88=86=E4=BA=AB=E6=96=87=E4=BB=B6=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Runner/XSFlutterManager.m | 89 +++++------- .../batchExportLog/batchExportLog_logic.dart | 3 +- .../exportRecordDialog_page.dart | 2 +- .../exportSuccess/exportSuccess_page.dart | 135 +----------------- .../viewExportRecord_page.dart | 5 - 5 files changed, 46 insertions(+), 188 deletions(-) diff --git a/ios/Runner/XSFlutterManager.m b/ios/Runner/XSFlutterManager.m index b33e8d5c..d53ee425 100755 --- a/ios/Runner/XSFlutterManager.m +++ b/ios/Runner/XSFlutterManager.m @@ -1,70 +1,62 @@ -// -// XSFlutterManager.m -// Runner -// -// Created by DaisyWu on 2023/10/14. -// - #import "XSFlutterManager.h" #include "GeneratedPluginRegistrant.h" #import "CommonDefine.h" - @interface XSFlutterManager () -@property(nonatomic,strong) FlutterMethodChannel* methodChannel; -@property (nonatomic, copy) NSString *textToShare; -@property (nonatomic, copy) NSString *urlToShare; +@property(nonatomic, strong) FlutterMethodChannel *methodChannel; +@property(nonatomic, copy) NSString *textToShare; +@property(nonatomic, copy) NSString *urlToShare; +@property(nonatomic, copy) NSArray *activityItems; @end -@implementation XSFlutterManager{ -} - +@implementation XSFlutterManager - (void)viewDidLoad { [super viewDidLoad]; self.textToShare = [[NSString alloc] init]; - self.textToShare = [[NSString alloc] init]; + self.urlToShare = [[NSString alloc] init]; + self.activityItems = [[NSArray alloc] init]; [self methodChannelFunction]; } + - (void)methodChannelFunction { + // 创建 FlutterMethodChannel + self.methodChannel = [FlutterMethodChannel methodChannelWithName:XSflutterMethodChannel binaryMessenger:self]; - //创建 FlutterMethodChannel - self.methodChannel = [FlutterMethodChannel - methodChannelWithName:XSflutterMethodChannel binaryMessenger:self]; - //设置监听 - [self.methodChannel setMethodCallHandler:^(FlutterMethodCall* methodCall, FlutterResult result) { - // TODO - NSString *method=methodCall.method; - //调用系统分享 + // 设置监听 + [self.methodChannel setMethodCallHandler:^(FlutterMethodCall *methodCall, FlutterResult result) { + NSString *method = methodCall.method; + // 调用系统分享 if ([method isEqualToString:XSflutterMethodSharePassword]) { id params = methodCall.arguments; self.textToShare = @"您好,您的密码是:"; if ([params isKindOfClass:[NSDictionary class]]) { NSDictionary *paramDic = (NSDictionary *)params; - //分享的标题 + // 分享的标题 self.textToShare = paramDic[@"shareText"]; self.urlToShare = paramDic[@"urlToShare"]; } - if ([self.urlToShare isEqualToString:"fileShare"]) { + + if ([self.urlToShare isEqualToString:@"fileShare"]) { // 创建要分享或操作的文件对象 - let fileURL = URL(fileURLWithPath: "/path/to/file.pdf") + NSURL *fileURL = [NSURL fileURLWithPath:self.textToShare]; // 将文件对象添加到数组中 - let activityItems = [fileURL] + self.activityItems = @[fileURL]; } else { - //分享的url + // 分享的 URL NSURL *urlToShare = [NSURL URLWithString:self.urlToShare]; - //在这里呢 如果想分享图片 就把图片添加进去 文字什么的通上 - NSArray *activityItems = @[self.textToShare,urlToShare]; + // 在这里呢 如果想分享图片 就把图片添加进去 文字什么的通上 + self.activityItems = @[self.textToShare, urlToShare]; } - UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil]; + UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:self.activityItems applicationActivities:nil]; - //不出现在活动项目 + // 不出现在活动项目 activityVC.excludedActivityTypes = @[UIActivityTypePrint]; [self presentViewController:activityVC animated:YES completion:nil]; @@ -72,40 +64,37 @@ activityVC.completionWithItemsHandler = ^(UIActivityType _Nullable activityType, BOOL completed, NSArray * _Nullable returnedItems, NSError * _Nullable activityError) { if (completed) { NSLog(@"completed"); - //分享 成功 - } else { - NSLog(@"cancled"); - //分享 取消 + // 分享成功 + } else { + NSLog(@"canceled"); + // 分享取消 } }; result(@"push返回到flutter"); } }]; + [GeneratedPluginRegistrant registerWithRegistry:self]; } - - - --(void)viewWillAppear:(BOOL)animated{ +- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:YES]; } --(void)viewWillDisappear:(BOOL)animated{ +- (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [self.navigationController setNavigationBarHidden:NO]; } - /* - #pragma mark - Navigation - - // In a storyboard-based application, you will often want to do a little preparation before navigation - - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - // Get the new view controller using [segue destinationViewController]. - // Pass the selected object to the new view controller. - } - */ +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ @end diff --git a/lib/main/lockDetail/doorLockLog/batchExportLog/batchExportLog_logic.dart b/lib/main/lockDetail/doorLockLog/batchExportLog/batchExportLog_logic.dart index 35103fda..59815605 100644 --- a/lib/main/lockDetail/doorLockLog/batchExportLog/batchExportLog_logic.dart +++ b/lib/main/lockDetail/doorLockLog/batchExportLog/batchExportLog_logic.dart @@ -38,7 +38,8 @@ class BatchExportLogLogic extends BaseGetXController { final http.Response response = await http.get(Uri.parse(url)); if (response.statusCode == 200) { final Directory directory = await getApplicationDocumentsDirectory(); - final File file = File('${directory.path}/exported_file.pdf'); + final File file = File( + '${directory.path}/record${DateTime.now().millisecondsSinceEpoch}.xlsx'); await file.writeAsBytes(response.bodyBytes); return file.path; } else { diff --git a/lib/main/lockDetail/doorLockLog/exportRecordDialog/exportRecordDialog_page.dart b/lib/main/lockDetail/doorLockLog/exportRecordDialog/exportRecordDialog_page.dart index 8b7a4f6a..015ac1f5 100644 --- a/lib/main/lockDetail/doorLockLog/exportRecordDialog/exportRecordDialog_page.dart +++ b/lib/main/lockDetail/doorLockLog/exportRecordDialog/exportRecordDialog_page.dart @@ -225,7 +225,7 @@ class __DerivedRecordWidgetState extends State<_DerivedRecordWidget> { final http.Response response = await http.get(Uri.parse(url)); if (response.statusCode == 200) { final Directory directory = await getApplicationDocumentsDirectory(); - final File file = File('${directory.path}/exported_file.xlsx'); + final File file = File('${directory.path}/record.xlsx'); await file.writeAsBytes(response.bodyBytes); return file.path; } else { diff --git a/lib/main/lockDetail/doorLockLog/exportSuccess/exportSuccess_page.dart b/lib/main/lockDetail/doorLockLog/exportSuccess/exportSuccess_page.dart index c04aa30d..e36c6f27 100644 --- a/lib/main/lockDetail/doorLockLog/exportSuccess/exportSuccess_page.dart +++ b/lib/main/lockDetail/doorLockLog/exportSuccess/exportSuccess_page.dart @@ -3,17 +3,15 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:open_file/open_file.dart'; import 'package:path_provider/path_provider.dart'; -import 'package:star_lock/appRouters.dart'; import 'package:star_lock/app_settings/app_colors.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/exportSuccess/exportSuccess_logic.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/exportSuccess/exportSuccess_state.dart'; import 'package:star_lock/tools/NativeInteractionTool.dart'; -import 'package:star_lock/tools/commonDataManage.dart'; import 'package:star_lock/tools/submitBtn.dart'; import 'package:star_lock/tools/titleAppBar.dart'; import 'package:url_launcher/url_launcher.dart'; -import 'package:open_file/open_file.dart'; class ExportSuccessPage extends StatefulWidget { const ExportSuccessPage({Key? key}) : super(key: key); @@ -40,7 +38,6 @@ class _ExportSuccessPageState extends State with RouteAware { } // 导出成功 - Widget sendElectronicKeySucceed() { return Column( children: [ @@ -83,19 +80,6 @@ class _ExportSuccessPageState extends State with RouteAware { btnName: '立即查看'.tr, onClick: () { OpenFile.open(state.getFilePath.value); - NativeInteractionTool() - .loadNativeFileShare(shareText: state.getFilePath.value); - - // openFile(state.getFilePath.value); - // previewFile(); - // Get.toNamed(Routers.viewExportRecordPage, - // arguments: { - // 'filePath': state.getFilePath.value, - // }); - // Get.toNamed(Routers.webviewShowPage, arguments: { - // 'url': state.getFilePath.value, - // 'title': '查看操作记录'.tr - // }); }), SizedBox( height: 20.h, @@ -103,27 +87,19 @@ class _ExportSuccessPageState extends State with RouteAware { OutLineBtn( btnName: '分享'.tr, onClick: () { - _openModalBottomSheet(); + NativeInteractionTool() + .loadNativeFileShare(shareText: state.getFilePath.value); }, ), ], ); } - // Future openFile(String filePath) async { - // final File file = File(filePath); - // if (await file.exists()) { - // await launchUrl(Uri.parse('file://$filePath')); - // } else { - // throw 'File not found'; - // } - // } - Future previewFile() async { // 获取本地文件路径 final Directory appDocDir = await getApplicationDocumentsDirectory(); final String appDocPath = appDocDir.path; - final String filePath = '$appDocPath/exported_file.xlsx'; + final String filePath = '$appDocPath/record.xlsx'; // 检查文件是否存在 final File file = File(filePath); @@ -137,107 +113,4 @@ class _ExportSuccessPageState extends State with RouteAware { print('File does not exist'); } } - - Future _openModalBottomSheet() async { - showModalBottomSheet( - context: context, - shape: RoundedRectangleBorder( - borderRadius: BorderRadiusDirectional.circular(10)), - constraints: BoxConstraints(maxHeight: 270.h), - builder: (BuildContext context) { - return Column( - children: [ - SizedBox( - width: ScreenUtil().screenWidth, - height: 160.h, - child: ListView( - scrollDirection: Axis.horizontal, //横向滚动 - children: initBottomSheetList()), - ), - Container( - height: 8.h, - color: AppColors.greyBackgroundColor, - ), - TextButton( - style: ButtonStyle( - overlayColor: - MaterialStateProperty.all(Colors.white)), - child: Text( - '取消'.tr, - style: TextStyle( - color: Colors.black, fontSize: ScreenUtil().setSp(24)), - ), - onPressed: () { - Navigator.pop(context); - }, - ) - ], - ); - }); - } - - List initBottomSheetList() { - final List widgetList = []; - - widgetList.add(buildCenter3('images/icon_wechat.png', '微信好友'.tr, 0)); - widgetList.add(buildCenter3('images/icon_message.png', '短信'.tr, 1)); - widgetList.add(buildCenter3('images/icon_email.png', '邮件'.tr, 2)); - widgetList.add(buildCenter3('images/icon_more.png', '更多'.tr, 3)); - - return widgetList; - } - - GestureDetector buildCenter3( - String imageName, String titleStr, int itemIndex) { - return GestureDetector( - child: Container( - width: 120.w, - // height: 64.h, - margin: - EdgeInsets.only(top: 20.w, bottom: 20.w, left: 10.w, right: 10.w), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Image.asset( - imageName, - width: 50.w, - height: 50.h, - ), - SizedBox( - height: 16.w, - ), - Text( - titleStr, - style: TextStyle( - fontSize: ScreenUtil().setSp(20), color: Colors.black), - ), - ], - ), - ), - onTap: () => jumpSmartDeviceRoute(itemIndex), - ); - } - - Future jumpSmartDeviceRoute(int itemIndex) async { - Get.back(); - // final String pwdShareStr = logic.getShareContentStr(); - switch (itemIndex) { - case 0: //微信好友 - // NativeInteractionTool().loadNativeShare(shareText: pwdShareStr); - break; - case 1: //短信 - case 2: //邮件 - Get.toNamed(Routers.sendEmailNotificationPage, - arguments: { - 'receiver': '', - 'channelType': itemIndex == 1 ? 1 : 2, - 'keyId': CommonDataManage().currentKeyInfo.keyId, - }); - break; - case 3: //更多 - // NativeInteractionTool().loadNativeShare(shareText: pwdShareStr); - break; - default: - } - } } diff --git a/lib/main/lockDetail/doorLockLog/viewExportRecord/viewExportRecord_page.dart b/lib/main/lockDetail/doorLockLog/viewExportRecord/viewExportRecord_page.dart index 05c3c524..8d2ff415 100644 --- a/lib/main/lockDetail/doorLockLog/viewExportRecord/viewExportRecord_page.dart +++ b/lib/main/lockDetail/doorLockLog/viewExportRecord/viewExportRecord_page.dart @@ -1,11 +1,6 @@ -import 'dart:io'; -import 'dart:typed_data'; - import 'package:flutter/material.dart'; import 'package:get/get.dart'; -import 'package:path_provider/path_provider.dart'; import 'package:star_lock/app_settings/app_colors.dart'; -import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/viewExportRecord/viewExportRecord_logic.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/viewExportRecord/viewExportRecord_state.dart'; import 'package:star_lock/tools/titleAppBar.dart';