From d86d2e232bc9dc87a89d8b00025a7a73d1e745fa Mon Sep 17 00:00:00 2001 From: wangtao Date: Sun, 19 Mar 2023 11:51:51 +0800 Subject: [PATCH 01/17] =?UTF-8?q?feat=EF=BC=9A=E6=B7=BB=E5=8A=A0=E6=96=B0?= =?UTF-8?q?=E7=9A=84=E5=88=9D=E5=A7=8B=E5=8C=96=E6=96=B9=E6=B3=95=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0config=E5=92=8Cuiconfig=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Classes/Api/MOP_initialize.m | 1 - ios/Classes/Api/Mop_newInitialize.h | 18 + ios/Classes/Api/Mop_newInitialize.m | 149 +++++++ lib/mop.dart | 590 +++++++++++++++++++++++++++- 4 files changed, 756 insertions(+), 2 deletions(-) create mode 100644 ios/Classes/Api/Mop_newInitialize.h create mode 100644 ios/Classes/Api/Mop_newInitialize.m diff --git a/ios/Classes/Api/MOP_initialize.m b/ios/Classes/Api/MOP_initialize.m index f75a922..14a621d 100644 --- a/ios/Classes/Api/MOP_initialize.m +++ b/ios/Classes/Api/MOP_initialize.m @@ -30,7 +30,6 @@ for (NSDictionary *dict in _finStoreConfigs) { FATStoreConfig *storeConfig = [[FATStoreConfig alloc] init]; storeConfig.sdkKey = dict[@"sdkKey"]; - // storeConfig.sdkKey = @"22LyZEib0gLTQdU3MUauAb4V4W8Uxd/gMgmH8Hg1bGQ="; storeConfig.sdkSecret = dict[@"sdkSecret"]; storeConfig.apiServer = dict[@"apiServer"]; storeConfig.apmServer = dict[@"apmServer"]; diff --git a/ios/Classes/Api/Mop_newInitialize.h b/ios/Classes/Api/Mop_newInitialize.h new file mode 100644 index 0000000..cc5a599 --- /dev/null +++ b/ios/Classes/Api/Mop_newInitialize.h @@ -0,0 +1,18 @@ +// +// Mop_newInitialize.h +// mop +// +// Created by 滔 on 2023/3/17. +// + +#import +#import "MOPBaseApi.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface Mop_newInitialize : MOPBaseApi +@property (nonatomic, strong) NSDictionary *config; +@property (nonatomic, strong) NSDictionary *uiConfig; +@end + +NS_ASSUME_NONNULL_END diff --git a/ios/Classes/Api/Mop_newInitialize.m b/ios/Classes/Api/Mop_newInitialize.m new file mode 100644 index 0000000..1ac09c6 --- /dev/null +++ b/ios/Classes/Api/Mop_newInitialize.m @@ -0,0 +1,149 @@ +// +// Mop_newInitialize.m +// mop +// +// Created by 滔 on 2023/3/17. +// + +#import "Mop_newInitialize.h" +#import "MOPTools.h" + +@implementation Mop_newInitialize + +- (void)setupApiWithSuccess:(void (^)(NSDictionary * _Nonnull))success failure:(void (^)(id _Nullable))failure cancel:(void (^)(void))cancel +{ + if (!self.config) { + failure(@"config不能为空"); + return; + } + FATConfig *config; + NSArray *storeConfigList = self.config[@"storeConfigs"]; + if (storeConfigList && storeConfigList.count > 0) { + NSMutableArray *storeArrayM = [NSMutableArray array]; + for (NSDictionary *dict in storeConfigList) { + FATStoreConfig *storeConfig = [[FATStoreConfig alloc] init]; + storeConfig.sdkKey = dict[@"sdkKey"]; + storeConfig.sdkSecret = dict[@"sdkSecret"]; + storeConfig.apiServer = dict[@"apiServer"]; + storeConfig.apmServer = dict[@"apmServer"]; + storeConfig.fingerprint = dict[@"fingerprint"]; + if ([@"SM" isEqualToString:dict[@"cryptType"]]) { + storeConfig.cryptType = FATApiCryptTypeSM; + } else { + storeConfig.cryptType = FATApiCryptTypeMD5; + } + storeConfig.encryptServerData = [dict[@"encryptServerData"] boolValue]; + [storeArrayM addObject:storeConfig]; + } + config = [FATConfig configWithStoreConfigs:storeArrayM]; + } else { + failure(@"storeConfigs不能为空"); + return; + } + + config.currentUserId = self.config[@"currentUserId"]; + config.productIdentification = self.config[@"productIdentification"]; + config.disableAuthorize = [self.config[@"disableAuthorize"] boolValue]; + config.appletAutoAuthorize = [self.config[@"appletAutoAuthorize"] boolValue]; + config.disableGetSuperviseInfo = [self.config[@"disableGetSuperviseInfo"] boolValue]; + config.ignoreWebviewCertAuth = [self.config[@"ignoreWebviewCertAuth"] boolValue]; + config.appletIntervalUpdateLimit = [self.config[@"appletIntervalUpdateLimit"] integerValue]; + config.startCrashProtection = [self.config[@"startCrashProtection"] boolValue]; + config.enableApmDataCompression = [self.config[@"enableApmDataCompression"] boolValue]; + config.encryptServerData = [self.config[@"encryptServerData"] boolValue]; + config.enableAppletDebug = [self.config[@"enableAppletDebug"] integerValue]; + config.enableWatermark = [self.config[@"enableWatermark"] boolValue]; + config.watermarkPriority = [self.config[@"watermarkPriority"] integerValue]; + config.baseLoadingViewClass = self.config[@"baseLoadingViewClass"]; + config.baseLoadFailedViewClass = self.config[@"baseLoadFailedViewClass"]; + config.header = self.config[@"header"]; + config.headerPriority = [self.config[@"headerPriority"] integerValue]; + config.enableH5AjaxHook = [self.config[@"enableH5AjaxHook"] boolValue]; + config.h5AjaxHookRequestKey = self.config[@"h5AjaxHookRequestKey"]; + config.pageCountLimit = [self.config[@"pageCountLimit"] integerValue]; + config.schemes = self.config[@"schemes"]; + + + NSError* error = nil; + FATUIConfig *uiconfig = [[FATUIConfig alloc]init]; + uiconfig.autoAdaptDarkMode = YES; + if (_uiConfig) { + if (_uiConfig[@"navigationTitleTextAttributes"]) { + uiconfig.navigationTitleTextAttributes = _uiConfig[@"navigationTitleTextAttributes"]; + } + + uiconfig.navigationBarHeight = [_uiConfig[@"navigationBarHeight"] floatValue]; + if (_uiConfig[@"navigationBarTitleLightColor"]) { + uiconfig.navigationBarTitleLightColor = [MOPTools colorWithRGBHex:[_uiConfig[@"navigationBarTitleLightColor"] intValue]]; + } + if (_uiConfig[@"navigationBarTitleDarkColor"]) { + uiconfig.navigationBarTitleDarkColor = [MOPTools colorWithRGBHex:[_uiConfig[@"navigationBarTitleDarkColor"] intValue]]; + } + if (_uiConfig[@"navigationBarBackBtnLightColor"]) { + uiconfig.navigationBarBackBtnLightColor = [MOPTools colorWithRGBHex:[_uiConfig[@"navigationBarBackBtnLightColor"] intValue]]; + } + if (_uiConfig[@"navigationBarBackBtnDarkColor"]) { + uiconfig.navigationBarBackBtnDarkColor = [MOPTools colorWithRGBHex:[_uiConfig[@"navigationBarBackBtnDarkColor"] intValue]]; + } + uiconfig.moreMenuStyle = [_uiConfig[@"moreMenuStyle"] integerValue]; + uiconfig.hideBackToHomePriority = [_uiConfig[@"hideBackToHomePriority"] integerValue]; + uiconfig.hideFeedbackMenu = [_uiConfig[@"isHideFeedbackAndComplaints"] boolValue]; + uiconfig.hideBackToHome = [_uiConfig[@"isHideBackHome"] boolValue]; + uiconfig.hideForwardMenu = [_uiConfig[@"isHideForwardMenu"] boolValue]; +// uiconfig. = [_uiConfig[@"isHideRefreshMenu"] integerValue]; + uiconfig.moreMenuStyle = [_uiConfig[@"moreMenuStyle"] integerValue]; + uiconfig.moreMenuStyle = [_uiConfig[@"moreMenuStyle"] integerValue]; + if (_uiConfig[@"progressBarColor"]) { + uiconfig.progressBarColor = [MOPTools colorWithRGBHex:[_uiConfig[@"progressBarColor"] intValue]]; + } + + uiconfig.hideFeedbackMenu = [_uiConfig[@"isHideFeedbackAndComplaints"] boolValue]; + uiconfig.hideForwardMenu = [_uiConfig[@"isHideForwardMenu"] boolValue]; + uiconfig.autoAdaptDarkMode = [_uiConfig[@"autoAdaptDarkMode"] boolValue]; + + uiconfig.appletText = _uiConfig[@"appletText"]; + uiconfig.hideTransitionCloseButton = [_uiConfig[@"hideTransitionCloseButton"] boolValue]; + uiconfig.disableSlideCloseAppletGesture = [_uiConfig[@"disableSlideCloseAppletGesture"] boolValue]; + if (_uiConfig[@"capsuleConfig"]) { + NSDictionary *capsuleConfigDic = _uiConfig[@"capsuleConfig"]; + FATCapsuleConfig *capsuleConfig = [[FATCapsuleConfig alloc]init]; + capsuleConfig.capsuleWidth = [capsuleConfigDic[@"capsuleWidth"] floatValue]; + capsuleConfig.capsuleHeight = [capsuleConfigDic[@"capsuleHeight"] floatValue]; + capsuleConfig.capsuleRightMargin = [capsuleConfigDic[@"capsuleRightMargin"] floatValue]; + capsuleConfig.capsuleCornerRadius = [capsuleConfigDic[@"capsuleCornerRadius"] floatValue]; + capsuleConfig.capsuleBorderWidth = [capsuleConfigDic[@"capsuleBorderWidth"] floatValue]; + capsuleConfig.moreBtnWidth = [capsuleConfigDic[@"moreBtnWidth"] floatValue]; + capsuleConfig.moreBtnLeftMargin = [capsuleConfigDic[@"moreBtnLeftMargin"] floatValue]; + capsuleConfig.closeBtnWidth = [capsuleConfigDic[@"closeBtnWidth"] floatValue]; + capsuleConfig.closeBtnLeftMargin = [capsuleConfigDic[@"closeBtnLeftMargin"] floatValue]; + + + capsuleConfig.capsuleBorderLightColor = [MOPTools colorWithRGBHex:[capsuleConfigDic[@"capsuleBorderLightColor"] intValue]]; + capsuleConfig.capsuleBorderDarkColor = [MOPTools colorWithRGBHex:[capsuleConfigDic[@"capsuleBorderDarkColor"] intValue]]; + capsuleConfig.capsuleBgLightColor = [MOPTools colorWithRGBHex:[capsuleConfigDic[@"capsuleBgLightColor"] intValue]]; + capsuleConfig.capsuleBgDarkColor = [MOPTools colorWithRGBHex:[capsuleConfigDic[@"capsuleBgDarkColor"] intValue]]; + capsuleConfig.capsuleDividerLightColor = [MOPTools colorWithRGBHex:[capsuleConfigDic[@"capsuleDividerLightColor"] intValue]]; + capsuleConfig.capsuleDividerDarkColor = [MOPTools colorWithRGBHex:[capsuleConfigDic[@"capsuleDividerDarkColor"] intValue]]; + uiconfig.capsuleConfig = capsuleConfig; + + } + uiconfig.appendingCustomUserAgent = _uiConfig[@"customWebViewUserAgent"]; + } + + + // uiconfig.moreMenuStyle = FATMoreViewStyleNormal; + [[FATClient sharedClient] initWithConfig:config uiConfig:uiconfig error:&error]; + if (error) { + failure(@"初始化失败"); + return; + } +// [[FATExtClient sharedClient] fat_prepareExtensionApis]; + [[FATClient sharedClient].logManager initLogWithLogDir:nil logLevel:FATLogLevelVerbose consoleLog:YES]; + + + [[FATClient sharedClient] setEnableLog:YES]; + + success(@{}); + +} +@end diff --git a/lib/mop.dart b/lib/mop.dart index e70d79e..96cc789 100644 --- a/lib/mop.dart +++ b/lib/mop.dart @@ -51,9 +51,198 @@ class FinStoreConfig { } } +class FATConfig { + /** + 当前用户id,对应管理后台的用户管理->成员管理->用户id。 + 若体验版本配置了体验成员,则需要设置正确的userId才能具备打开小程序的权限 + 登录/切换用户/退出登录时,需要修改此值。 + 小程序缓存信息会存储在以userId命名的不同目录下。 + */ +String? currentUserId; + +/** + 产品的标识,非必传,默认为存储目录里的finclip,finogeeks和userAgent里的finogeeks + */ +String? productIdentification; + +/** +是否不让SDK申请权限 +如果设置为true,则SDK内使用权限的api,不会主动申请权限 +*/ +bool disableAuthorize = false; + +/** + 小程序自动申请授权 + 如果设置为true,则小程序申请权限时不会弹出用户确认提示框 + */ +bool appletAutoAuthorize = false; + +/** + 是否禁用SDK的监管接口API(默认开启:false) + 如果设置为true,则SDK禁用监管接口API +*/ +bool disableGetSuperviseInfo = false; + +/** + 是否忽略webview的证书校验,默认为false,进行校验 + 如果设置为true,则忽略校验Https的证书 +*/ +bool ignoreWebviewCertAuth = false; + +/** +后台自动检查更新的小程序个数 +初始化SDK成功后,如处于wifi网络下,更新最近使用的x个小程序 +取值范围:0~50。0代表不检查更新;不设置默认是3。 +*/ +int appletIntervalUpdateLimit = 3; + +/** +apm 统计的扩展信息 +*/ +Map? apmExtension; + +/** 是否开启Crash防崩溃,默认为false。(iOS支持) + 如果开启,可以防止如下类型的崩溃:UnrecognizedSelector、KVO、Notification、Timer、Container(数组越界,字典插入nil等)、String (越界、nil等) + 如果在开发阶段,建议关闭该属性,否则开发时不便于及时发现代码中的崩溃问题。 +*/ +bool startCrashProtection = false; + +Map? theme; + +/** + * 数据上报时,是否压缩请求的数据 + * 默认为false + */ +bool enableApmDataCompression = false; + +/** +是否需要接口加密验证(初始化单服务器时使用) +默认为不开启,当设置为YES时开启,接口返回加密数据并处理 +*/ +bool encryptServerData = false; + +/** + 是否开启小程序的debug模式。 + 默认为FATBOOLStateUndefined,此时为旧版通过app.json 中 debug:true 开启vconsole。 + 当设置为FATBOOLStateTrue时,强制所有的小程序都会开启vconsole。 + 当设置为FATBOOLStateFalse时,非正式版会在更多菜单里显示打开和关闭调试的菜单。 + 当设置为FATBOOLStateForbidden时,所有版本强制关闭vconsole,且不可调api开启,多面板不展示打开、关闭调试菜单 + */ +@property (nonatomic, assign) FATBOOLState enableAppletDebug; + +/** + 是否显示水印 + */ +bool enableWatermark = false; + +/** + 显示水印优先级设置,默认全局配置优先 + */ +ConfigPriority watermarkPriority = ConfigPriority.ConfigGlobalPriority; + +/** + 小程序的自定义启动加载页,非必填。 + 自定义启动加载页必须继承自FATBaseLoadingView + 注意:swift中的类名带有命名空间,需要在前拼接项目文件名,如:“SwiftDemo.FCloadingView”。其中SwiftDemo是项目名,FCloadingView是类名 +*/ +String? baseLoadingViewClass; + +/** + 小程序的自定义启动失败页,非必填。 + 自定义启动失败页必须继承自FATBaseLoadFailedView + 注意:swift中的类名带有命名空间,需要在前拼接项目文件名,如:“SwiftDemo.FCloadingView”。其中SwiftDemo是项目名,FCloadingView是类名 +*/ +String? baseLoadFailedViewClass; + +/** + 统一设置小程序中网络请求的header。 + 注意,如果小程序调用api时也传递了相同的key,则会用小程序传递的参数覆盖。 + 对ft.request、ft.downloadFile、ft.uploadFile均会生效 + */ +Map? header; + +/** + header优先级设置,默认全局配置优先 + */ +ConfigPriority headerPriority = ConfigPriority.ConfigGlobalPriority; + +/** + 是否开启小程序中加载的H5页面hook功能,非必填。 + 如果宿主app 拦截了http 或https,会导致H5中的request 丢失body。我们SDK为了兼容这一问题,会hook request请求, + 在发起请求之前,先将body中的参数,通过代理方法传递给宿主App。宿主App可自行存储每个request的body,然后在 + 自定义的URLProtocol里发起请求之前,组装上body内容。 + */ +bool enableH5AjaxHook = false; + +/** + 开启enableH5AjaxHook后,会hook request请求,会在原request 的url 后拼上一个FinClipHookBridge-RequestId=xxx的参数。 + 而该参数可设置参数名,比如您可以设置Key 为 FinClip-RequestId,这样会拼接FinClip-RequestId=xxx的参数。 + */ +String? h5AjaxHookRequestKey; + +/** + 小程序中页面栈的最大限制。默认值为0,标识不限制。 + 例如,设置为5,则表示页面栈中最多可有5个页面。从主页最多可再navigateTo 4 层页面。 + */ +int pageCountLimit = 0; + +/** + 自定义的scheme数组 + */ +List schemes = []; + + Map toMap() { + return { + "currentUserId": currentUserId, + "productIdentification": productIdentification, + + "disableAuthorize": disableAuthorize, + "appletAutoAuthorize": appletAutoAuthorize, + "disableGetSuperviseInfo": disableGetSuperviseInfo, + "ignoreWebviewCertAuth": ignoreWebviewCertAuth, + "appletIntervalUpdateLimit": appletIntervalUpdateLimit, + "apmExtension": apmExtension, + "enableApmDataCompression": enableApmDataCompression, + "encryptServerData": encryptServerData, + "enableAppletDebug": enableAppletDebug, + "enableWatermark": enableWatermark, + "watermarkPriority": watermarkPriority.index, + "baseLoadingViewClass": baseLoadingViewClass, + "baseLoadFailedViewClass": baseLoadFailedViewClass, + "header": header, + "headerPriority": headerPriority.index, + "enableH5AjaxHook": enableH5AjaxHook, + "pageCountLimit": pageCountLimit, + "schemes": schemes, + }; + } +} + class UIConfig { Map? navigationTitleTextAttributes; //导航栏的标题样式,目前支持了font + //导航栏的高度(不含状态栏高度),默认值为44 + double navigationBarHeight = 44; + + //导航栏的标题颜色(深色主题),默认值为白色 + int navigationBarTitleLightColor = 0xffffffff; + + //导航栏的标题颜色(明亮主题),默认值为黑色 + int navigationBarTitleDarkColor = 0xff000000; + + //导航栏的返回按钮颜色(深色主题),默认值为白色 + int navigationBarBackBtnLightColor = 0xffffffff; + + //导航栏的返回按钮颜色(明亮主题),默认值为黑色 + int navigationBarBackBtnDarkColor 0xff000000; + + // int? navigationBackImage; + //弹出的菜单视图的样式 0:默认 1: + int moreMenuStyle = 0; + + //隐藏导航栏返回首页按钮的优先级设置,默认全局配置优先 不支持FATConfigAppletFilePriority + ConfigPriority hideBackToHomePriority = ConfigPriority.ConfigGlobalPriority + ///当导航栏为默认导航栏时,是否始终显示返回按钮 bool isAlwaysShowBackInDefaultNavigationBar = false; @@ -66,9 +255,21 @@ class UIConfig { ///是否隐藏"更多"菜单中的"返回首页"菜单入口 bool isHideBackHome = false; - ///是否隐藏"更多"菜单中的"转发"按钮 + //隐藏...弹出菜单中的 【转发】 的菜单,默认为false bool isHideForwardMenu = false; + //隐藏...弹出菜单中的 【反馈与投诉】 的菜单,默认为false + bool isHideFeedbackMenu = false; + + //隐藏...弹出菜单中的 【分享】 的菜单,默认为true + bool isHideShareAppletMenu = true; + + //隐藏...弹出菜单中的 【重新进入小程序】 的菜单,默认为false + bool isHideRefreshMenu = false; + + //隐藏...弹出菜单中的 【设置】 的菜单,默认为false + bool isHideSettingMenu = false; + /// 加载小程序过程中(小程序Service层还未加载成功,基础库还没有向SDK传递小程序配置信息),是否隐藏导航栏的关闭按钮 bool hideTransitionCloseButton = false; @@ -78,21 +279,57 @@ class UIConfig { /// 胶囊按钮配置 CapsuleConfig? capsuleConfig; + //返回首页按钮的配置 + NavHomeConfig? navHomeConfig; + FloatWindowConfig? floatWindowConfig; + //权限弹窗UI配置 + AuthViewConfig? authViewConfig; + //iOS中独有的设置属性 //小程序里加载H5页面时进度条的颜色 格式 0xFFFFAA00 int? progressBarColor; + //隐藏小程序里加载H5时进度条,默认为false + bool hideWebViewProgressBar = false; + + + //是否自适应暗黑模式。如果设置为true,则更多页面、关于等原生页面会随着手机切换暗黑,也自动调整为暗黑模式 bool autoAdaptDarkMode = true; + //要拼接的userAgent字符串 + String? appendingCustomUserAgent; + /** + 打开小程序时的默认动画方式,默认为FATTranstionStyleUp。 + 该属性主要针对非api方式打开小程序时的动画缺省值。主要改变如下场景的动画方式: + 1. scheme 打开小程序; + 2. universal link 打开小程序; + 3. navigateToMiniprogram + */ + TranstionStyle transtionStyle = TranstionStyle.TranstionStyleUp; + + //是否隐藏转场页的关闭按钮。默认为false + bool hideTransitionCloseButton = false; + + /** + 是否禁用侧滑关闭小程序的手势。默认为NO + 该手势禁用,不影响小程序里页面的侧滑返回上一页的功能 + */ + bool disableSlideCloseAppletGesture = false; + //注入小程序统称appletText字符串,默认为“小程序”。 String? appletText; Map toMap() { return { "navigationTitleTextAttributes": navigationTitleTextAttributes, + "navigationBarHeight": navigationBarHeight, + "navigationBarTitleLightColor": navigationBarTitleLightColor, + "navigationBarTitleDarkColor": navigationBarTitleDarkColor, + "navigationBarBackBtnLightColor": navigationBarBackBtnLightColor, + "navigationBarBackBtnDarkColor": navigationBarBackBtnDarkColor, "isAlwaysShowBackInDefaultNavigationBar": isAlwaysShowBackInDefaultNavigationBar, "isClearNavigationBarNavButtonBackground": @@ -100,12 +337,25 @@ class UIConfig { "isHideFeedbackAndComplaints": isHideFeedbackAndComplaints, "isHideBackHome": isHideBackHome, "isHideForwardMenu": isHideForwardMenu, + "isHideRefreshMenu": isHideRefreshMenu, + "isHideFeedbackMenu": isHideFeedbackMenu, + "isHideShareAppletMenu": isHideShareAppletMenu, + "isHideSettingMenu": isHideSettingMenu, "hideTransitionCloseButton": hideTransitionCloseButton, "disableSlideCloseAppletGesture": disableSlideCloseAppletGesture, "capsuleConfig": capsuleConfig?.toMap(), + "navHomeConfig": navHomeConfig?.toMap(), + "authViewConfig": authViewConfig,toMap(,) "floatWindowConfig": floatWindowConfig?.toMap(), "progressBarColor": progressBarColor, + "hideWebViewProgressBar": hideWebViewProgressBar, + "moreMenuStyle": moreMenuStyle, + "hideBackToHomePriority": hideBackToHomePriority, "autoAdaptDarkMode": autoAdaptDarkMode, + "appendingCustomUserAgent": appendingCustomUserAgent, + "transtionStyle":transtionStyle.index, + "hideTransitionCloseButton": hideTransitionCloseButton, + "disableSlideCloseAppletGesture": disableSlideCloseAppletGesture, "appletText": appletText }; } @@ -218,6 +468,316 @@ class FloatWindowConfig { } } +class NavHomeConfig { + /** + 返回首页按钮的宽度 + */ + double width; + +/** + 返回首页按钮的高度 + */ + double height; + +/** + 返回首页按钮的左边距,默认值为10 + */ + double leftMargin; + +/** + 返回首页按钮的圆角半径,默认值为5 + */ + double cornerRadius; + +/** + 返回首页按钮的边框宽度,默认值为0.8 + */ + double borderWidth; + +/** + 浅色返回首页按钮的图片对象,如果不传,会使用默认图标 + (暗黑模式) +*/ +// int? lightImage; + +/** + 深色返回首页按钮的图片对象,如果不传,会使用默认图标 + (明亮模式) +*/ +// int? darkImage; + +/** + 返回首页按钮的边框浅色颜色 + (暗黑模式) + */ + int borderLightColor; + +/** + 返回首页按钮的边框深色颜色 + (明亮模式) + */ + int borderDarkColor; + +/** + 返回首页按钮的背景浅色颜色 + (明亮模式) + */ + int bgLightColor; + +/** + 返回首页按钮的背景深色颜色 + (暗黑模式) + */ + int bgDarkColor; + + Map toMap() { + return { + "width": width, + "height": height, + "leftMargin": leftMargin, + "cornerRadius": cornerRadius, + "borderWidth": borderWidth, + "borderLightColor": borderLightColor, + "borderDarkColor": borderDarkColor, + "bgLightColor": bgLightColor, + "bgDarkColor": bgDarkColor, + }; + } +} + +class AuthViewConfig { +/** + 小程序名称字体大小,默认字体为PingFangSC-Regular,默认大小16 + */ +int appletNameFont; + +/** + 小程序名称的浅色颜色(明亮模式),默认#202020 + */ +int appletNameLightColor; + +/** + 小程序名称的深色颜色(暗黑模式),默认#D0D0D0 + */ +int appletNameDarkColor; + +/** + 隐私协议入口icon(明亮模式),大小:22pt(@2× @3×) + */ +int agreementLightImage; + +/** + 隐私协议入口icon(暗黑模式),大小:22pt(@2× @3×) + */ +int agreementDarkImage; + +/** + 权限标题字体大小,默认字体为PingFangSC-Medium,默认大小17 + 备注:权限选项文字字体大小使用该配置项,但字体固定为PingFangSC-Regular + */ +int authorizeTitleFont; + +/** + 权限标题的浅色颜色(明亮模式),默认#202020 + 备注:权限选项文字字体颜色使用该配置项 + */ +int authorizeTitleLightColor; + +/** + 权限标题的深色颜色(暗黑模式),默认#D0D0D0 + 备注:权限选项文字字体颜色使用该配置项 + */ +int authorizeTitleDarkColor; + +/** + 权限描述字体大小,默认字体为PingFangSC-Regular,默认大小14 + */ +int authorizeDescriptionFont; + +/** + 权限描述的浅色颜色(明亮模式),默认#666666 + */ +int authorizeDescriptionLightColor; + +/** + 权限描述的深色颜色(暗黑模式),默认#8C8C8C + */ +int authorizeDescriptionDarkColor; + +/** + 协议标题字体大小,默认字体为PingFangSC-Regular,默认大小16 + */ +int agreementTitleFont; + +/** + 协议标题的浅色颜色(明亮模式),默认#202020 + */ +int agreementTitleLightColor; + +/** + 协议标题的深色颜色(暗黑模式),默认#D0D0D0 + */ +int agreementTitleDarkColor; + +/** + 协议描述字体大小,默认字体为PingFangSC-Regular,默认大小14 + */ +int agreementDescriptionFont; + +/** + 协议描述的浅色颜色(明亮模式),默认#202020 + */ +int agreementDescriptionLightColor; + +/** + 协议描述的深色颜色(暗黑模式),默认#D0D0D0 + */ +int agreementDescriptionDarkColor; + +/** + 权限选项选中时的icon(明亮模式),大小:22pt(@2× @3×) + */ +int authorizeSelectedLightImage; + +/** + 权限选项选中时的icon(暗黑模式),大小:22pt(@2× @3×) + */ +int authorizeSelectedDarkImage; + +/** + 链接的浅色颜色(明亮模式),默认#409EFF + */ +int linkLightColor; + +/** + 链接的深色颜色(暗黑模式),默认#368CE4 + */ +int linkDarkColor; + +/** + 同意按钮配置(明亮模式),默认配置如下: + 圆角:4 + 默认背景色:#4285F4 + 默认描边:#4285F4 + 默认文字颜色:#FFFFFF + 按下背景色:#3B77DB + 按下默认描边:#3B77DB + 按下文字颜色:#FFFFFF + */ +AuthButtonConfig allowButtonLightConfig; + +/** + 同意按钮配置(暗黑模式),默认配置如下: + 圆角:4 + 默认背景色:#4285F4 + 默认描边:#4285F4 + 默认文字颜色:#FFFFFF + 按下背景色:#5E97F5 + 按下默认描边:#5E97F5 + 按下文字颜色:#FFFFFF + */ +AuthButtonConfig allowButtonDarkConfig; + +/** + 拒绝按钮配置(明亮模式),默认配置如下: + 圆角:4 + 默认背景色:#FFFFFF + 默认描边:#E2E2E2 + 默认文字颜色:#222222 + 按下背景色:#D8D8D8 + 按下默认描边:#D8D8D8 + 按下文字颜色:#222222 + */ +AuthButtonConfig rejectButtonLightConfig; + +/** + 拒绝按钮配置(暗黑模式),默认配置如下: + 圆角:4 + 默认背景色:#2C2C2C + 默认描边:#2C2C2C + 默认文字颜色:#D0D0D0 + 按下背景色:#414141 + 按下默认描边:#414141 + 按下文字颜色:#D0D0D0 + */ +AuthButtonConfig rejectButtonDarkConfig; + +Map toMap() { + return { + "appletNameFont": appletNameFont, + "appletNameLightColor": appletNameLightColor, + "appletNameDarkColor": appletNameDarkColor, + "authorizeTitleFont": authorizeTitleFont, + "authorizeTitleLightColor": authorizeTitleLightColor, + "authorizeTitleDarkColor": authorizeTitleDarkColor, + "authorizeDescriptionFont": authorizeDescriptionFont, + "authorizeDescriptionLightColor": authorizeDescriptionLightColor, + "authorizeDescriptionDarkColor": authorizeDescriptionDarkColor, + + "agreementTitleFont": agreementTitleFont, + "agreementTitleLightColor": agreementTitleLightColor, + "agreementTitleDarkColor": agreementTitleDarkColor, + "agreementDescriptionFont": agreementDescriptionFont, + "agreementDescriptionDarkColor": agreementDescriptionDarkColor, + "linkLightColor": linkLightColor, + "linkDarkColor": linkDarkColor, + "allowButtonLightConfig": allowButtonLightConfig.toMap(), + "allowButtonDarkConfig": allowButtonDarkConfig.toMap(), + "rejectButtonLightConfig": rejectButtonLightConfig.toMap(), + "rejectButtonDarkConfig": rejectButtonDarkConfig.toMap(), + }; + } +} + +class AuthButtonConfig { + /** + 按钮的圆角半径 + */ +double cornerRadius; + +/** + 按钮默认背景颜色 + */ +int normalBackgroundColor; + +/** + 按钮按下背景颜色 + */ +int pressedBackgroundColor; + +/** + 按钮默认文字颜色 + */ +int normalTextColor; + +/** + 按钮按下文字颜色 + */ +int pressedTextColor; + +/** + 按钮默认边框颜色 + */ +int normalBorderColor; + +/** + 按钮按下边框颜色 + */ +int pressedBorderColor; + +Map toMap() { + return { + "cornerRadius": cornerRadius, + "normalBackgroundColor": normalBackgroundColor, + "pressedBackgroundColor": pressedBackgroundColor, + "normalTextColor": normalTextColor, + "pressedTextColor": pressedTextColor, + "normalBorderColor": normalBorderColor, + "pressedBorderColor": pressedBorderColor + }; + } +} + class BaseAppletRequest { // 服务器地址,必填 String apiServer; @@ -325,6 +885,17 @@ enum Anim { NoneAnim } +enum ConfigPriority { + ConfigGlobalPriority , //全局配置优先 + ConfigSpecifiedPriority, // 单个配置优先 + ConfigAppletFilePriority, // 小程序配置文件优先,小程序app.ext.json文件中配置 +} + +enum TranstionStyle { + TranstionStyleUp, // 页面从下往上弹出,类似present效果 + TranstionStylePush, // 页面从右往左弹出,类似push效果 +} + class Mop { static final Mop _instance = new Mop._internal(); late MethodChannel _channel; @@ -405,6 +976,7 @@ class Mop { /// [userId] 用户id /// [finStoreConfigs] 多服务配置 /// [uiConfig] UI配置 + /// [config] 小程序相关配置 /// [debug] 设置debug模式,影响调试和日志 /// [customWebViewUserAgent] 设置自定义webview ua /// [appletIntervalUpdateLimit] 设置小程序批量更新周期 @@ -452,6 +1024,22 @@ class Mop { return ret; } + Future newInitialize( + FATConfig config, + { + UIConfig? uiConfig + } + }) async { + List>? storeConfigs = + finStoreConfigs?.map((e) => e.toMap()).toList(); + + final Map ret = await _channel.invokeMethod('newInitialize', { + 'config': config, + 'uiConfig': uiConfig, + }); + return ret; + } + /// open the miniprogram [appId] from the mop server. /// 打开小程序 /// [appId] is required. From 01c782236a956a52ff0581611c1e2bc102ed5eb1 Mon Sep 17 00:00:00 2001 From: wangtao Date: Mon, 20 Mar 2023 10:43:14 +0800 Subject: [PATCH 02/17] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E6=96=B0=E7=9A=84sdk=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=8C=E5=8F=82=E6=95=B0=E4=B8=BAconfig?= =?UTF-8?q?=E5=92=8CuiConfig?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Classes/Api/Mop_newInitialize.m | 150 ++++++++++++++++- ios/mop.podspec | 4 +- lib/mop.dart | 239 ++++++++++++---------------- 3 files changed, 254 insertions(+), 139 deletions(-) diff --git a/ios/Classes/Api/Mop_newInitialize.m b/ios/Classes/Api/Mop_newInitialize.m index 1ac09c6..09702f4 100644 --- a/ios/Classes/Api/Mop_newInitialize.m +++ b/ios/Classes/Api/Mop_newInitialize.m @@ -90,9 +90,10 @@ uiconfig.hideFeedbackMenu = [_uiConfig[@"isHideFeedbackAndComplaints"] boolValue]; uiconfig.hideBackToHome = [_uiConfig[@"isHideBackHome"] boolValue]; uiconfig.hideForwardMenu = [_uiConfig[@"isHideForwardMenu"] boolValue]; -// uiconfig. = [_uiConfig[@"isHideRefreshMenu"] integerValue]; - uiconfig.moreMenuStyle = [_uiConfig[@"moreMenuStyle"] integerValue]; - uiconfig.moreMenuStyle = [_uiConfig[@"moreMenuStyle"] integerValue]; + uiconfig.hideShareAppletMenu = [_uiConfig[@"isHideShareAppletMenu"] boolValue]; + uiconfig.hideRefreshMenu = [_uiConfig[@"isHideRefreshMenu"] boolValue]; + uiconfig.hideTransitionCloseButton = [_uiConfig[@"hideTransitionCloseButton"] integerValue]; + uiconfig.disableSlideCloseAppletGesture = [_uiConfig[@"disableSlideCloseAppletGesture"] boolValue]; if (_uiConfig[@"progressBarColor"]) { uiconfig.progressBarColor = [MOPTools colorWithRGBHex:[_uiConfig[@"progressBarColor"] intValue]]; } @@ -102,7 +103,6 @@ uiconfig.autoAdaptDarkMode = [_uiConfig[@"autoAdaptDarkMode"] boolValue]; uiconfig.appletText = _uiConfig[@"appletText"]; - uiconfig.hideTransitionCloseButton = [_uiConfig[@"hideTransitionCloseButton"] boolValue]; uiconfig.disableSlideCloseAppletGesture = [_uiConfig[@"disableSlideCloseAppletGesture"] boolValue]; if (_uiConfig[@"capsuleConfig"]) { NSDictionary *capsuleConfigDic = _uiConfig[@"capsuleConfig"]; @@ -127,10 +127,122 @@ uiconfig.capsuleConfig = capsuleConfig; } + + if (_uiConfig[@"navHomeConfig"]) { + NSDictionary *navHomeConfigDic = _uiConfig[@"navHomeConfig"]; + FATNavHomeConfig *navHomeConfig = [[FATNavHomeConfig alloc]init]; + navHomeConfig.width = [navHomeConfigDic[@"width"] floatValue]; + navHomeConfig.height = [navHomeConfigDic[@"height"] floatValue]; + navHomeConfig.leftMargin = [navHomeConfigDic[@"leftMargin"] floatValue]; + navHomeConfig.cornerRadius = [navHomeConfigDic[@"cornerRadius"] floatValue]; + navHomeConfig.borderWidth = [navHomeConfigDic[@"width"] floatValue]; + if (navHomeConfigDic[@"borderLightColor"]) { + navHomeConfig.borderLightColor = [MOPTools colorWithRGBHex:[navHomeConfigDic[@"borderLightColor"] intValue]]; + } + if (navHomeConfigDic[@"borderDarkColor"]) { + navHomeConfig.borderDarkColor = [MOPTools colorWithRGBHex:[navHomeConfigDic[@"borderDarkColor"] intValue]]; + } + if (navHomeConfigDic[@"bgLightColor"]) { + navHomeConfig.bgLightColor = [MOPTools colorWithRGBHex:[navHomeConfigDic[@"bgLightColor"] intValue]]; + } + if (navHomeConfigDic[@"bgDarkColor"]) { + navHomeConfig.bgDarkColor = [MOPTools colorWithRGBHex:[navHomeConfigDic[@"bgDarkColor"] intValue]]; + } + uiconfig.navHomeConfig = navHomeConfig; + } + + if (_uiConfig[@"authViewConfig"]) { + NSDictionary *authViewConfigDic = _uiConfig[@"authViewConfig"]; + FATAuthViewConfig *authViewConfig = [[FATAuthViewConfig alloc]init]; + authViewConfig.appletNameFont = [UIFont systemFontOfSize:[authViewConfigDic[@"appletNameFont"] integerValue]]; + if (authViewConfigDic[@"appletNameLightColor"]) { + authViewConfig.appletNameLightColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"appletNameLightColor"] intValue]]; + } + + if (authViewConfigDic[@"appletNameDarkColor"]) { + authViewConfig.appletNameDarkColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"appletNameDarkColor"] intValue]]; + } + + authViewConfig.authorizeTitleFont = [UIFont systemFontOfSize:[authViewConfigDic[@"authorizeTitleFont"] integerValue] weight:UIFontWeightMedium]; + + if (authViewConfigDic[@"authorizeTitleLightColor"]) { + authViewConfig.authorizeTitleLightColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"authorizeTitleLightColor"] intValue]]; + } + + if (authViewConfigDic[@"authorizeTitleDarkColor"]) { + authViewConfig.authorizeTitleDarkColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"authorizeTitleDarkColor"] intValue]]; + } + + authViewConfig.authorizeDescriptionFont = [UIFont systemFontOfSize:[authViewConfigDic[@"authorizeDescriptionFont"] integerValue]]; + + if (authViewConfigDic[@"authorizeDescriptionLightColor"]) { + authViewConfig.authorizeDescriptionLightColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"authorizeDescriptionLightColor"] intValue]]; + } + + if (authViewConfigDic[@"authorizeDescriptionDarkColor"]) { + authViewConfig.authorizeDescriptionDarkColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"authorizeDescriptionDarkColor"] intValue]]; + } + + authViewConfig.agreementTitleFont = [UIFont systemFontOfSize:[authViewConfigDic[@"agreementTitleFont"] integerValue]]; + + if (authViewConfigDic[@"agreementTitleLightColor"]) { + authViewConfig.agreementTitleLightColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"agreementTitleLightColor"] intValue]]; + } + + if (authViewConfigDic[@"agreementTitleDarkColor"]) { + authViewConfig.agreementTitleDarkColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"agreementTitleDarkColor"] intValue]]; + } + + authViewConfig.agreementDescriptionFont = [UIFont systemFontOfSize:[authViewConfigDic[@"agreementDescriptionFont"] integerValue]]; + + if (authViewConfigDic[@"agreementDescriptionLightColor"]) { + authViewConfig.agreementDescriptionLightColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"agreementDescriptionLightColor"] intValue]]; + } + + if (authViewConfigDic[@"agreementDescriptionDarkColor"]) { + authViewConfig.agreementDescriptionDarkColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"agreementDescriptionDarkColor"] intValue]]; + } + + if (authViewConfigDic[@"linkLightColor"]) { + authViewConfig.linkLightColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"linkLightColor"] intValue]]; + } + + if (authViewConfigDic[@"linkDarkColor"]) { + authViewConfig.linkDarkColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"linkDarkColor"] intValue]]; + } + + if (authViewConfigDic[@"allowButtonLightConfig"]) { + FATAuthButtonConfig *allowButtonLightConfig = [self createAuthButtonConfigWithDic:authViewConfigDic[@"allowButtonLightConfig"]]; + authViewConfig.allowButtonLightConfig = allowButtonLightConfig; + + } + + if (authViewConfigDic[@"allowButtonDarkConfig"]) { + FATAuthButtonConfig *allowButtonDarkConfig = [self createAuthButtonConfigWithDic:authViewConfigDic[@"allowButtonDarkConfig"]]; + authViewConfig.allowButtonDarkConfig = allowButtonDarkConfig; + + } + if (authViewConfigDic[@"rejectButtonLightConfig"]) { + FATAuthButtonConfig *rejectButtonLightConfig = [self createAuthButtonConfigWithDic:authViewConfigDic[@"rejectButtonLightConfig"]]; + authViewConfig.rejectButtonLightConfig = rejectButtonLightConfig; + + } + if (authViewConfigDic[@"rejectButtonDarkConfig"]) { + FATAuthButtonConfig *rejectButtonDarkConfig = [self createAuthButtonConfigWithDic:authViewConfigDic[@"rejectButtonDarkConfig"]]; + authViewConfig.rejectButtonDarkConfig = rejectButtonDarkConfig; + + } + + uiconfig.authViewConfig = authViewConfig; + } uiconfig.appendingCustomUserAgent = _uiConfig[@"customWebViewUserAgent"]; + uiconfig.hideWebViewProgressBar = [_uiConfig[@"hideWebViewProgressBar"] boolValue]; + uiconfig.autoAdaptDarkMode = [_uiConfig[@"autoAdaptDarkMode"] boolValue]; + uiconfig.transtionStyle = [_uiConfig[@"transtionStyle"] integerValue]; } + // uiconfig.moreMenuStyle = FATMoreViewStyleNormal; [[FATClient sharedClient] initWithConfig:config uiConfig:uiconfig error:&error]; if (error) { @@ -146,4 +258,34 @@ success(@{}); } + +- (FATAuthButtonConfig *)createAuthButtonConfigWithDic:(NSDictionary *)dic { + if (!dic) { + return nil; + } + FATAuthButtonConfig * authButtonConfig = [[FATAuthButtonConfig alloc]init]; + if (dic[@"cornerRadius"]) { + authButtonConfig.cornerRadius = [dic[@"cornerRadius"] floatValue]; + } + if (dic[@"normalBackgroundColor"]) { + authButtonConfig.normalBackgroundColor = [MOPTools colorWithRGBHex:[dic[@"normalBackgroundColor"] intValue]]; + } + if (dic[@"pressedBackgroundColor"]) { + authButtonConfig.pressedBackgroundColor = [MOPTools colorWithRGBHex:[dic[@"pressedBackgroundColor"] intValue]]; + } + if (dic[@"normalTextColor"]) { + authButtonConfig.normalTextColor = [MOPTools colorWithRGBHex:[dic[@"normalTextColor"] intValue]]; + } + if (dic[@"pressedTextColor"]) { + authButtonConfig.pressedTextColor = [MOPTools colorWithRGBHex:[dic[@"pressedTextColor"] intValue]]; + } + if (dic[@"normalBorderColor"]) { + authButtonConfig.normalBorderColor = [MOPTools colorWithRGBHex:[dic[@"normalBorderColor"] intValue]]; + } + if (dic[@"pressedBorderColor"]) { + authButtonConfig.pressedBorderColor = [MOPTools colorWithRGBHex:[dic[@"pressedBorderColor"] intValue]]; + } + + return authButtonConfig; +} @end diff --git a/ios/mop.podspec b/ios/mop.podspec index 3481d07..1f7d386 100644 --- a/ios/mop.podspec +++ b/ios/mop.podspec @@ -17,7 +17,7 @@ A finclip miniprogram flutter sdk. s.dependency 'Flutter' s.ios.deployment_target = '9.0' - s.dependency 'FinApplet' , '2.39.7' - s.dependency 'FinAppletExt' , '2.39.7' + s.dependency 'FinApplet' , '2.39.11' + s.dependency 'FinAppletExt' , '2.39.11' end diff --git a/lib/mop.dart b/lib/mop.dart index 96cc789..d0d1f87 100644 --- a/lib/mop.dart +++ b/lib/mop.dart @@ -53,73 +53,77 @@ class FinStoreConfig { class FATConfig { /** + 要初始化的服务器配置对象列表 + */ + List storeConfigs; + /** 当前用户id,对应管理后台的用户管理->成员管理->用户id。 若体验版本配置了体验成员,则需要设置正确的userId才能具备打开小程序的权限 登录/切换用户/退出登录时,需要修改此值。 小程序缓存信息会存储在以userId命名的不同目录下。 */ -String? currentUserId; + String? currentUserId; /** 产品的标识,非必传,默认为存储目录里的finclip,finogeeks和userAgent里的finogeeks */ -String? productIdentification; + String? productIdentification; /** 是否不让SDK申请权限 如果设置为true,则SDK内使用权限的api,不会主动申请权限 */ -bool disableAuthorize = false; + bool disableAuthorize = false; /** 小程序自动申请授权 如果设置为true,则小程序申请权限时不会弹出用户确认提示框 */ -bool appletAutoAuthorize = false; + bool appletAutoAuthorize = false; /** 是否禁用SDK的监管接口API(默认开启:false) 如果设置为true,则SDK禁用监管接口API */ -bool disableGetSuperviseInfo = false; + bool disableGetSuperviseInfo = false; /** 是否忽略webview的证书校验,默认为false,进行校验 如果设置为true,则忽略校验Https的证书 */ -bool ignoreWebviewCertAuth = false; + bool ignoreWebviewCertAuth = false; /** 后台自动检查更新的小程序个数 初始化SDK成功后,如处于wifi网络下,更新最近使用的x个小程序 取值范围:0~50。0代表不检查更新;不设置默认是3。 */ -int appletIntervalUpdateLimit = 3; + int appletIntervalUpdateLimit = 3; /** apm 统计的扩展信息 */ -Map? apmExtension; + Map? apmExtension; /** 是否开启Crash防崩溃,默认为false。(iOS支持) 如果开启,可以防止如下类型的崩溃:UnrecognizedSelector、KVO、Notification、Timer、Container(数组越界,字典插入nil等)、String (越界、nil等) 如果在开发阶段,建议关闭该属性,否则开发时不便于及时发现代码中的崩溃问题。 */ -bool startCrashProtection = false; + bool startCrashProtection = false; -Map? theme; + Map? theme; /** * 数据上报时,是否压缩请求的数据 * 默认为false */ -bool enableApmDataCompression = false; + bool enableApmDataCompression = false; /** 是否需要接口加密验证(初始化单服务器时使用) 默认为不开启,当设置为YES时开启,接口返回加密数据并处理 */ -bool encryptServerData = false; + bool encryptServerData = false; /** 是否开启小程序的debug模式。 @@ -128,43 +132,43 @@ bool encryptServerData = false; 当设置为FATBOOLStateFalse时,非正式版会在更多菜单里显示打开和关闭调试的菜单。 当设置为FATBOOLStateForbidden时,所有版本强制关闭vconsole,且不可调api开启,多面板不展示打开、关闭调试菜单 */ -@property (nonatomic, assign) FATBOOLState enableAppletDebug; + FATBOOLState enableAppletDebug = FATBOOLState.FATBOOLStateUndefined; /** 是否显示水印 */ -bool enableWatermark = false; + bool enableWatermark = false; /** 显示水印优先级设置,默认全局配置优先 */ -ConfigPriority watermarkPriority = ConfigPriority.ConfigGlobalPriority; + ConfigPriority watermarkPriority = ConfigPriority.ConfigGlobalPriority; /** 小程序的自定义启动加载页,非必填。 自定义启动加载页必须继承自FATBaseLoadingView 注意:swift中的类名带有命名空间,需要在前拼接项目文件名,如:“SwiftDemo.FCloadingView”。其中SwiftDemo是项目名,FCloadingView是类名 */ -String? baseLoadingViewClass; + String? baseLoadingViewClass; /** 小程序的自定义启动失败页,非必填。 自定义启动失败页必须继承自FATBaseLoadFailedView 注意:swift中的类名带有命名空间,需要在前拼接项目文件名,如:“SwiftDemo.FCloadingView”。其中SwiftDemo是项目名,FCloadingView是类名 */ -String? baseLoadFailedViewClass; + String? baseLoadFailedViewClass; /** 统一设置小程序中网络请求的header。 注意,如果小程序调用api时也传递了相同的key,则会用小程序传递的参数覆盖。 对ft.request、ft.downloadFile、ft.uploadFile均会生效 */ -Map? header; + Map? header; /** header优先级设置,默认全局配置优先 */ -ConfigPriority headerPriority = ConfigPriority.ConfigGlobalPriority; + ConfigPriority headerPriority = ConfigPriority.ConfigGlobalPriority; /** 是否开启小程序中加载的H5页面hook功能,非必填。 @@ -172,30 +176,34 @@ ConfigPriority headerPriority = ConfigPriority.ConfigGlobalPriority; 在发起请求之前,先将body中的参数,通过代理方法传递给宿主App。宿主App可自行存储每个request的body,然后在 自定义的URLProtocol里发起请求之前,组装上body内容。 */ -bool enableH5AjaxHook = false; + bool enableH5AjaxHook = false; /** 开启enableH5AjaxHook后,会hook request请求,会在原request 的url 后拼上一个FinClipHookBridge-RequestId=xxx的参数。 而该参数可设置参数名,比如您可以设置Key 为 FinClip-RequestId,这样会拼接FinClip-RequestId=xxx的参数。 */ -String? h5AjaxHookRequestKey; + String? h5AjaxHookRequestKey; /** 小程序中页面栈的最大限制。默认值为0,标识不限制。 例如,设置为5,则表示页面栈中最多可有5个页面。从主页最多可再navigateTo 4 层页面。 */ -int pageCountLimit = 0; + int pageCountLimit = 0; /** 自定义的scheme数组 */ -List schemes = []; + List schemes = []; - Map toMap() { + FATConfig(this.storeConfigs); + + Map toMap() { + List>? finStoreConfigs = + storeConfigs.map((e) => e.toMap()).toList(); return { + "storeConfigs": finStoreConfigs, "currentUserId": currentUserId, "productIdentification": productIdentification, - "disableAuthorize": disableAuthorize, "appletAutoAuthorize": appletAutoAuthorize, "disableGetSuperviseInfo": disableGetSuperviseInfo, @@ -204,7 +212,7 @@ List schemes = []; "apmExtension": apmExtension, "enableApmDataCompression": enableApmDataCompression, "encryptServerData": encryptServerData, - "enableAppletDebug": enableAppletDebug, + "enableAppletDebug": enableAppletDebug.index, "enableWatermark": enableWatermark, "watermarkPriority": watermarkPriority.index, "baseLoadingViewClass": baseLoadingViewClass, @@ -215,7 +223,7 @@ List schemes = []; "pageCountLimit": pageCountLimit, "schemes": schemes, }; - } + } } class UIConfig { @@ -234,19 +242,19 @@ class UIConfig { int navigationBarBackBtnLightColor = 0xffffffff; //导航栏的返回按钮颜色(明亮主题),默认值为黑色 - int navigationBarBackBtnDarkColor 0xff000000; + int navigationBarBackBtnDarkColor = 0xff000000; // int? navigationBackImage; //弹出的菜单视图的样式 0:默认 1: int moreMenuStyle = 0; //隐藏导航栏返回首页按钮的优先级设置,默认全局配置优先 不支持FATConfigAppletFilePriority - ConfigPriority hideBackToHomePriority = ConfigPriority.ConfigGlobalPriority + ConfigPriority hideBackToHomePriority = ConfigPriority.ConfigGlobalPriority; - ///当导航栏为默认导航栏时,是否始终显示返回按钮 + ///当导航栏为默认导航栏时,是否始终显示返回按钮 ios未发现该属性 bool isAlwaysShowBackInDefaultNavigationBar = false; - ///是否清除导航栏导航按钮的背景 + ///是否清除导航栏导航按钮的背景 ios未发现该属性 bool isClearNavigationBarNavButtonBackground = false; ///是否隐藏"更多"菜单中的"反馈与投诉"菜单入口 @@ -258,9 +266,6 @@ class UIConfig { //隐藏...弹出菜单中的 【转发】 的菜单,默认为false bool isHideForwardMenu = false; - //隐藏...弹出菜单中的 【反馈与投诉】 的菜单,默认为false - bool isHideFeedbackMenu = false; - //隐藏...弹出菜单中的 【分享】 的菜单,默认为true bool isHideShareAppletMenu = true; @@ -270,12 +275,6 @@ class UIConfig { //隐藏...弹出菜单中的 【设置】 的菜单,默认为false bool isHideSettingMenu = false; - /// 加载小程序过程中(小程序Service层还未加载成功,基础库还没有向SDK传递小程序配置信息),是否隐藏导航栏的关闭按钮 - bool hideTransitionCloseButton = false; - - /// 禁用侧滑关闭小程序手势 - bool disableSlideCloseAppletGesture = false; - /// 胶囊按钮配置 CapsuleConfig? capsuleConfig; @@ -294,8 +293,6 @@ class UIConfig { //隐藏小程序里加载H5时进度条,默认为false bool hideWebViewProgressBar = false; - - //是否自适应暗黑模式。如果设置为true,则更多页面、关于等原生页面会随着手机切换暗黑,也自动调整为暗黑模式 bool autoAdaptDarkMode = true; @@ -310,7 +307,7 @@ class UIConfig { */ TranstionStyle transtionStyle = TranstionStyle.TranstionStyleUp; - //是否隐藏转场页的关闭按钮。默认为false + /// 加载小程序过程中(小程序Service层还未加载成功,基础库还没有向SDK传递小程序配置信息),是否隐藏导航栏的关闭按钮 bool hideTransitionCloseButton = false; /** @@ -338,23 +335,20 @@ class UIConfig { "isHideBackHome": isHideBackHome, "isHideForwardMenu": isHideForwardMenu, "isHideRefreshMenu": isHideRefreshMenu, - "isHideFeedbackMenu": isHideFeedbackMenu, "isHideShareAppletMenu": isHideShareAppletMenu, "isHideSettingMenu": isHideSettingMenu, "hideTransitionCloseButton": hideTransitionCloseButton, - "disableSlideCloseAppletGesture": disableSlideCloseAppletGesture, "capsuleConfig": capsuleConfig?.toMap(), "navHomeConfig": navHomeConfig?.toMap(), - "authViewConfig": authViewConfig,toMap(,) + "authViewConfig": authViewConfig?.toMap(), "floatWindowConfig": floatWindowConfig?.toMap(), "progressBarColor": progressBarColor, "hideWebViewProgressBar": hideWebViewProgressBar, "moreMenuStyle": moreMenuStyle, - "hideBackToHomePriority": hideBackToHomePriority, + "hideBackToHomePriority": hideBackToHomePriority.index, "autoAdaptDarkMode": autoAdaptDarkMode, "appendingCustomUserAgent": appendingCustomUserAgent, - "transtionStyle":transtionStyle.index, - "hideTransitionCloseButton": hideTransitionCloseButton, + "transtionStyle": transtionStyle.index, "disableSlideCloseAppletGesture": disableSlideCloseAppletGesture, "appletText": appletText }; @@ -482,29 +476,17 @@ class NavHomeConfig { /** 返回首页按钮的左边距,默认值为10 */ - double leftMargin; + double leftMargin = 10; /** 返回首页按钮的圆角半径,默认值为5 */ - double cornerRadius; + double cornerRadius = 5; /** 返回首页按钮的边框宽度,默认值为0.8 */ - double borderWidth; - -/** - 浅色返回首页按钮的图片对象,如果不传,会使用默认图标 - (暗黑模式) -*/ -// int? lightImage; - -/** - 深色返回首页按钮的图片对象,如果不传,会使用默认图标 - (明亮模式) -*/ -// int? darkImage; + double borderWidth = 0.8; /** 返回首页按钮的边框浅色颜色 @@ -530,6 +512,9 @@ class NavHomeConfig { */ int bgDarkColor; + NavHomeConfig(this.width, this.height, this.borderLightColor, + this.borderDarkColor, this.bgLightColor, this.bgDarkColor); + Map toMap() { return { "width": width, @@ -549,110 +534,90 @@ class AuthViewConfig { /** 小程序名称字体大小,默认字体为PingFangSC-Regular,默认大小16 */ -int appletNameFont; + int appletNameFont = 16; /** 小程序名称的浅色颜色(明亮模式),默认#202020 */ -int appletNameLightColor; + int appletNameLightColor = 0xff202020; /** 小程序名称的深色颜色(暗黑模式),默认#D0D0D0 */ -int appletNameDarkColor; - -/** - 隐私协议入口icon(明亮模式),大小:22pt(@2× @3×) - */ -int agreementLightImage; - -/** - 隐私协议入口icon(暗黑模式),大小:22pt(@2× @3×) - */ -int agreementDarkImage; + int appletNameDarkColor = 0xffd0d0d0; /** 权限标题字体大小,默认字体为PingFangSC-Medium,默认大小17 备注:权限选项文字字体大小使用该配置项,但字体固定为PingFangSC-Regular */ -int authorizeTitleFont; + int authorizeTitleFont = 17; /** 权限标题的浅色颜色(明亮模式),默认#202020 备注:权限选项文字字体颜色使用该配置项 */ -int authorizeTitleLightColor; + int authorizeTitleLightColor = 0xff202020; /** 权限标题的深色颜色(暗黑模式),默认#D0D0D0 备注:权限选项文字字体颜色使用该配置项 */ -int authorizeTitleDarkColor; + int authorizeTitleDarkColor = 0xffd0d0d0; /** 权限描述字体大小,默认字体为PingFangSC-Regular,默认大小14 */ -int authorizeDescriptionFont; + int authorizeDescriptionFont = 14; /** 权限描述的浅色颜色(明亮模式),默认#666666 */ -int authorizeDescriptionLightColor; + int authorizeDescriptionLightColor = 0xff666666; /** 权限描述的深色颜色(暗黑模式),默认#8C8C8C */ -int authorizeDescriptionDarkColor; + int authorizeDescriptionDarkColor = 0xff8c8c8c; /** 协议标题字体大小,默认字体为PingFangSC-Regular,默认大小16 */ -int agreementTitleFont; + int agreementTitleFont = 16; /** 协议标题的浅色颜色(明亮模式),默认#202020 */ -int agreementTitleLightColor; + int agreementTitleLightColor = 0xff202020; /** 协议标题的深色颜色(暗黑模式),默认#D0D0D0 */ -int agreementTitleDarkColor; + int agreementTitleDarkColor = 0xffd0d0d0; /** 协议描述字体大小,默认字体为PingFangSC-Regular,默认大小14 */ -int agreementDescriptionFont; + int agreementDescriptionFont = 14; /** 协议描述的浅色颜色(明亮模式),默认#202020 */ -int agreementDescriptionLightColor; + int agreementDescriptionLightColor = 0xff202020; /** 协议描述的深色颜色(暗黑模式),默认#D0D0D0 */ -int agreementDescriptionDarkColor; - -/** - 权限选项选中时的icon(明亮模式),大小:22pt(@2× @3×) - */ -int authorizeSelectedLightImage; - -/** - 权限选项选中时的icon(暗黑模式),大小:22pt(@2× @3×) - */ -int authorizeSelectedDarkImage; + int agreementDescriptionDarkColor = 0xffd0d0d0; /** 链接的浅色颜色(明亮模式),默认#409EFF */ -int linkLightColor; + int linkLightColor = 0xff409eff; /** 链接的深色颜色(暗黑模式),默认#368CE4 */ -int linkDarkColor; + int linkDarkColor = 0xff368ce4; /** 同意按钮配置(明亮模式),默认配置如下: @@ -664,7 +629,7 @@ int linkDarkColor; 按下默认描边:#3B77DB 按下文字颜色:#FFFFFF */ -AuthButtonConfig allowButtonLightConfig; + AuthButtonConfig? allowButtonLightConfig; /** 同意按钮配置(暗黑模式),默认配置如下: @@ -676,7 +641,7 @@ AuthButtonConfig allowButtonLightConfig; 按下默认描边:#5E97F5 按下文字颜色:#FFFFFF */ -AuthButtonConfig allowButtonDarkConfig; + AuthButtonConfig? allowButtonDarkConfig; /** 拒绝按钮配置(明亮模式),默认配置如下: @@ -688,7 +653,7 @@ AuthButtonConfig allowButtonDarkConfig; 按下默认描边:#D8D8D8 按下文字颜色:#222222 */ -AuthButtonConfig rejectButtonLightConfig; + AuthButtonConfig? rejectButtonLightConfig; /** 拒绝按钮配置(暗黑模式),默认配置如下: @@ -700,9 +665,9 @@ AuthButtonConfig rejectButtonLightConfig; 按下默认描边:#414141 按下文字颜色:#D0D0D0 */ -AuthButtonConfig rejectButtonDarkConfig; + AuthButtonConfig? rejectButtonDarkConfig; -Map toMap() { + Map toMap() { return { "appletNameFont": appletNameFont, "appletNameLightColor": appletNameLightColor, @@ -713,7 +678,6 @@ Map toMap() { "authorizeDescriptionFont": authorizeDescriptionFont, "authorizeDescriptionLightColor": authorizeDescriptionLightColor, "authorizeDescriptionDarkColor": authorizeDescriptionDarkColor, - "agreementTitleFont": agreementTitleFont, "agreementTitleLightColor": agreementTitleLightColor, "agreementTitleDarkColor": agreementTitleDarkColor, @@ -721,10 +685,10 @@ Map toMap() { "agreementDescriptionDarkColor": agreementDescriptionDarkColor, "linkLightColor": linkLightColor, "linkDarkColor": linkDarkColor, - "allowButtonLightConfig": allowButtonLightConfig.toMap(), - "allowButtonDarkConfig": allowButtonDarkConfig.toMap(), - "rejectButtonLightConfig": rejectButtonLightConfig.toMap(), - "rejectButtonDarkConfig": rejectButtonDarkConfig.toMap(), + "allowButtonLightConfig": allowButtonLightConfig?.toMap(), + "allowButtonDarkConfig": allowButtonDarkConfig?.toMap(), + "rejectButtonLightConfig": rejectButtonLightConfig?.toMap(), + "rejectButtonDarkConfig": rejectButtonDarkConfig?.toMap(), }; } } @@ -733,39 +697,48 @@ class AuthButtonConfig { /** 按钮的圆角半径 */ -double cornerRadius; + double cornerRadius; /** 按钮默认背景颜色 */ -int normalBackgroundColor; + int normalBackgroundColor; /** 按钮按下背景颜色 */ -int pressedBackgroundColor; + int pressedBackgroundColor; /** 按钮默认文字颜色 */ -int normalTextColor; + int normalTextColor; /** 按钮按下文字颜色 */ -int pressedTextColor; + int pressedTextColor; /** 按钮默认边框颜色 */ -int normalBorderColor; + int normalBorderColor; /** 按钮按下边框颜色 */ -int pressedBorderColor; + int pressedBorderColor; -Map toMap() { + AuthButtonConfig( + this.cornerRadius, + this.normalBackgroundColor, + this.pressedBackgroundColor, + this.normalTextColor, + this.pressedTextColor, + this.normalBorderColor, + this.pressedBorderColor); + + Map toMap() { return { "cornerRadius": cornerRadius, "normalBackgroundColor": normalBackgroundColor, @@ -886,16 +859,24 @@ enum Anim { } enum ConfigPriority { - ConfigGlobalPriority , //全局配置优先 - ConfigSpecifiedPriority, // 单个配置优先 + ConfigGlobalPriority, //全局配置优先 + ConfigSpecifiedPriority, // 单个配置优先 ConfigAppletFilePriority, // 小程序配置文件优先,小程序app.ext.json文件中配置 } enum TranstionStyle { - TranstionStyleUp, // 页面从下往上弹出,类似present效果 + TranstionStyleUp, // 页面从下往上弹出,类似present效果 TranstionStylePush, // 页面从右往左弹出,类似push效果 } +enum FATBOOLState { + FATBOOLStateUndefined, // 未设置 + FATBOOLStateTrue, // 所有版本强制开启vconsole,且不可调api关闭,更多面板不展示打开、关闭调试菜单 + FATBOOLStateFalse, // 正式版更多面板不展示打开、关闭调试菜单;非正式版更多面板展示打开、关闭调试菜单;所有版本均可调setEnableDebug开启vconsole。 + FATBOOLStateForbidden, // 所有版本强制关闭vconsole,且不可调api开启,多面板不展示打开、关闭调试菜单 + +} + class Mop { static final Mop _instance = new Mop._internal(); late MethodChannel _channel; @@ -1024,18 +1005,10 @@ class Mop { return ret; } - Future newInitialize( - FATConfig config, - { - UIConfig? uiConfig - } - }) async { - List>? storeConfigs = - finStoreConfigs?.map((e) => e.toMap()).toList(); - + Future newInitialize(FATConfig config, {UIConfig? uiConfig}) async { final Map ret = await _channel.invokeMethod('newInitialize', { - 'config': config, - 'uiConfig': uiConfig, + 'config': config.toMap(), + 'uiConfig': uiConfig?.toMap(), }); return ret; } From 18efa395003f6d8cb26799658920ec739872dca4 Mon Sep 17 00:00:00 2001 From: wangtao Date: Tue, 21 Mar 2023 15:58:07 +0800 Subject: [PATCH 03/17] =?UTF-8?q?fix=EF=BC=9A=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=9A=84sdk=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Classes/Api/{Mop_newInitialize.h => MOP_initSDK.h} | 4 ++-- ios/Classes/Api/{Mop_newInitialize.m => MOP_initSDK.m} | 6 +++--- ios/Classes/Utils/MOPApiConverter.m | 2 +- lib/mop.dart | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) rename ios/Classes/Api/{Mop_newInitialize.h => MOP_initSDK.h} (79%) rename ios/Classes/Api/{Mop_newInitialize.m => MOP_initSDK.m} (99%) diff --git a/ios/Classes/Api/Mop_newInitialize.h b/ios/Classes/Api/MOP_initSDK.h similarity index 79% rename from ios/Classes/Api/Mop_newInitialize.h rename to ios/Classes/Api/MOP_initSDK.h index cc5a599..03f03b5 100644 --- a/ios/Classes/Api/Mop_newInitialize.h +++ b/ios/Classes/Api/MOP_initSDK.h @@ -1,5 +1,5 @@ // -// Mop_newInitialize.h +// Mop_initSDK.h // mop // // Created by 滔 on 2023/3/17. @@ -10,7 +10,7 @@ NS_ASSUME_NONNULL_BEGIN -@interface Mop_newInitialize : MOPBaseApi +@interface MOP_initSDK : MOPBaseApi @property (nonatomic, strong) NSDictionary *config; @property (nonatomic, strong) NSDictionary *uiConfig; @end diff --git a/ios/Classes/Api/Mop_newInitialize.m b/ios/Classes/Api/MOP_initSDK.m similarity index 99% rename from ios/Classes/Api/Mop_newInitialize.m rename to ios/Classes/Api/MOP_initSDK.m index 09702f4..d1d22d7 100644 --- a/ios/Classes/Api/Mop_newInitialize.m +++ b/ios/Classes/Api/MOP_initSDK.m @@ -5,10 +5,10 @@ // Created by 滔 on 2023/3/17. // -#import "Mop_newInitialize.h" +#import "Mop_initSDK.h" #import "MOPTools.h" -@implementation Mop_newInitialize +@implementation MOP_initSDK - (void)setupApiWithSuccess:(void (^)(NSDictionary * _Nonnull))success failure:(void (^)(id _Nullable))failure cancel:(void (^)(void))cancel { @@ -92,7 +92,7 @@ uiconfig.hideForwardMenu = [_uiConfig[@"isHideForwardMenu"] boolValue]; uiconfig.hideShareAppletMenu = [_uiConfig[@"isHideShareAppletMenu"] boolValue]; uiconfig.hideRefreshMenu = [_uiConfig[@"isHideRefreshMenu"] boolValue]; - uiconfig.hideTransitionCloseButton = [_uiConfig[@"hideTransitionCloseButton"] integerValue]; + uiconfig.hideTransitionCloseButton = [_uiConfig[@"hideTransitionCloseButton"] boolValue]; uiconfig.disableSlideCloseAppletGesture = [_uiConfig[@"disableSlideCloseAppletGesture"] boolValue]; if (_uiConfig[@"progressBarColor"]) { uiconfig.progressBarColor = [MOPTools colorWithRGBHex:[_uiConfig[@"progressBarColor"] intValue]]; diff --git a/ios/Classes/Utils/MOPApiConverter.m b/ios/Classes/Utils/MOPApiConverter.m index b5796aa..1b4e8d9 100644 --- a/ios/Classes/Utils/MOPApiConverter.m +++ b/ios/Classes/Utils/MOPApiConverter.m @@ -20,7 +20,7 @@ Class ApiClass = NSClassFromString(apiMethod); if (!ApiClass) { - NSLog(@"MOPybridExtensionConverter Error"); + NSLog(@"MOPybridExtensionConverter Error %@",apiMethod); return nil; } diff --git a/lib/mop.dart b/lib/mop.dart index d0d1f87..7874497 100644 --- a/lib/mop.dart +++ b/lib/mop.dart @@ -1006,7 +1006,7 @@ class Mop { } Future newInitialize(FATConfig config, {UIConfig? uiConfig}) async { - final Map ret = await _channel.invokeMethod('newInitialize', { + final Map ret = await _channel.invokeMethod('initSDK', { 'config': config.toMap(), 'uiConfig': uiConfig?.toMap(), }); From 63589a746cecb2280029942be0b3bca0267261ef Mon Sep 17 00:00:00 2001 From: wangtao Date: Tue, 21 Mar 2023 16:36:50 +0800 Subject: [PATCH 04/17] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E6=96=B0?= =?UTF-8?q?=E5=A2=9Esdk=E5=88=9D=E5=A7=8B=E5=8C=96=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E7=9A=84=E6=96=B9=E6=B3=95=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/mop.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mop.dart b/lib/mop.dart index 7874497..f333a35 100644 --- a/lib/mop.dart +++ b/lib/mop.dart @@ -1005,7 +1005,7 @@ class Mop { return ret; } - Future newInitialize(FATConfig config, {UIConfig? uiConfig}) async { + Future initSDK(FATConfig config, {UIConfig? uiConfig}) async { final Map ret = await _channel.invokeMethod('initSDK', { 'config': config.toMap(), 'uiConfig': uiConfig?.toMap(), From 48f1feb4934c6eac5a2455886350f9dc03b5f021 Mon Sep 17 00:00:00 2001 From: zhongweiguang Date: Tue, 21 Mar 2023 17:46:50 +0800 Subject: [PATCH 05/17] =?UTF-8?q?=E5=AE=8C=E5=96=84config=E5=92=8CuiConfig?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/build.gradle | 4 +- .../com/finogeeks/mop/api/ApisManager.java | 2 + .../com/finogeeks/mop/api/mop/BaseModule.java | 4 +- .../finogeeks/mop/api/mop/InitSDKModule.java | 77 ++ ios/Classes/Api/MOP_initSDK.m | 24 +- ios/Classes/Api/MOP_initialize.m | 4 +- lib/mop.dart | 729 ++++++++---------- 7 files changed, 397 insertions(+), 447 deletions(-) create mode 100644 android/src/main/java/com/finogeeks/mop/api/mop/InitSDKModule.java diff --git a/android/build.gradle b/android/build.gradle index 54f6df1..bf08398 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -91,6 +91,6 @@ kapt { } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'com.finogeeks.lib:finapplet:2.39.7' - implementation 'com.finogeeks.mop:plugins:2.39.7' + implementation 'com.finogeeks.lib:finapplet:2.39.11' + implementation 'com.finogeeks.mop:plugins:2.39.11' } \ No newline at end of file diff --git a/android/src/main/java/com/finogeeks/mop/api/ApisManager.java b/android/src/main/java/com/finogeeks/mop/api/ApisManager.java index 168793e..6e82f8b 100644 --- a/android/src/main/java/com/finogeeks/mop/api/ApisManager.java +++ b/android/src/main/java/com/finogeeks/mop/api/ApisManager.java @@ -8,6 +8,7 @@ import com.finogeeks.mop.api.mop.AppletManageModule; import com.finogeeks.mop.api.mop.AppletModule; import com.finogeeks.mop.api.mop.BaseModule; import com.finogeeks.mop.api.mop.ExtensionApiModule; +import com.finogeeks.mop.api.mop.InitSDKModule; import com.finogeeks.mop.api.mop.VersionModule; import com.finogeeks.mop.api.mop.SmSignModule; import com.finogeeks.mop.api.mop.WXQrCodeModule; @@ -65,6 +66,7 @@ public class ApisManager { } private void initSdkApi(Activity activity) { + add(new InitSDKModule(activity)); add(new BaseModule(activity)); add(new AppletModule(activity)); add(new AppletManageModule(activity)); diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/BaseModule.java b/android/src/main/java/com/finogeeks/mop/api/mop/BaseModule.java index 802b8e2..d81b892 100644 --- a/android/src/main/java/com/finogeeks/mop/api/mop/BaseModule.java +++ b/android/src/main/java/com/finogeeks/mop/api/mop/BaseModule.java @@ -4,7 +4,6 @@ import android.app.Application; import android.content.Context; import android.util.Log; -import com.finogeeks.lib.applet.BuildConfig; import com.finogeeks.lib.applet.client.FinAppClient; import com.finogeeks.lib.applet.client.FinAppConfig; import com.finogeeks.lib.applet.client.FinStoreConfig; @@ -14,7 +13,6 @@ import com.finogeeks.mop.interfaces.ICallback; import com.finogeeks.mop.service.MopPluginService; import com.finogeeks.xlog.XLogLevel; import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; import java.io.File; import java.util.ArrayList; @@ -22,7 +20,7 @@ import java.util.List; import java.util.Map; public class BaseModule extends BaseApi { - private final static String TAG = BaseModule.class.getSimpleName(); + private final static String TAG = "BaseModule"; public BaseModule(Context context) { super(context); diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/InitSDKModule.java b/android/src/main/java/com/finogeeks/mop/api/mop/InitSDKModule.java new file mode 100644 index 0000000..f04c7b8 --- /dev/null +++ b/android/src/main/java/com/finogeeks/mop/api/mop/InitSDKModule.java @@ -0,0 +1,77 @@ +package com.finogeeks.mop.api.mop; + +import android.app.Application; +import android.content.Context; +import android.util.Log; + +import com.finogeeks.lib.applet.client.FinAppClient; +import com.finogeeks.lib.applet.client.FinAppConfig; +import com.finogeeks.lib.applet.interfaces.FinCallback; +import com.finogeeks.mop.api.BaseApi; +import com.finogeeks.mop.interfaces.ICallback; +import com.finogeeks.mop.service.MopPluginService; +import com.google.gson.Gson; + +import java.util.Map; + +public class InitSDKModule extends BaseApi { + + private final static String TAG = "InitSDKModule"; + + public InitSDKModule(Context context) { + super(context); + } + + @Override + public String[] apis() { + return new String[]{"initSDK"}; + } + + @Override + public void invoke(String event, Map param, ICallback callback) { + if (FinAppClient.INSTANCE.isFinAppProcess(super.getContext())) { + // 小程序进程不执行任何初始化操作 + return; + } + + Log.d(TAG, "param:" + param); + if (param.get("config") == null) { + callback.onFail("config不能为空"); + return; + } + + Gson gson = new Gson(); + FinAppConfig config = gson.fromJson(gson.toJson(param.get("config")), FinAppConfig.class); + + FinAppConfig.UIConfig uiConfig = null; + if (param.containsKey("uiConfig")) { + uiConfig = gson.fromJson(gson.toJson(param.get("uiConfig")), FinAppConfig.UIConfig.class); + } + + +// FinAppConfig config = builder.build(); +// Log.d(TAG, "config:" + gson.toJson(config)); + + final Application application = MopPluginService.getInstance().getActivity().getApplication(); + // SDK初始化结果回调,用于接收SDK初始化状态 + FinCallback cb = new FinCallback() { + @Override + public void onSuccess(Object result) { + // SDK初始化成功 + callback.onSuccess(null); + } + + @Override + public void onError(int code, String error) { + // SDK初始化失败 + callback.onFail(null); + } + + @Override + public void onProgress(int status, String error) { + + } + }; + FinAppClient.INSTANCE.init(application, config, cb); + } +} diff --git a/ios/Classes/Api/MOP_initSDK.m b/ios/Classes/Api/MOP_initSDK.m index d1d22d7..8205f7b 100644 --- a/ios/Classes/Api/MOP_initSDK.m +++ b/ios/Classes/Api/MOP_initSDK.m @@ -17,7 +17,7 @@ return; } FATConfig *config; - NSArray *storeConfigList = self.config[@"storeConfigs"]; + NSArray *storeConfigList = self.config[@"finStoreConfigs"]; if (storeConfigList && storeConfigList.count > 0) { NSMutableArray *storeArrayM = [NSMutableArray array]; for (NSDictionary *dict in storeConfigList) { @@ -41,9 +41,9 @@ return; } - config.currentUserId = self.config[@"currentUserId"]; + config.currentUserId = self.config[@"userId"]; config.productIdentification = self.config[@"productIdentification"]; - config.disableAuthorize = [self.config[@"disableAuthorize"] boolValue]; + config.disableAuthorize = [self.config[@"disableRequestPermissions"] boolValue]; config.appletAutoAuthorize = [self.config[@"appletAutoAuthorize"] boolValue]; config.disableGetSuperviseInfo = [self.config[@"disableGetSuperviseInfo"] boolValue]; config.ignoreWebviewCertAuth = [self.config[@"ignoreWebviewCertAuth"] boolValue]; @@ -51,7 +51,7 @@ config.startCrashProtection = [self.config[@"startCrashProtection"] boolValue]; config.enableApmDataCompression = [self.config[@"enableApmDataCompression"] boolValue]; config.encryptServerData = [self.config[@"encryptServerData"] boolValue]; - config.enableAppletDebug = [self.config[@"enableAppletDebug"] integerValue]; + config.enableAppletDebug = [self.config[@"appletDebugMode"] integerValue]; config.enableWatermark = [self.config[@"enableWatermark"] boolValue]; config.watermarkPriority = [self.config[@"watermarkPriority"] integerValue]; config.baseLoadingViewClass = self.config[@"baseLoadingViewClass"]; @@ -86,7 +86,7 @@ uiconfig.navigationBarBackBtnDarkColor = [MOPTools colorWithRGBHex:[_uiConfig[@"navigationBarBackBtnDarkColor"] intValue]]; } uiconfig.moreMenuStyle = [_uiConfig[@"moreMenuStyle"] integerValue]; - uiconfig.hideBackToHomePriority = [_uiConfig[@"hideBackToHomePriority"] integerValue]; + uiconfig.hideBackToHomePriority = [_uiConfig[@"isHideBackHomePriority"] integerValue]; uiconfig.hideFeedbackMenu = [_uiConfig[@"isHideFeedbackAndComplaints"] boolValue]; uiconfig.hideBackToHome = [_uiConfig[@"isHideBackHome"] boolValue]; uiconfig.hideForwardMenu = [_uiConfig[@"isHideForwardMenu"] boolValue]; @@ -94,8 +94,8 @@ uiconfig.hideRefreshMenu = [_uiConfig[@"isHideRefreshMenu"] boolValue]; uiconfig.hideTransitionCloseButton = [_uiConfig[@"hideTransitionCloseButton"] boolValue]; uiconfig.disableSlideCloseAppletGesture = [_uiConfig[@"disableSlideCloseAppletGesture"] boolValue]; - if (_uiConfig[@"progressBarColor"]) { - uiconfig.progressBarColor = [MOPTools colorWithRGBHex:[_uiConfig[@"progressBarColor"] intValue]]; + if (_uiConfig[@"webViewProgressBarColor"]) { + uiconfig.progressBarColor = [MOPTools colorWithRGBHex:[_uiConfig[@"webViewProgressBarColor"] intValue]]; } uiconfig.hideFeedbackMenu = [_uiConfig[@"isHideFeedbackAndComplaints"] boolValue]; @@ -154,7 +154,7 @@ if (_uiConfig[@"authViewConfig"]) { NSDictionary *authViewConfigDic = _uiConfig[@"authViewConfig"]; FATAuthViewConfig *authViewConfig = [[FATAuthViewConfig alloc]init]; - authViewConfig.appletNameFont = [UIFont systemFontOfSize:[authViewConfigDic[@"appletNameFont"] integerValue]]; + authViewConfig.appletNameFont = [UIFont systemFontOfSize:[authViewConfigDic[@"appletNameTextSize"] floatValue]]; if (authViewConfigDic[@"appletNameLightColor"]) { authViewConfig.appletNameLightColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"appletNameLightColor"] intValue]]; } @@ -163,7 +163,7 @@ authViewConfig.appletNameDarkColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"appletNameDarkColor"] intValue]]; } - authViewConfig.authorizeTitleFont = [UIFont systemFontOfSize:[authViewConfigDic[@"authorizeTitleFont"] integerValue] weight:UIFontWeightMedium]; + authViewConfig.authorizeTitleFont = [UIFont systemFontOfSize:[authViewConfigDic[@"authorizeTitleTextSize"] floatValue] weight:UIFontWeightMedium]; if (authViewConfigDic[@"authorizeTitleLightColor"]) { authViewConfig.authorizeTitleLightColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"authorizeTitleLightColor"] intValue]]; @@ -173,7 +173,7 @@ authViewConfig.authorizeTitleDarkColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"authorizeTitleDarkColor"] intValue]]; } - authViewConfig.authorizeDescriptionFont = [UIFont systemFontOfSize:[authViewConfigDic[@"authorizeDescriptionFont"] integerValue]]; + authViewConfig.authorizeDescriptionFont = [UIFont systemFontOfSize:[authViewConfigDic[@"authorizeDescriptionTextSize"] floatValue]]; if (authViewConfigDic[@"authorizeDescriptionLightColor"]) { authViewConfig.authorizeDescriptionLightColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"authorizeDescriptionLightColor"] intValue]]; @@ -183,7 +183,7 @@ authViewConfig.authorizeDescriptionDarkColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"authorizeDescriptionDarkColor"] intValue]]; } - authViewConfig.agreementTitleFont = [UIFont systemFontOfSize:[authViewConfigDic[@"agreementTitleFont"] integerValue]]; + authViewConfig.agreementTitleFont = [UIFont systemFontOfSize:[authViewConfigDic[@"agreementTitleTextSize"] floatValue]]; if (authViewConfigDic[@"agreementTitleLightColor"]) { authViewConfig.agreementTitleLightColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"agreementTitleLightColor"] intValue]]; @@ -193,7 +193,7 @@ authViewConfig.agreementTitleDarkColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"agreementTitleDarkColor"] intValue]]; } - authViewConfig.agreementDescriptionFont = [UIFont systemFontOfSize:[authViewConfigDic[@"agreementDescriptionFont"] integerValue]]; + authViewConfig.agreementDescriptionFont = [UIFont systemFontOfSize:[authViewConfigDic[@"agreementDescriptionTextSize"] floatValue]]; if (authViewConfigDic[@"agreementDescriptionLightColor"]) { authViewConfig.agreementDescriptionLightColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"agreementDescriptionLightColor"] intValue]]; diff --git a/ios/Classes/Api/MOP_initialize.m b/ios/Classes/Api/MOP_initialize.m index 14a621d..fb7ba70 100644 --- a/ios/Classes/Api/MOP_initialize.m +++ b/ios/Classes/Api/MOP_initialize.m @@ -81,8 +81,8 @@ if (_uiConfig[@"navigationTitleTextAttributes"]) { uiconfig.navigationTitleTextAttributes = _uiConfig[@"navigationTitleTextAttributes"]; } - if (_uiConfig[@"progressBarColor"]) { - uiconfig.progressBarColor = [MOPTools colorWithRGBHex:[_uiConfig[@"progressBarColor"] intValue]]; + if (_uiConfig[@"webViewProgressBarColor"]) { + uiconfig.progressBarColor = [MOPTools colorWithRGBHex:[_uiConfig[@"webViewProgressBarColor"] intValue]]; } uiconfig.hideFeedbackMenu = [_uiConfig[@"isHideFeedbackAndComplaints"] boolValue]; uiconfig.hideForwardMenu = [_uiConfig[@"isHideForwardMenu"] boolValue]; diff --git a/lib/mop.dart b/lib/mop.dart index 7874497..5a63a41 100644 --- a/lib/mop.dart +++ b/lib/mop.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; @@ -12,25 +13,25 @@ typedef ExtensionApiHandler = Future> Function( typedef MopAppletHandler = Future Function(dynamic params); class FinStoreConfig { - ///创建应用时生成的SDK Key + /// 创建应用时生成的SDK Key String sdkKey; - ///创建应用时生成的SDK secret + /// 创建应用时生成的SDK secret String sdkSecret; - ///服务器地址,客户部署的后台地址 + /// 服务器地址,客户部署的后台地址 String apiServer; - ///apm统计服务器的地址,如果不填,则默认与apiServer一致 + /// apm统计服务器的地址,如果不填,则默认与apiServer一致 String apmServer; - ///网络接口加密类型,默认为MD5 国密SM + /// 网络接口加密类型,默认为MD5 国密SM String cryptType; - ///SDK指纹 证联环境(https://open.fdep.cn/) 时必填,其他环境的不用填 + /// SDK指纹 证联环境(https://open.fdep.cn/) 时必填,其他环境的不用填 String? fingerprint; - ///是否需要接口加密验证(初始化多服务器时使用)默认为不开启,当设置为YES时开启,接口返回加密数据并处理 + /// 是否需要接口加密验证(初始化多服务器时使用)默认为不开启,当设置为YES时开启,接口返回加密数据并处理 bool encryptServerData; FinStoreConfig(this.sdkKey, this.sdkSecret, this.apiServer, this.apmServer, @@ -51,168 +52,127 @@ class FinStoreConfig { } } -class FATConfig { - /** - 要初始化的服务器配置对象列表 - */ - List storeConfigs; - /** - 当前用户id,对应管理后台的用户管理->成员管理->用户id。 - 若体验版本配置了体验成员,则需要设置正确的userId才能具备打开小程序的权限 - 登录/切换用户/退出登录时,需要修改此值。 - 小程序缓存信息会存储在以userId命名的不同目录下。 - */ - String? currentUserId; +class Config { + /// 要初始化的服务器配置对象列表 + List finStoreConfigs; -/** - 产品的标识,非必传,默认为存储目录里的finclip,finogeeks和userAgent里的finogeeks - */ + /// 当前用户id,对应管理后台的用户管理->成员管理->用户id。 + /// 若体验版本配置了体验成员,则需要设置正确的userId才能具备打开小程序的权限 + /// 登录/切换用户/退出登录时,需要修改此值。 + /// 小程序缓存信息会存储在以userId命名的不同目录下。 + String? userId; + + /// 产品的标识,非必传,默认为存储目录里的finclip,finogeeks和userAgent里的finogeeks String? productIdentification; -/** -是否不让SDK申请权限 -如果设置为true,则SDK内使用权限的api,不会主动申请权限 -*/ - bool disableAuthorize = false; + /// 是否不让SDK申请权限 + /// 如果设置为true,则SDK内使用权限的api,不会主动申请权限 + bool disableRequestPermissions = false; -/** - 小程序自动申请授权 - 如果设置为true,则小程序申请权限时不会弹出用户确认提示框 - */ + /// 小程序自动申请授权 + /// 如果设置为true,则小程序申请权限时不会弹出用户确认提示框 bool appletAutoAuthorize = false; -/** - 是否禁用SDK的监管接口API(默认开启:false) - 如果设置为true,则SDK禁用监管接口API -*/ + /// 是否禁用SDK的监管接口API(默认开启:false) + /// 如果设置为true,则SDK禁用监管接口API bool disableGetSuperviseInfo = false; -/** - 是否忽略webview的证书校验,默认为false,进行校验 - 如果设置为true,则忽略校验Https的证书 -*/ + /// 是否忽略webview的证书校验,默认为false,进行校验 + /// 如果设置为true,则忽略校验Https的证书 bool ignoreWebviewCertAuth = false; -/** -后台自动检查更新的小程序个数 -初始化SDK成功后,如处于wifi网络下,更新最近使用的x个小程序 -取值范围:0~50。0代表不检查更新;不设置默认是3。 -*/ + /// 后台自动检查更新的小程序个数 + /// 初始化SDK成功后,如处于wifi网络下,更新最近使用的x个小程序 + /// 取值范围:0~50。0代表不检查更新;不设置默认是3。 int appletIntervalUpdateLimit = 3; -/** -apm 统计的扩展信息 -*/ - Map? apmExtension; + /// apm 统计的扩展信息 + Map? apmExtendInfo; -/** 是否开启Crash防崩溃,默认为false。(iOS支持) - 如果开启,可以防止如下类型的崩溃:UnrecognizedSelector、KVO、Notification、Timer、Container(数组越界,字典插入nil等)、String (越界、nil等) - 如果在开发阶段,建议关闭该属性,否则开发时不便于及时发现代码中的崩溃问题。 -*/ + /// 是否开启Crash防崩溃,默认为false。(iOS支持) + /// 如果开启,可以防止如下类型的崩溃:UnrecognizedSelector、KVO、Notification、Timer、Container(数组越界,字典插入nil等)、String (越界、nil等) + /// 如果在开发阶段,建议关闭该属性,否则开发时不便于及时发现代码中的崩溃问题。 bool startCrashProtection = false; - Map? theme; - -/** - * 数据上报时,是否压缩请求的数据 - * 默认为false - */ + /// 数据上报时,是否压缩请求的数据 + /// 默认为false bool enableApmDataCompression = false; -/** -是否需要接口加密验证(初始化单服务器时使用) -默认为不开启,当设置为YES时开启,接口返回加密数据并处理 -*/ + /// 是否需要接口加密验证(初始化单服务器时使用) + /// 默认为不开启,当设置为YES时开启,接口返回加密数据并处理 bool encryptServerData = false; -/** - 是否开启小程序的debug模式。 - 默认为FATBOOLStateUndefined,此时为旧版通过app.json 中 debug:true 开启vconsole。 - 当设置为FATBOOLStateTrue时,强制所有的小程序都会开启vconsole。 - 当设置为FATBOOLStateFalse时,非正式版会在更多菜单里显示打开和关闭调试的菜单。 - 当设置为FATBOOLStateForbidden时,所有版本强制关闭vconsole,且不可调api开启,多面板不展示打开、关闭调试菜单 - */ - FATBOOLState enableAppletDebug = FATBOOLState.FATBOOLStateUndefined; + /// 是否开启小程序的debug模式。 + /// 默认为BOOLStateUndefined,此时为旧版通过app.json 中 debug:true 开启vconsole。 + /// 当设置为BOOLStateTrue时,强制所有的小程序都会开启vconsole。 + /// 当设置为BOOLStateFalse时,非正式版会在更多菜单里显示打开和关闭调试的菜单。 + /// 当设置为BOOLStateForbidden时,所有版本强制关闭vconsole,且不可调api开启,多面板不展示打开、关闭调试菜单 + BOOLState appletDebugMode = BOOLState.BOOLStateUndefined; -/** - 是否显示水印 - */ + /// 是否显示水印 bool enableWatermark = false; -/** - 显示水印优先级设置,默认全局配置优先 - */ + /// 显示水印优先级设置,默认全局配置优先 ConfigPriority watermarkPriority = ConfigPriority.ConfigGlobalPriority; -/** - 小程序的自定义启动加载页,非必填。 - 自定义启动加载页必须继承自FATBaseLoadingView - 注意:swift中的类名带有命名空间,需要在前拼接项目文件名,如:“SwiftDemo.FCloadingView”。其中SwiftDemo是项目名,FCloadingView是类名 -*/ + /// iOS属性 + /// 小程序的自定义启动加载页,非必填。 + /// 自定义启动加载页必须继承自FATBaseLoadingView + /// 注意:swift中的类名带有命名空间,需要在前拼接项目文件名,如:“SwiftDemo.FCloadingView”。其中SwiftDemo是项目名,FCloadingView是类名 String? baseLoadingViewClass; -/** - 小程序的自定义启动失败页,非必填。 - 自定义启动失败页必须继承自FATBaseLoadFailedView - 注意:swift中的类名带有命名空间,需要在前拼接项目文件名,如:“SwiftDemo.FCloadingView”。其中SwiftDemo是项目名,FCloadingView是类名 -*/ + /// iOS属性 + /// 小程序的自定义启动失败页,非必填。 + /// 自定义启动失败页必须继承自FATBaseLoadFailedView + /// 注意:swift中的类名带有命名空间,需要在前拼接项目文件名,如:“SwiftDemo.FCloadingView”。其中SwiftDemo是项目名,FCloadingView是类名 String? baseLoadFailedViewClass; -/** - 统一设置小程序中网络请求的header。 - 注意,如果小程序调用api时也传递了相同的key,则会用小程序传递的参数覆盖。 - 对ft.request、ft.downloadFile、ft.uploadFile均会生效 - */ - Map? header; + /// 统一设置小程序中网络请求的header。 + /// 注意,如果小程序调用api时也传递了相同的key,则会用小程序传递的参数覆盖。 + /// 对ft.request、ft.downloadFile、ft.uploadFile均会生效 + Map? header; -/** - header优先级设置,默认全局配置优先 - */ + /// header优先级设置,默认全局配置优先 ConfigPriority headerPriority = ConfigPriority.ConfigGlobalPriority; -/** - 是否开启小程序中加载的H5页面hook功能,非必填。 - 如果宿主app 拦截了http 或https,会导致H5中的request 丢失body。我们SDK为了兼容这一问题,会hook request请求, - 在发起请求之前,先将body中的参数,通过代理方法传递给宿主App。宿主App可自行存储每个request的body,然后在 - 自定义的URLProtocol里发起请求之前,组装上body内容。 - */ + /// iOS属性 + /// 是否开启小程序中加载的H5页面hook功能,非必填。 + /// 如果宿主app 拦截了http 或https,会导致H5中的request 丢失body。我们SDK为了兼容这一问题,会hook request请求, + /// 在发起请求之前,先将body中的参数,通过代理方法传递给宿主App。宿主App可自行存储每个request的body,然后在 + /// 自定义的URLProtocol里发起请求之前,组装上body内容。 bool enableH5AjaxHook = false; -/** - 开启enableH5AjaxHook后,会hook request请求,会在原request 的url 后拼上一个FinClipHookBridge-RequestId=xxx的参数。 - 而该参数可设置参数名,比如您可以设置Key 为 FinClip-RequestId,这样会拼接FinClip-RequestId=xxx的参数。 - */ + /// iOS属性 + /// 开启enableH5AjaxHook后,会hook request请求,会在原request 的url 后拼上一个FinClipHookBridge-RequestId=xxx的参数。 + /// 而该参数可设置参数名,比如您可以设置Key 为 FinClip-RequestId,这样会拼接FinClip-RequestId=xxx的参数。 String? h5AjaxHookRequestKey; -/** - 小程序中页面栈的最大限制。默认值为0,标识不限制。 - 例如,设置为5,则表示页面栈中最多可有5个页面。从主页最多可再navigateTo 4 层页面。 - */ + /// 小程序中页面栈的最大限制。默认值为0,标识不限制。 + /// 例如,设置为5,则表示页面栈中最多可有5个页面。从主页最多可再navigateTo 4 层页面。 int pageCountLimit = 0; -/** - 自定义的scheme数组 - */ + /// 自定义的scheme数组 List schemes = []; - FATConfig(this.storeConfigs); + Config(this.finStoreConfigs); Map toMap() { - List>? finStoreConfigs = - storeConfigs.map((e) => e.toMap()).toList(); + List>? storeConfigs = + finStoreConfigs.map((e) => e.toMap()).toList(); return { - "storeConfigs": finStoreConfigs, - "currentUserId": currentUserId, + "finStoreConfigs": storeConfigs, + "userId": userId, "productIdentification": productIdentification, - "disableAuthorize": disableAuthorize, + "disableRequestPermissions": disableRequestPermissions, "appletAutoAuthorize": appletAutoAuthorize, "disableGetSuperviseInfo": disableGetSuperviseInfo, "ignoreWebviewCertAuth": ignoreWebviewCertAuth, "appletIntervalUpdateLimit": appletIntervalUpdateLimit, - "apmExtension": apmExtension, + "apmExtendInfo": apmExtendInfo, + "startCrashProtection": startCrashProtection, "enableApmDataCompression": enableApmDataCompression, "encryptServerData": encryptServerData, - "enableAppletDebug": enableAppletDebug.index, + "appletDebugMode": appletDebugMode.index, "enableWatermark": enableWatermark, "watermarkPriority": watermarkPriority.index, "baseLoadingViewClass": baseLoadingViewClass, @@ -220,6 +180,7 @@ apm 统计的扩展信息 "header": header, "headerPriority": headerPriority.index, "enableH5AjaxHook": enableH5AjaxHook, + "h5AjaxHookRequestKey": h5AjaxHookRequestKey, "pageCountLimit": pageCountLimit, "schemes": schemes, }; @@ -227,106 +188,112 @@ apm 统计的扩展信息 } class UIConfig { - Map? navigationTitleTextAttributes; //导航栏的标题样式,目前支持了font + // 导航栏的标题样式,目前支持了font,Android无此属性 + Map? navigationTitleTextAttributes; - //导航栏的高度(不含状态栏高度),默认值为44 + // 导航栏的高度(不含状态栏高度),默认值为44,Android无此属性 double navigationBarHeight = 44; - //导航栏的标题颜色(深色主题),默认值为白色 + // 导航栏的标题颜色(深色主题),默认值为白色 int navigationBarTitleLightColor = 0xffffffff; - //导航栏的标题颜色(明亮主题),默认值为黑色 + // 导航栏的标题颜色(明亮主题),默认值为黑色 int navigationBarTitleDarkColor = 0xff000000; - //导航栏的返回按钮颜色(深色主题),默认值为白色 + // 导航栏的返回按钮颜色(深色主题),默认值为白色 int navigationBarBackBtnLightColor = 0xffffffff; - //导航栏的返回按钮颜色(明亮主题),默认值为黑色 + // 导航栏的返回按钮颜色(明亮主题),默认值为黑色 int navigationBarBackBtnDarkColor = 0xff000000; - // int? navigationBackImage; - //弹出的菜单视图的样式 0:默认 1: + // 弹出的菜单视图的样式 0:默认 1:Normal int moreMenuStyle = 0; - //隐藏导航栏返回首页按钮的优先级设置,默认全局配置优先 不支持FATConfigAppletFilePriority - ConfigPriority hideBackToHomePriority = ConfigPriority.ConfigGlobalPriority; + /// iOS为hideBackToHomePriority + /// 隐藏导航栏返回首页按钮的优先级设置,默认全局配置优先 不支持FATConfigAppletFilePriority + ConfigPriority isHideBackHomePriority = ConfigPriority.ConfigGlobalPriority; - ///当导航栏为默认导航栏时,是否始终显示返回按钮 ios未发现该属性 + /// 当导航栏为默认导航栏时,是否始终显示返回按钮 ios未发现该属性 bool isAlwaysShowBackInDefaultNavigationBar = false; - ///是否清除导航栏导航按钮的背景 ios未发现该属性 + /// 是否清除导航栏导航按钮的背景 ios未发现该属性 bool isClearNavigationBarNavButtonBackground = false; - ///是否隐藏"更多"菜单中的"反馈与投诉"菜单入口 + /// 是否隐藏"更多"菜单中的"反馈与投诉"菜单入口 bool isHideFeedbackAndComplaints = false; - ///是否隐藏"更多"菜单中的"返回首页"菜单入口 + /// 是否隐藏"更多"菜单中的"返回首页"菜单入口 bool isHideBackHome = false; - //隐藏...弹出菜单中的 【转发】 的菜单,默认为false + // 隐藏...弹出菜单中的 【转发】 的菜单,默认为false bool isHideForwardMenu = false; - //隐藏...弹出菜单中的 【分享】 的菜单,默认为true + // 隐藏...弹出菜单中的 【分享】 的菜单,默认为true bool isHideShareAppletMenu = true; - //隐藏...弹出菜单中的 【重新进入小程序】 的菜单,默认为false + // 隐藏...弹出菜单中的 【重新进入小程序】 的菜单,默认为false bool isHideRefreshMenu = false; - //隐藏...弹出菜单中的 【设置】 的菜单,默认为false + // 隐藏...弹出菜单中的 【设置】 的菜单,默认为false bool isHideSettingMenu = false; /// 胶囊按钮配置 CapsuleConfig? capsuleConfig; - //返回首页按钮的配置 + // 返回首页按钮的配置 NavHomeConfig? navHomeConfig; FloatWindowConfig? floatWindowConfig; - //权限弹窗UI配置 + // 权限弹窗UI配置 AuthViewConfig? authViewConfig; - //iOS中独有的设置属性 - //小程序里加载H5页面时进度条的颜色 格式 0xFFFFAA00 - int? progressBarColor; + // iOS为progressBarColor,这里合并成一个 + // 小程序里加载H5页面时进度条的颜色 格式 0xFFFFAA00 + int? webViewProgressBarColor; - //隐藏小程序里加载H5时进度条,默认为false + // 隐藏小程序里加载H5时进度条,默认为false bool hideWebViewProgressBar = false; - //是否自适应暗黑模式。如果设置为true,则更多页面、关于等原生页面会随着手机切换暗黑,也自动调整为暗黑模式 - bool autoAdaptDarkMode = true; + // 是否自适应暗黑模式。如果设置为true,则更多页面、关于等原生页面会随着手机切换暗黑,也自动调整为暗黑模式 + bool autoAdaptDarkMode = false; - //要拼接的userAgent字符串 + // 要拼接的userAgent字符串 String? appendingCustomUserAgent; - /** - 打开小程序时的默认动画方式,默认为FATTranstionStyleUp。 - 该属性主要针对非api方式打开小程序时的动画缺省值。主要改变如下场景的动画方式: - 1. scheme 打开小程序; - 2. universal link 打开小程序; - 3. navigateToMiniprogram - */ + + /// Android没有这个属性,Android通过setActivityTransitionAnim方法设置 + /// + /// 打开小程序时的默认动画方式,默认为FATTranstionStyleUp。 + /// 该属性主要针对非api方式打开小程序时的动画缺省值。主要改变如下场景的动画方式: + /// 1. scheme 打开小程序; + /// 2. universal link 打开小程序; + /// 3. navigateToMiniprogram TranstionStyle transtionStyle = TranstionStyle.TranstionStyleUp; /// 加载小程序过程中(小程序Service层还未加载成功,基础库还没有向SDK传递小程序配置信息),是否隐藏导航栏的关闭按钮 bool hideTransitionCloseButton = false; - /** - 是否禁用侧滑关闭小程序的手势。默认为NO - 该手势禁用,不影响小程序里页面的侧滑返回上一页的功能 - */ + /// 是否禁用侧滑关闭小程序的手势。默认为NO + /// 该手势禁用,不影响小程序里页面的侧滑返回上一页的功能 bool disableSlideCloseAppletGesture = false; - //注入小程序统称appletText字符串,默认为“小程序”。 + // 注入小程序统称appletText字符串,默认为“小程序”。 String? appletText; + /// Android属性 + /// Loading页回调Class + String? loadingLayoutCls; + Map toMap() { return { "navigationTitleTextAttributes": navigationTitleTextAttributes, "navigationBarHeight": navigationBarHeight, - "navigationBarTitleLightColor": navigationBarTitleLightColor, - "navigationBarTitleDarkColor": navigationBarTitleDarkColor, - "navigationBarBackBtnLightColor": navigationBarBackBtnLightColor, - "navigationBarBackBtnDarkColor": navigationBarBackBtnDarkColor, + "navigationBarTitleLightColor": navigationBarTitleLightColor.toSigned(32), + "navigationBarTitleDarkColor": navigationBarTitleDarkColor.toSigned(32), + "navigationBarBackBtnLightColor": + navigationBarBackBtnLightColor.toSigned(32), + "navigationBarBackBtnDarkColor": + navigationBarBackBtnDarkColor.toSigned(32), "isAlwaysShowBackInDefaultNavigationBar": isAlwaysShowBackInDefaultNavigationBar, "isClearNavigationBarNavButtonBackground": @@ -342,15 +309,16 @@ class UIConfig { "navHomeConfig": navHomeConfig?.toMap(), "authViewConfig": authViewConfig?.toMap(), "floatWindowConfig": floatWindowConfig?.toMap(), - "progressBarColor": progressBarColor, + "webViewProgressBarColor": webViewProgressBarColor?.toSigned(32), "hideWebViewProgressBar": hideWebViewProgressBar, "moreMenuStyle": moreMenuStyle, - "hideBackToHomePriority": hideBackToHomePriority.index, + "isHideBackHomePriority": isHideBackHomePriority.index, "autoAdaptDarkMode": autoAdaptDarkMode, "appendingCustomUserAgent": appendingCustomUserAgent, "transtionStyle": transtionStyle.index, "disableSlideCloseAppletGesture": disableSlideCloseAppletGesture, - "appletText": appletText + "appletText": appletText, + "loadingLayoutCls": loadingLayoutCls, }; } } @@ -360,61 +328,58 @@ class CapsuleConfig { /// 上角胶囊视图的宽度,默认值为88 double capsuleWidth = 88; - ///上角胶囊视图的高度,默认值为32 + /// 上角胶囊视图的高度,默认值为32 double capsuleHeight = 32; - ///右上角胶囊视图的右边距 - double capsuleRightMargin = 7; + /// 右上角胶囊视图的右边距 + double capsuleRightMargin = 8; - ///右上角胶囊视图的圆角半径,默认值为5 + /// 右上角胶囊视图的圆角半径,默认值为5 double capsuleCornerRadius = 5; - ///右上角胶囊视图的边框宽度,默认值为0.8 + /// 右上角胶囊视图的边框宽度,默认值为0.8 double capsuleBorderWidth = 1; - ///胶囊背景颜色浅色 + /// 胶囊背景颜色浅色 int capsuleBgLightColor = 0x33000000; - ///胶囊背景颜色深色 + /// 胶囊背景颜色深色 int capsuleBgDarkColor = 0x80ffffff; /// 右上角胶囊视图的边框浅色颜色 - int capsuleBorderLightColor = 0x80ffffff; ///右上角胶囊视图的边框深色颜色 - int capsuleBorderDarkColor = 0x26000000; - ///胶囊分割线浅色颜色 + /// 胶囊分割线浅色颜色 int capsuleDividerLightColor = 0x80ffffff; - ///胶囊分割线深色颜色 + /// 胶囊分割线深色颜色 int capsuleDividerDarkColor = 0x26000000; - ///胶囊里的浅色更多按钮的图片对象,如果不传,会使用默认图标 + /// 胶囊里的浅色更多按钮的图片对象,如果不传,会使用默认图标 int? moreLightImage; - ///胶囊里的深色更多按钮的图片对象,如果不传,会使用默认图标 + /// 胶囊里的深色更多按钮的图片对象,如果不传,会使用默认图标 int? moreDarkImage; - ///胶囊里的更多按钮的宽度,高度与宽度相等 + /// 胶囊里的更多按钮的宽度,高度与宽度相等 double moreBtnWidth = 32; - ///胶囊里的更多按钮的左边距 + /// 胶囊里的更多按钮的左边距 double moreBtnLeftMargin = 6; - ///胶囊里的浅色更多按钮的图片对象,如果不传,会使用默认图标 - + /// 胶囊里的浅色更多按钮的图片对象,如果不传,会使用默认图标 int? closeLightImage; - ///胶囊里的深色更多按钮的图片对象,如果不传,会使用默认图标 + /// 胶囊里的深色更多按钮的图片对象,如果不传,会使用默认图标 int? closeDarkImage; - ///胶囊里的关闭按钮的宽度,高度与宽度相等 + /// 胶囊里的关闭按钮的宽度,高度与宽度相等 double closeBtnWidth = 32; - ///胶囊里的关闭按钮的左边距 + /// 胶囊里的关闭按钮的左边距 double closeBtnLeftMargin = 6; Map toMap() { @@ -424,12 +389,12 @@ class CapsuleConfig { "capsuleRightMargin": capsuleRightMargin, "capsuleCornerRadius": capsuleCornerRadius, "capsuleBorderWidth": capsuleBorderWidth, - "capsuleBgLightColor": capsuleBgLightColor, - "capsuleBgDarkColor": capsuleBgDarkColor, - "capsuleBorderLightColor": capsuleBorderLightColor, - "capsuleBorderDarkColor": capsuleBorderDarkColor, - "capsuleDividerLightColor": capsuleDividerLightColor, - "capsuleDividerDarkColor": capsuleDividerDarkColor, + "capsuleBgLightColor": capsuleBgLightColor.toSigned(32), + "capsuleBgDarkColor": capsuleBgDarkColor.toSigned(32), + "capsuleBorderLightColor": capsuleBorderLightColor.toSigned(32), + "capsuleBorderDarkColor": capsuleBorderDarkColor.toSigned(32), + "capsuleDividerLightColor": capsuleDividerLightColor.toSigned(32), + "capsuleDividerDarkColor": capsuleDividerDarkColor.toSigned(32), "moreLightImage": moreLightImage, "moreDarkImage": moreDarkImage, "moreBtnWidth": moreBtnWidth, @@ -463,54 +428,36 @@ class FloatWindowConfig { } class NavHomeConfig { - /** - 返回首页按钮的宽度 - */ + /// 返回首页按钮的宽度 double width; -/** - 返回首页按钮的高度 - */ + /// 返回首页按钮的高度 double height; -/** - 返回首页按钮的左边距,默认值为10 - */ - double leftMargin = 10; + /// 返回首页按钮的左边距,Android默认值为8,iOS默认值为10 + double leftMargin = Platform.isAndroid ? 8 : 10; -/** - 返回首页按钮的圆角半径,默认值为5 - */ + /// 返回首页按钮的圆角半径,默认值为5 double cornerRadius = 5; -/** - 返回首页按钮的边框宽度,默认值为0.8 - */ - double borderWidth = 0.8; + /// 返回首页按钮的边框宽度,Android默认值为0.75,iOS默认值为0.8 + double borderWidth = Platform.isAndroid ? 0.75 : 0.8; -/** - 返回首页按钮的边框浅色颜色 - (暗黑模式) - */ - int borderLightColor; + /// 返回首页按钮的边框浅色颜色 + /// (暗黑模式) + int borderLightColor = 0x80ffffff; -/** - 返回首页按钮的边框深色颜色 - (明亮模式) - */ - int borderDarkColor; + /// 返回首页按钮的边框深色颜色 + /// (明亮模式) + int borderDarkColor = 0x26000000; -/** - 返回首页按钮的背景浅色颜色 - (明亮模式) - */ - int bgLightColor; + /// 返回首页按钮的背景浅色颜色 + /// (明亮模式) + int bgLightColor = 0x33000000; -/** - 返回首页按钮的背景深色颜色 - (暗黑模式) - */ - int bgDarkColor; + /// 返回首页按钮的背景深色颜色 + /// (暗黑模式) + int bgDarkColor = 0x80ffffff; NavHomeConfig(this.width, this.height, this.borderLightColor, this.borderDarkColor, this.bgLightColor, this.bgDarkColor); @@ -522,169 +469,132 @@ class NavHomeConfig { "leftMargin": leftMargin, "cornerRadius": cornerRadius, "borderWidth": borderWidth, - "borderLightColor": borderLightColor, - "borderDarkColor": borderDarkColor, - "bgLightColor": bgLightColor, - "bgDarkColor": bgDarkColor, + "borderLightColor": borderLightColor.toSigned(32), + "borderDarkColor": borderDarkColor.toSigned(32), + "bgLightColor": bgLightColor.toSigned(32), + "bgDarkColor": bgDarkColor.toSigned(32), }; } } class AuthViewConfig { -/** - 小程序名称字体大小,默认字体为PingFangSC-Regular,默认大小16 - */ - int appletNameFont = 16; + /// 小程序名称字体大小,默认字体为PingFangSC-Regular,默认大小16 + double appletNameTextSize = 16; -/** - 小程序名称的浅色颜色(明亮模式),默认#202020 - */ - int appletNameLightColor = 0xff202020; + /// 小程序名称的浅色颜色(明亮模式),默认#222222 + int appletNameLightColor = 0xff222222; -/** - 小程序名称的深色颜色(暗黑模式),默认#D0D0D0 - */ + /// 小程序名称的深色颜色(暗黑模式),默认#D0D0D0 int appletNameDarkColor = 0xffd0d0d0; -/** - 权限标题字体大小,默认字体为PingFangSC-Medium,默认大小17 - 备注:权限选项文字字体大小使用该配置项,但字体固定为PingFangSC-Regular - */ - int authorizeTitleFont = 17; + /// 权限标题字体大小,默认字体为PingFangSC-Medium,默认大小17 + /// 备注:权限选项文字字体大小使用该配置项,但字体固定为PingFangSC-Regular + double authorizeTitleTextSize = 17; -/** - 权限标题的浅色颜色(明亮模式),默认#202020 - 备注:权限选项文字字体颜色使用该配置项 - */ - int authorizeTitleLightColor = 0xff202020; + /// 权限标题的浅色颜色(明亮模式),默认#222222 + /// 备注:权限选项文字字体颜色使用该配置项 + int authorizeTitleLightColor = 0xff222222; -/** - 权限标题的深色颜色(暗黑模式),默认#D0D0D0 - 备注:权限选项文字字体颜色使用该配置项 - */ + /// 权限标题的深色颜色(暗黑模式),默认#D0D0D0 + /// 备注:权限选项文字字体颜色使用该配置项 int authorizeTitleDarkColor = 0xffd0d0d0; -/** - 权限描述字体大小,默认字体为PingFangSC-Regular,默认大小14 - */ - int authorizeDescriptionFont = 14; + /// 权限描述字体大小,默认字体为PingFangSC-Regular,默认大小14 + double authorizeDescriptionTextSize = 14; -/** - 权限描述的浅色颜色(明亮模式),默认#666666 - */ + /// 权限描述的浅色颜色(明亮模式),默认#666666 int authorizeDescriptionLightColor = 0xff666666; -/** - 权限描述的深色颜色(暗黑模式),默认#8C8C8C - */ - int authorizeDescriptionDarkColor = 0xff8c8c8c; + /// 权限描述的深色颜色(暗黑模式),默认#5c5c5c + int authorizeDescriptionDarkColor = 0xff5c5c5c; -/** - 协议标题字体大小,默认字体为PingFangSC-Regular,默认大小16 - */ - int agreementTitleFont = 16; + /// 协议标题字体大小,默认字体为PingFangSC-Regular,默认大小16 + double agreementTitleTextSize = 16; -/** - 协议标题的浅色颜色(明亮模式),默认#202020 - */ - int agreementTitleLightColor = 0xff202020; + /// 协议标题的浅色颜色(明亮模式),默认#222222 + int agreementTitleLightColor = 0xff222222; -/** - 协议标题的深色颜色(暗黑模式),默认#D0D0D0 - */ + /// 协议标题的深色颜色(暗黑模式),默认#D0D0D0 int agreementTitleDarkColor = 0xffd0d0d0; -/** - 协议描述字体大小,默认字体为PingFangSC-Regular,默认大小14 - */ - int agreementDescriptionFont = 14; + /// 协议描述字体大小,默认字体为PingFangSC-Regular,默认大小14 + double agreementDescriptionTextSize = 14; -/** - 协议描述的浅色颜色(明亮模式),默认#202020 - */ - int agreementDescriptionLightColor = 0xff202020; + /// 协议描述的浅色颜色(明亮模式),默认#222222 + int agreementDescriptionLightColor = 0xff222222; -/** - 协议描述的深色颜色(暗黑模式),默认#D0D0D0 - */ + /// 协议描述的深色颜色(暗黑模式),默认#D0D0D0 int agreementDescriptionDarkColor = 0xffd0d0d0; -/** - 链接的浅色颜色(明亮模式),默认#409EFF - */ - int linkLightColor = 0xff409eff; + /// 链接的浅色颜色(明亮模式),默认#4285f4 + int linkLightColor = 0xff4285f4; -/** - 链接的深色颜色(暗黑模式),默认#368CE4 - */ - int linkDarkColor = 0xff368ce4; + /// 链接的深色颜色(暗黑模式),默认#4285f4 + int linkDarkColor = 0xff4285f4; -/** - 同意按钮配置(明亮模式),默认配置如下: - 圆角:4 - 默认背景色:#4285F4 - 默认描边:#4285F4 - 默认文字颜色:#FFFFFF - 按下背景色:#3B77DB - 按下默认描边:#3B77DB - 按下文字颜色:#FFFFFF - */ + /// 同意按钮配置(明亮模式),默认配置如下: + /// 圆角:4 + /// 默认背景色:#4285F4 + /// 默认描边:#4285F4 + /// 默认文字颜色:#FFFFFF + /// 按下背景色:#3B77DB + /// 按下默认描边:#3B77DB + /// 按下文字颜色:#FFFFFF AuthButtonConfig? allowButtonLightConfig; -/** - 同意按钮配置(暗黑模式),默认配置如下: - 圆角:4 - 默认背景色:#4285F4 - 默认描边:#4285F4 - 默认文字颜色:#FFFFFF - 按下背景色:#5E97F5 - 按下默认描边:#5E97F5 - 按下文字颜色:#FFFFFF - */ + /// 同意按钮配置(暗黑模式),默认配置如下: + /// 圆角:4 + /// 默认背景色:#4285F4 + /// 默认描边:#4285F4 + /// 默认文字颜色:#FFFFFF + /// 按下背景色:#5E97F5 + /// 按下默认描边:#5E97F5 + /// 按下文字颜色:#FFFFFF AuthButtonConfig? allowButtonDarkConfig; -/** - 拒绝按钮配置(明亮模式),默认配置如下: - 圆角:4 - 默认背景色:#FFFFFF - 默认描边:#E2E2E2 - 默认文字颜色:#222222 - 按下背景色:#D8D8D8 - 按下默认描边:#D8D8D8 - 按下文字颜色:#222222 - */ + /// 拒绝按钮配置(明亮模式),默认配置如下: + /// 圆角:4 + /// 默认背景色:#FFFFFF + /// 默认描边:#E2E2E2 + /// 默认文字颜色:#222222 + /// 按下背景色:#D8D8D8 + /// 按下默认描边:#D8D8D8 + /// 按下文字颜色:#222222 AuthButtonConfig? rejectButtonLightConfig; -/** - 拒绝按钮配置(暗黑模式),默认配置如下: - 圆角:4 - 默认背景色:#2C2C2C - 默认描边:#2C2C2C - 默认文字颜色:#D0D0D0 - 按下背景色:#414141 - 按下默认描边:#414141 - 按下文字颜色:#D0D0D0 - */ + /// 拒绝按钮配置(暗黑模式),默认配置如下: + /// 圆角:4 + /// 默认背景色:#2C2C2C + /// 默认描边:#2C2C2C + /// 默认文字颜色:#D0D0D0 + /// 按下背景色:#414141 + /// 按下默认描边:#414141 + /// 按下文字颜色:#D0D0D0 AuthButtonConfig? rejectButtonDarkConfig; Map toMap() { return { - "appletNameFont": appletNameFont, - "appletNameLightColor": appletNameLightColor, - "appletNameDarkColor": appletNameDarkColor, - "authorizeTitleFont": authorizeTitleFont, - "authorizeTitleLightColor": authorizeTitleLightColor, - "authorizeTitleDarkColor": authorizeTitleDarkColor, - "authorizeDescriptionFont": authorizeDescriptionFont, - "authorizeDescriptionLightColor": authorizeDescriptionLightColor, - "authorizeDescriptionDarkColor": authorizeDescriptionDarkColor, - "agreementTitleFont": agreementTitleFont, - "agreementTitleLightColor": agreementTitleLightColor, - "agreementTitleDarkColor": agreementTitleDarkColor, - "agreementDescriptionFont": agreementDescriptionFont, - "agreementDescriptionDarkColor": agreementDescriptionDarkColor, - "linkLightColor": linkLightColor, - "linkDarkColor": linkDarkColor, + "appletNameTextSize": appletNameTextSize, + "appletNameLightColor": appletNameLightColor.toSigned(32), + "appletNameDarkColor": appletNameDarkColor.toSigned(32), + "authorizeTitleTextSize": authorizeTitleTextSize, + "authorizeTitleLightColor": authorizeTitleLightColor.toSigned(32), + "authorizeTitleDarkColor": authorizeTitleDarkColor.toSigned(32), + "authorizeDescriptionTextSize": authorizeDescriptionTextSize, + "authorizeDescriptionLightColor": + authorizeDescriptionLightColor.toSigned(32), + "authorizeDescriptionDarkColor": + authorizeDescriptionDarkColor.toSigned(32), + "agreementTitleTextSize": agreementTitleTextSize, + "agreementTitleLightColor": agreementTitleLightColor.toSigned(32), + "agreementTitleDarkColor": agreementTitleDarkColor.toSigned(32), + "agreementDescriptionTextSize": agreementDescriptionTextSize, + "agreementDescriptionLightColor": + agreementDescriptionLightColor.toSigned(32), + "agreementDescriptionDarkColor": + agreementDescriptionDarkColor.toSigned(32), + "linkLightColor": linkLightColor.toSigned(32), + "linkDarkColor": linkDarkColor.toSigned(32), "allowButtonLightConfig": allowButtonLightConfig?.toMap(), "allowButtonDarkConfig": allowButtonDarkConfig?.toMap(), "rejectButtonLightConfig": rejectButtonLightConfig?.toMap(), @@ -694,39 +604,25 @@ class AuthViewConfig { } class AuthButtonConfig { - /** - 按钮的圆角半径 - */ + /// 按钮的圆角半径 double cornerRadius; -/** - 按钮默认背景颜色 - */ + /// 按钮默认背景颜色 int normalBackgroundColor; -/** - 按钮按下背景颜色 - */ + /// 按钮按下背景颜色 int pressedBackgroundColor; -/** - 按钮默认文字颜色 - */ + /// 按钮默认文字颜色 int normalTextColor; -/** - 按钮按下文字颜色 - */ + /// 按钮按下文字颜色 int pressedTextColor; -/** - 按钮默认边框颜色 - */ + /// 按钮默认边框颜色 int normalBorderColor; -/** - 按钮按下边框颜色 - */ + /// 按钮按下边框颜色 int pressedBorderColor; AuthButtonConfig( @@ -741,12 +637,12 @@ class AuthButtonConfig { Map toMap() { return { "cornerRadius": cornerRadius, - "normalBackgroundColor": normalBackgroundColor, - "pressedBackgroundColor": pressedBackgroundColor, - "normalTextColor": normalTextColor, - "pressedTextColor": pressedTextColor, - "normalBorderColor": normalBorderColor, - "pressedBorderColor": pressedBorderColor + "normalBackgroundColor": normalBackgroundColor.toSigned(32), + "pressedBackgroundColor": pressedBackgroundColor.toSigned(32), + "normalTextColor": normalTextColor.toSigned(32), + "pressedTextColor": pressedTextColor.toSigned(32), + "normalBorderColor": normalBorderColor.toSigned(32), + "pressedBorderColor": pressedBorderColor.toSigned(32) }; } } @@ -754,12 +650,16 @@ class AuthButtonConfig { class BaseAppletRequest { // 服务器地址,必填 String apiServer; + // 小程序id,必填 String appletId; + // 小程序的启动参数,非必填 Map? startParams; + // iOS端打开小程序时是否显示动画,默认为true。 bool? animated; + // 是否以单进程模式运行,仅限android,默认为false bool isSingleProcess; @@ -785,19 +685,26 @@ class BaseAppletRequest { class RemoteAppletRequest { // 服务器地址,必填 String apiServer; + // 小程序id,必填 String appletId; + // 小程序的启动参数,非必填 Map? startParams; + // 小程序的索引,(审核小程序时必填) int? sequence; + // 离线小程序压缩包路径,非必填 String? offlineMiniprogramZipPath; + // 离线基础库压缩包路径,非必填 String? offlineFrameworkZipPath; + // iOS端打开小程序时是否显示动画,默认为true。 bool animated; -// 是否以单进程模式运行,仅限android,默认为false + + // 是否以单进程模式运行,仅限android,默认为false bool isSingleProcess; RemoteAppletRequest({ @@ -833,8 +740,10 @@ class RemoteAppletRequest { class QRCodeAppletRequest { // 二维码内容 String qrCode; + // 是否显示打开动画 bool animated = true; + // 是否以单进程模式运行,仅限android,默认为false bool isSingleProcess; @@ -869,12 +778,11 @@ enum TranstionStyle { TranstionStylePush, // 页面从右往左弹出,类似push效果 } -enum FATBOOLState { - FATBOOLStateUndefined, // 未设置 - FATBOOLStateTrue, // 所有版本强制开启vconsole,且不可调api关闭,更多面板不展示打开、关闭调试菜单 - FATBOOLStateFalse, // 正式版更多面板不展示打开、关闭调试菜单;非正式版更多面板展示打开、关闭调试菜单;所有版本均可调setEnableDebug开启vconsole。 - FATBOOLStateForbidden, // 所有版本强制关闭vconsole,且不可调api开启,多面板不展示打开、关闭调试菜单 - +enum BOOLState { + BOOLStateUndefined, // 未设置 + BOOLStateTrue, // 所有版本强制开启vconsole,且不可调api关闭,更多面板不展示打开、关闭调试菜单 + BOOLStateFalse, // 正式版更多面板不展示打开、关闭调试菜单;非正式版更多面板展示打开、关闭调试菜单;所有版本均可调setEnableDebug开启vconsole。 + BOOLStateForbidden, // 所有版本强制关闭vconsole,且不可调api开启,多面板不展示打开、关闭调试菜单 } class Mop { @@ -943,8 +851,6 @@ class Mop { } } - /// - /// /// initialize mop miniprogram engine. /// 初始化小程序 /// [sdkkey] is required. it can be getted from api.finclip.com @@ -962,7 +868,6 @@ class Mop { /// [customWebViewUserAgent] 设置自定义webview ua /// [appletIntervalUpdateLimit] 设置小程序批量更新周期 /// [maxRunningApplet] 设置最大同时运行小程序个数 - /// Future initialize( String sdkkey, String secret, { @@ -1005,7 +910,7 @@ class Mop { return ret; } - Future newInitialize(FATConfig config, {UIConfig? uiConfig}) async { + Future initSDK(Config config, {UIConfig? uiConfig}) async { final Map ret = await _channel.invokeMethod('initSDK', { 'config': config.toMap(), 'uiConfig': uiConfig?.toMap(), @@ -1051,12 +956,9 @@ class Mop { return ret; } - /// - /// get current using applet - /// 获取当前正在使用的小程序信息 - /// {appId,name,icon,description,version,thumbnail} - /// - /// + /// get current using applet + /// 获取当前正在使用的小程序信息 + /// {appId,name,icon,description,version,thumbnail} Future> currentApplet() async { final ret = await _channel.invokeMapMethod("currentApplet"); return Map.from(ret!); @@ -1068,18 +970,14 @@ class Mop { return Map.from(ret!); } - /// /// close all running applets /// 关闭当前打开的所有小程序 - /// Future closeAllApplets() async { return await _channel.invokeMethod("closeAllApplets"); } - /// /// clear applets cache /// 清除缓存的小程序 - /// Future clearApplets() async { return await _channel.invokeMethod("clearApplets"); } @@ -1096,18 +994,14 @@ class Mop { return await _channel.invokeMethod("removeAllUsedApplets", params); } - /// /// 获取运行时版本号 - /// Future sdkVersion() async { return await _channel .invokeMapMethod("sdkVersion") .then((value) => value?["data"]); } - /// /// (扫码后)解密-鉴权-打开小程序 - /// Future scanOpenApplet(String info, {bool isSingleProcess = false}) async { Map params = { 'info': info, @@ -1116,10 +1010,8 @@ class Mop { return await _channel.invokeMapMethod("scanOpenApplet", params); } - /// /// 通过二维码打开小程序 /// [qrcode] 二维码内容 - /// Future qrcodeOpenApplet(String qrcode, {bool isSingleProcess = false}) async { Map params = { 'qrcode': qrcode, @@ -1128,9 +1020,7 @@ class Mop { return await _channel.invokeMapMethod("qrcodeOpenApplet", params); } - /// /// 根据微信QrCode信息解析小程序信息 - /// Future> parseAppletInfoFromWXQrCode( String qrCode, String apiServer) async { final ret = await _channel.invokeMapMethod("parseAppletInfoFromWXQrCode", @@ -1138,10 +1028,8 @@ class Mop { return Map.from(ret!); } - /// /// register handler to provide custom info or behaviour /// 注册小程序事件处理 - /// void registerAppletHandler(AppletHandler handler) { _appletHandlerApis["forwardApplet"] = (params) async { handler.forwardApplet(Map.from(params)); @@ -1181,10 +1069,8 @@ class Mop { _channel.invokeMethod("registerAppletHandler"); } - /// /// register extension api /// 注册拓展api - /// void registerExtensionApi(String name, ExtensionApiHandler handler) { _extensionApis[name] = handler; _channel.invokeMethod("registerExtensionApi", {"name": name}); @@ -1205,33 +1091,26 @@ class Mop { return; } - /// /// 关闭小程序 小程序会在内存中存在 - /// Future closeApplet(String appletId, bool animated) async { await _channel.invokeMethod( "closeApplet", {"appletId": appletId, "animated": animated}); return; } - /// /// 结束小程序 小程序会从内存中清除 - /// Future finishRunningApplet(String appletId, bool animated) async { await _channel.invokeMethod( "finishRunningApplet", {"appletId": appletId, "animated": animated}); return; } - /// /// 设置小程序切换动画 安卓 - /// Future setActivityTransitionAnim(Anim anim) async { await _channel.invokeMethod("setActivityTransitionAnim", {"anim": ""}); return; } - /// /// 原生发送事件给小程序 /// [appId] 小程序id /// [eventData] 事件对象 @@ -1242,13 +1121,11 @@ class Mop { return; } - /// /// 原生调用webview中的js方法 /// [appId] 小程序id /// [eventName] 方法名 /// [nativeViewId] webviewId /// [eventData] 参数 - /// Future callJS(String appId, String eventName, String nativeViewId, Map eventData) async { await _channel.invokeMethod("callJS", { @@ -1260,18 +1137,14 @@ class Mop { return; } - /// /// register webview extension api /// 注册webview拓展api - /// void addWebExtentionApi(String name, ExtensionApiHandler handler) { _webExtensionApis[name] = handler; _channel.invokeMethod("addWebExtentionApi", {"name": name}); } - /// /// 将当前正在运行的最后一个打开的小程序移至任务栈前台 - /// void moveCurrentAppletToFront() async { return await _channel.invokeMethod("moveCurrentAppletToFront"); } From 509f33bd464f6df64ea3bd601a0f42243edb35ed Mon Sep 17 00:00:00 2001 From: zhongweiguang Date: Wed, 22 Mar 2023 14:51:07 +0800 Subject: [PATCH 06/17] =?UTF-8?q?initSDK=20Android=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E5=A4=84=E7=90=86=E6=96=B9=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../finogeeks/mop/api/mop/InitSDKModule.java | 254 +++++++++++++++++- lib/mop.dart | 9 +- 2 files changed, 247 insertions(+), 16 deletions(-) diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/InitSDKModule.java b/android/src/main/java/com/finogeeks/mop/api/mop/InitSDKModule.java index f04c7b8..26dbfc3 100644 --- a/android/src/main/java/com/finogeeks/mop/api/mop/InitSDKModule.java +++ b/android/src/main/java/com/finogeeks/mop/api/mop/InitSDKModule.java @@ -6,12 +6,16 @@ import android.util.Log; import com.finogeeks.lib.applet.client.FinAppClient; import com.finogeeks.lib.applet.client.FinAppConfig; +import com.finogeeks.lib.applet.client.FinAppConfigPriority; +import com.finogeeks.lib.applet.client.FinStoreConfig; import com.finogeeks.lib.applet.interfaces.FinCallback; import com.finogeeks.mop.api.BaseApi; import com.finogeeks.mop.interfaces.ICallback; import com.finogeeks.mop.service.MopPluginService; import com.google.gson.Gson; +import java.util.ArrayList; +import java.util.List; import java.util.Map; public class InitSDKModule extends BaseApi { @@ -28,6 +32,7 @@ public class InitSDKModule extends BaseApi { } @Override + @SuppressWarnings("unchecked") public void invoke(String event, Map param, ICallback callback) { if (FinAppClient.INSTANCE.isFinAppProcess(super.getContext())) { // 小程序进程不执行任何初始化操作 @@ -35,22 +40,235 @@ public class InitSDKModule extends BaseApi { } Log.d(TAG, "param:" + param); - if (param.get("config") == null) { - callback.onFail("config不能为空"); - return; + FinAppConfig.Builder configBuilder = new FinAppConfig.Builder(); + + // config + Map configMap = (Map) param.get("config"); + List> finStoreConfigs = (List>) configMap.get("finStoreConfigs"); + List storeConfigs = new ArrayList<>(); + for (Map store : finStoreConfigs) { + String sdkKey = (String) store.get("sdkKey"); + String sdkSecret = (String) store.get("sdkSecret"); + String apiServer = (String) store.get("apiServer"); + String apmServer = (String) store.get("apmServer"); + if (apmServer == null) { + apmServer = ""; + } + String fingerprint = (String) store.get("fingerprint"); + if (fingerprint == null) { + fingerprint = ""; + } + String cryptType = (String) store.get("cryptType"); + Boolean encryptServerData = (Boolean) store.get("encryptServerData"); + storeConfigs.add(new FinStoreConfig(sdkKey, sdkSecret, apiServer, apmServer, "", + fingerprint, cryptType, encryptServerData)); + } + configBuilder.setFinStoreConfigs(storeConfigs); + String userId = (String) configMap.get("userId"); + if (userId != null) { + configBuilder.setUserId(userId); + } + String productIdentification = (String) configMap.get("productIdentification"); + if (productIdentification != null) { + configBuilder.setProductIdentification(productIdentification); + } + configBuilder.setDisableRequestPermissions((Boolean) configMap.get("disableRequestPermissions")); + configBuilder.setAppletAutoAuthorize((Boolean) configMap.get("appletAutoAuthorize")); + configBuilder.setDisableGetSuperviseInfo((Boolean) configMap.get("disableGetSuperviseInfo")); + configBuilder.setIgnoreWebviewCertAuth((Boolean) configMap.get("ignoreWebviewCertAuth")); + configBuilder.setAppletIntervalUpdateLimit((Integer) configMap.get("appletIntervalUpdateLimit")); + Map apmExtendInfo = (Map) configMap.get("apmExtendInfo"); + if (apmExtendInfo != null) { + configBuilder.setApmExtendInfo(apmExtendInfo); + } + configBuilder.setEnableApmDataCompression((Boolean) configMap.get("enableApmDataCompression")); + configBuilder.setEncryptServerData((Boolean) configMap.get("encryptServerData")); + configBuilder.setEncryptServerData((Boolean) configMap.get("encryptServerData")); + int appletDebugModeIndex = (Integer) configMap.get("appletDebugMode"); + if (appletDebugModeIndex == 0) { + configBuilder.setAppletDebugMode(FinAppConfig.AppletDebugMode.appletDebugModeUndefined); + } else if (appletDebugModeIndex == 1) { + configBuilder.setAppletDebugMode(FinAppConfig.AppletDebugMode.appletDebugModeEnable); + } else if (appletDebugModeIndex == 2) { + configBuilder.setAppletDebugMode(FinAppConfig.AppletDebugMode.appletDebugModeDisable); + } else if (appletDebugModeIndex == 3) { + configBuilder.setAppletDebugMode(FinAppConfig.AppletDebugMode.appletDebugModeForbidden); + } + configBuilder.setEnableWatermark((Boolean) configMap.get("enableWatermark")); + int watermarkPriorityIndex = (Integer) configMap.get("watermarkPriority"); + if (watermarkPriorityIndex == 0) { + configBuilder.setWatermarkPriority(FinAppConfigPriority.GLOBAL); + } else if (watermarkPriorityIndex == 1) { + configBuilder.setWatermarkPriority(FinAppConfigPriority.SPECIFIED); + } else if (watermarkPriorityIndex == 2) { + configBuilder.setWatermarkPriority(FinAppConfigPriority.APPLET_FILE); + } + Map header = (Map) configMap.get("header"); + if (header != null) { + configBuilder.setHeader(header); + } + int headerPriorityIndex = (Integer) configMap.get("headerPriority"); + if (headerPriorityIndex == 0) { + configBuilder.setHeaderPriority(FinAppConfigPriority.GLOBAL); + } else if (headerPriorityIndex == 1) { + configBuilder.setHeaderPriority(FinAppConfigPriority.SPECIFIED); + } else if (headerPriorityIndex == 2) { + configBuilder.setHeaderPriority(FinAppConfigPriority.APPLET_FILE); + } + configBuilder.setPageCountLimit((Integer) configMap.get("pageCountLimit")); + String[] schemes = (String[]) configMap.get("schemes"); + if (schemes != null) { + configBuilder.setSchemes(schemes); } - Gson gson = new Gson(); - FinAppConfig config = gson.fromJson(gson.toJson(param.get("config")), FinAppConfig.class); + // uiConfig + Map uiConfigMap = (Map) param.get("uiConfig"); + if (uiConfigMap != null) { + FinAppConfig.UIConfig uiConfig = new FinAppConfig.UIConfig(); + uiConfig.setNavigationBarTitleLightColor((Integer) uiConfigMap.get("navigationBarTitleLightColor")); + uiConfig.setNavigationBarTitleDarkColor((Integer) uiConfigMap.get("navigationBarTitleDarkColor")); + uiConfig.setNavigationBarBackBtnLightColor((Integer) uiConfigMap.get("navigationBarBackBtnLightColor")); + uiConfig.setAlwaysShowBackInDefaultNavigationBar((Boolean) uiConfigMap.get("isAlwaysShowBackInDefaultNavigationBar")); + uiConfig.setClearNavigationBarNavButtonBackground((Boolean) uiConfigMap.get("isClearNavigationBarNavButtonBackground")); + uiConfig.setHideFeedbackAndComplaints((Boolean) uiConfigMap.get("isHideFeedbackAndComplaints")); + uiConfig.setHideBackHome((Boolean) uiConfigMap.get("isHideBackHome")); + uiConfig.setHideForwardMenu((Boolean) uiConfigMap.get("isHideForwardMenu")); + uiConfig.setHideRefreshMenu((Boolean) uiConfigMap.get("isHideRefreshMenu")); + uiConfig.setHideShareAppletMenu((Boolean) uiConfigMap.get("isHideShareAppletMenu")); + uiConfig.setHideSettingMenu((Boolean) uiConfigMap.get("isHideSettingMenu")); + uiConfig.setHideTransitionCloseButton((Boolean) uiConfigMap.get("hideTransitionCloseButton")); + Map capsuleConfigMap = (Map) uiConfigMap.get("capsuleConfig"); + if (capsuleConfigMap != null) { + FinAppConfig.UIConfig.CapsuleConfig capsuleConfig = new FinAppConfig.UIConfig.CapsuleConfig(); + capsuleConfig.capsuleWidth = (float) capsuleConfigMap.get("capsuleWidth"); + capsuleConfig.capsuleHeight = (float) capsuleConfigMap.get("capsuleHeight"); + capsuleConfig.capsuleRightMargin = (float) capsuleConfigMap.get("capsuleRightMargin"); + capsuleConfig.capsuleCornerRadius = (float) capsuleConfigMap.get("capsuleCornerRadius"); + capsuleConfig.capsuleBorderWidth = (float) capsuleConfigMap.get("capsuleBorderWidth"); + capsuleConfig.capsuleBgLightColor = (int) capsuleConfigMap.get("capsuleBgLightColor"); + capsuleConfig.capsuleBgDarkColor = (int) capsuleConfigMap.get("capsuleBgDarkColor"); + capsuleConfig.capsuleBorderLightColor = (int) capsuleConfigMap.get("capsuleBorderLightColor"); + capsuleConfig.capsuleBorderDarkColor = (int) capsuleConfigMap.get("capsuleBorderDarkColor"); + capsuleConfig.capsuleDividerLightColor = (int) capsuleConfigMap.get("capsuleDividerLightColor"); + capsuleConfig.capsuleDividerDarkColor = (int) capsuleConfigMap.get("capsuleDividerDarkColor"); + Integer moreLightImage = (Integer) capsuleConfigMap.get("moreLightImage"); + if (moreLightImage != null) { + capsuleConfig.moreLightImage = moreLightImage; + } + Integer moreDarkImage = (Integer) capsuleConfigMap.get("moreDarkImage"); + if (moreDarkImage != null) { + capsuleConfig.moreDarkImage = moreDarkImage; + } + capsuleConfig.moreBtnWidth = (float) capsuleConfigMap.get("moreBtnWidth"); + capsuleConfig.moreBtnLeftMargin = (float) capsuleConfigMap.get("moreBtnLeftMargin"); + Integer closeLightImage = (Integer) capsuleConfigMap.get("closeLightImage"); + if (closeLightImage != null) { + capsuleConfig.closeLightImage = closeLightImage; + } + Integer closeDarkImage = (Integer) capsuleConfigMap.get("closeDarkImage"); + if (closeDarkImage != null) { + capsuleConfig.closeDarkImage = closeDarkImage; + } + capsuleConfig.closeBtnWidth = (float) capsuleConfigMap.get("closeBtnWidth"); + capsuleConfig.closeBtnLeftMargin = (float) capsuleConfigMap.get("closeBtnLeftMargin"); + uiConfig.setCapsuleConfig(capsuleConfig); + } + Map navHomeConfigMap = (Map) uiConfigMap.get("navHomeConfig"); + if (navHomeConfigMap != null) { + FinAppConfig.UIConfig.NavHomeConfig navHomeConfig = new FinAppConfig.UIConfig.NavHomeConfig(); + navHomeConfig.width = (float) navHomeConfigMap.get("width"); + navHomeConfig.height = (float) navHomeConfigMap.get("height"); + navHomeConfig.leftMargin = (float) navHomeConfigMap.get("leftMargin"); + navHomeConfig.cornerRadius = (float) navHomeConfigMap.get("cornerRadius"); + navHomeConfig.borderWidth = (float) navHomeConfigMap.get("borderWidth"); + navHomeConfig.borderLightColor = (int) navHomeConfigMap.get("borderLightColor"); + navHomeConfig.borderDarkColor = (int) navHomeConfigMap.get("borderDarkColor"); + navHomeConfig.bgLightColor = (int) navHomeConfigMap.get("bgLightColor"); + navHomeConfig.bgDarkColor = (int) navHomeConfigMap.get("bgDarkColor"); + uiConfig.setNavHomeConfig(navHomeConfig); + } + Map authViewConfigMap = (Map) uiConfigMap.get("authViewConfig"); + if (authViewConfigMap != null) { + FinAppConfig.UIConfig.AuthViewConfig authViewConfig = new FinAppConfig.UIConfig.AuthViewConfig(); + authViewConfig.appletNameTextSize = (float) authViewConfigMap.get("appletNameTextSize"); + authViewConfig.appletNameLightColor = (int) authViewConfigMap.get("appletNameLightColor"); + authViewConfig.appletNameDarkColor = (int) authViewConfigMap.get("appletNameDarkColor"); + authViewConfig.authorizeTitleTextSize = (float) authViewConfigMap.get("authorizeTitleTextSize"); + authViewConfig.authorizeTitleLightColor = (int) authViewConfigMap.get("authorizeTitleLightColor"); + authViewConfig.authorizeTitleDarkColor = (int) authViewConfigMap.get("authorizeTitleDarkColor"); + authViewConfig.authorizeDescriptionTextSize = (float) authViewConfigMap.get("authorizeDescriptionTextSize"); + authViewConfig.authorizeDescriptionLightColor = (int) authViewConfigMap.get("authorizeDescriptionLightColor"); + authViewConfig.authorizeDescriptionDarkColor = (int) authViewConfigMap.get("authorizeDescriptionDarkColor"); + authViewConfig.agreementTitleTextSize = (float) authViewConfigMap.get("agreementTitleTextSize"); + authViewConfig.agreementTitleLightColor = (int) authViewConfigMap.get("agreementTitleLightColor"); + authViewConfig.agreementTitleDarkColor = (int) authViewConfigMap.get("agreementTitleDarkColor"); + authViewConfig.agreementDescriptionTextSize = (float) authViewConfigMap.get("agreementDescriptionTextSize"); + authViewConfig.agreementDescriptionLightColor = (int) authViewConfigMap.get("agreementDescriptionLightColor"); + authViewConfig.agreementDescriptionDarkColor = (int) authViewConfigMap.get("agreementDescriptionDarkColor"); + authViewConfig.linkLightColor = (int) authViewConfigMap.get("linkLightColor"); + authViewConfig.linkDarkColor = (int) authViewConfigMap.get("linkDarkColor"); + Map allowButtonLightConfig = (Map) authViewConfigMap.get("allowButtonLightConfig"); + if (allowButtonLightConfig != null) { + authViewConfig.allowButtonLightConfig = getAuthButtonConfig(allowButtonLightConfig); + } + Map allowButtonDarkConfig = (Map) authViewConfigMap.get("allowButtonDarkConfig"); + if (allowButtonDarkConfig != null) { + authViewConfig.allowButtonDarkConfig = getAuthButtonConfig(allowButtonDarkConfig); + } + Map rejectButtonLightConfig = (Map) authViewConfigMap.get("rejectButtonLightConfig"); + if (rejectButtonLightConfig != null) { + authViewConfig.rejectButtonLightConfig = getAuthButtonConfig(rejectButtonLightConfig); + } + Map rejectButtonDarkConfig = (Map) authViewConfigMap.get("rejectButtonDarkConfig"); + if (rejectButtonDarkConfig != null) { + authViewConfig.rejectButtonDarkConfig = getAuthButtonConfig(rejectButtonDarkConfig); + } + uiConfig.setAuthViewConfig(authViewConfig); + } + Map floatWindowConfigMap = (Map) uiConfigMap.get("floatWindowConfig"); + if (floatWindowConfigMap != null) { + FinAppConfig.UIConfig.FloatWindowConfig floatWindowConfig = new FinAppConfig.UIConfig.FloatWindowConfig(); + floatWindowConfig.floatMode = (boolean) floatWindowConfigMap.get("floatMode"); + floatWindowConfig.x = (int) floatWindowConfigMap.get("x"); + floatWindowConfig.y = (int) floatWindowConfigMap.get("y"); + floatWindowConfig.width = (int) floatWindowConfigMap.get("width"); + floatWindowConfig.height = (int) floatWindowConfigMap.get("height"); + uiConfig.setFloatWindowConfig(floatWindowConfig); + } + Integer webViewProgressBarColor = (Integer) uiConfigMap.get("webViewProgressBarColor"); + if (webViewProgressBarColor != null) { + uiConfig.setWebViewProgressBarColor(webViewProgressBarColor); + } + uiConfig.setHideWebViewProgressBar((Boolean) uiConfigMap.get("hideWebViewProgressBar")); + uiConfig.setMoreMenuStyle((Integer) uiConfigMap.get("moreMenuStyle")); + int isHideBackHomePriorityIndex = (Integer) uiConfigMap.get("isHideBackHomePriority"); + if (isHideBackHomePriorityIndex == 0) { + uiConfig.setIsHideBackHomePriority(FinAppConfigPriority.GLOBAL); + } else if (isHideBackHomePriorityIndex == 1) { + uiConfig.setIsHideBackHomePriority(FinAppConfigPriority.SPECIFIED); + } else if (isHideBackHomePriorityIndex == 2) { + uiConfig.setIsHideBackHomePriority(FinAppConfigPriority.APPLET_FILE); + } + uiConfig.setAutoAdaptDarkMode((Boolean) uiConfigMap.get("autoAdaptDarkMode")); + String appendingCustomUserAgent = (String) uiConfigMap.get("appendingCustomUserAgent"); + if (appendingCustomUserAgent != null) { + configBuilder.setCustomWebViewUserAgent(appendingCustomUserAgent); + } + uiConfig.setDisableSlideCloseAppletGesture((Boolean) uiConfigMap.get("disableSlideCloseAppletGesture")); + String appletText = (String) uiConfigMap.get("appletText"); + if (appletText != null) { + configBuilder.setAppletText(appletText); + } + String loadingLayoutCls = (String) uiConfigMap.get("loadingLayoutCls"); + if (loadingLayoutCls != null) { +// uiConfig.setLoadingLayoutCls(loadingLayoutCls); + } - FinAppConfig.UIConfig uiConfig = null; - if (param.containsKey("uiConfig")) { - uiConfig = gson.fromJson(gson.toJson(param.get("uiConfig")), FinAppConfig.UIConfig.class); + configBuilder.setUiConfig(uiConfig); } - -// FinAppConfig config = builder.build(); -// Log.d(TAG, "config:" + gson.toJson(config)); + FinAppConfig finAppConfig = configBuilder.build(); + Log.d(TAG, "finAppConfig:" + new Gson().toJson(finAppConfig)); final Application application = MopPluginService.getInstance().getActivity().getApplication(); // SDK初始化结果回调,用于接收SDK初始化状态 @@ -72,6 +290,18 @@ public class InitSDKModule extends BaseApi { } }; - FinAppClient.INSTANCE.init(application, config, cb); + FinAppClient.INSTANCE.init(application, finAppConfig, cb); + } + + private FinAppConfig.UIConfig.AuthViewConfig.AuthButtonConfig getAuthButtonConfig(Map map) { + return new FinAppConfig.UIConfig.AuthViewConfig.AuthButtonConfig( + (float) map.get("cornerRadius"), + (int) map.get("normalBackgroundColor"), + (int) map.get("pressedBackgroundColor"), + (int) map.get("normalBorderColor"), + (int) map.get("pressedBorderColor"), + (int) map.get("normalTextColor"), + (int) map.get("pressedTextColor") + ); } } diff --git a/lib/mop.dart b/lib/mop.dart index 5a63a41..92abcdd 100644 --- a/lib/mop.dart +++ b/lib/mop.dart @@ -23,7 +23,7 @@ class FinStoreConfig { String apiServer; /// apm统计服务器的地址,如果不填,则默认与apiServer一致 - String apmServer; + String? apmServer; /// 网络接口加密类型,默认为MD5 国密SM String cryptType; @@ -34,8 +34,9 @@ class FinStoreConfig { /// 是否需要接口加密验证(初始化多服务器时使用)默认为不开启,当设置为YES时开启,接口返回加密数据并处理 bool encryptServerData; - FinStoreConfig(this.sdkKey, this.sdkSecret, this.apiServer, this.apmServer, - {this.cryptType = "MD5", + FinStoreConfig(this.sdkKey, this.sdkSecret, this.apiServer, + {this.apmServer, + this.cryptType = "MD5", this.fingerprint, this.encryptServerData = false}); @@ -152,7 +153,7 @@ class Config { int pageCountLimit = 0; /// 自定义的scheme数组 - List schemes = []; + List? schemes; Config(this.finStoreConfigs); From 2fbd9f4f163b88901ab068fc94ccee92d340e145 Mon Sep 17 00:00:00 2001 From: zhongweiguang Date: Wed, 22 Mar 2023 15:21:00 +0800 Subject: [PATCH 07/17] =?UTF-8?q?=E8=B0=83=E6=95=B4BaseModule=E8=8E=B7?= =?UTF-8?q?=E5=8F=96uiConfig=E7=9A=84=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/build.gradle | 2 +- .../com/finogeeks/mop/api/mop/BaseModule.java | 11 +- .../finogeeks/mop/api/mop/InitSDKModule.java | 165 ++---------------- .../finogeeks/mop/api/mop/util/InitUtils.java | 159 +++++++++++++++++ 4 files changed, 177 insertions(+), 160 deletions(-) create mode 100644 android/src/main/java/com/finogeeks/mop/api/mop/util/InitUtils.java diff --git a/android/build.gradle b/android/build.gradle index bf08398..5c3b04a 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -91,6 +91,6 @@ kapt { } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'com.finogeeks.lib:finapplet:2.39.11' + implementation 'com.finogeeks.lib:finapplet:2.39.12-alpha20230322v01' implementation 'com.finogeeks.mop:plugins:2.39.11' } \ No newline at end of file diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/BaseModule.java b/android/src/main/java/com/finogeeks/mop/api/mop/BaseModule.java index d81b892..4042e4b 100644 --- a/android/src/main/java/com/finogeeks/mop/api/mop/BaseModule.java +++ b/android/src/main/java/com/finogeeks/mop/api/mop/BaseModule.java @@ -9,6 +9,7 @@ import com.finogeeks.lib.applet.client.FinAppConfig; import com.finogeeks.lib.applet.client.FinStoreConfig; import com.finogeeks.lib.applet.interfaces.FinCallback; import com.finogeeks.mop.api.BaseApi; +import com.finogeeks.mop.api.mop.util.InitUtils; import com.finogeeks.mop.interfaces.ICallback; import com.finogeeks.mop.service.MopPluginService; import com.finogeeks.xlog.XLogLevel; @@ -105,11 +106,9 @@ public class BaseModule extends BaseApi { } } } - FinAppConfig.UIConfig uiConfig = null; - if (param.get("uiConfig") != null) { - uiConfig = gson.fromJson(gson.toJson(param.get("uiConfig")), FinAppConfig.UIConfig.class); - } + // uiConfig + FinAppConfig.UIConfig uiConfig = InitUtils.createUIConfigFromMap((Map) param.get("uiConfig")); FinAppConfig.Builder builder = new FinAppConfig.Builder() .setSdkKey(appkey) @@ -123,8 +122,8 @@ public class BaseModule extends BaseApi { .setDisableRequestPermissions(disablePermission) .setBindAppletWithMainProcess(bindAppletWithMainProcess) .setLogLevel(XLogLevel.LEVEL_VERBOSE) - .setXLogDir(new File(getContext().getExternalCacheDir(),"xlog")); -// .setPageCountLimit(pageCountLimit); + .setXLogDir(new File(getContext().getExternalCacheDir(),"xlog")) + .setPageCountLimit(pageCountLimit); if (customWebViewUserAgent != null) builder.setCustomWebViewUserAgent(customWebViewUserAgent); diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/InitSDKModule.java b/android/src/main/java/com/finogeeks/mop/api/mop/InitSDKModule.java index 26dbfc3..6211059 100644 --- a/android/src/main/java/com/finogeeks/mop/api/mop/InitSDKModule.java +++ b/android/src/main/java/com/finogeeks/mop/api/mop/InitSDKModule.java @@ -10,6 +10,7 @@ import com.finogeeks.lib.applet.client.FinAppConfigPriority; import com.finogeeks.lib.applet.client.FinStoreConfig; import com.finogeeks.lib.applet.interfaces.FinCallback; import com.finogeeks.mop.api.BaseApi; +import com.finogeeks.mop.api.mop.util.InitUtils; import com.finogeeks.mop.interfaces.ICallback; import com.finogeeks.mop.service.MopPluginService; import com.google.gson.Gson; @@ -120,150 +121,19 @@ public class InitSDKModule extends BaseApi { if (schemes != null) { configBuilder.setSchemes(schemes); } + Map uiConfigMap = (Map) param.get("uiConfig"); + String appendingCustomUserAgent = (String) uiConfigMap.get("appendingCustomUserAgent"); + if (appendingCustomUserAgent != null) { + configBuilder.setCustomWebViewUserAgent(appendingCustomUserAgent); + } + String appletText = (String) uiConfigMap.get("appletText"); + if (appletText != null) { + configBuilder.setAppletText(appletText); + } // uiConfig - Map uiConfigMap = (Map) param.get("uiConfig"); - if (uiConfigMap != null) { - FinAppConfig.UIConfig uiConfig = new FinAppConfig.UIConfig(); - uiConfig.setNavigationBarTitleLightColor((Integer) uiConfigMap.get("navigationBarTitleLightColor")); - uiConfig.setNavigationBarTitleDarkColor((Integer) uiConfigMap.get("navigationBarTitleDarkColor")); - uiConfig.setNavigationBarBackBtnLightColor((Integer) uiConfigMap.get("navigationBarBackBtnLightColor")); - uiConfig.setAlwaysShowBackInDefaultNavigationBar((Boolean) uiConfigMap.get("isAlwaysShowBackInDefaultNavigationBar")); - uiConfig.setClearNavigationBarNavButtonBackground((Boolean) uiConfigMap.get("isClearNavigationBarNavButtonBackground")); - uiConfig.setHideFeedbackAndComplaints((Boolean) uiConfigMap.get("isHideFeedbackAndComplaints")); - uiConfig.setHideBackHome((Boolean) uiConfigMap.get("isHideBackHome")); - uiConfig.setHideForwardMenu((Boolean) uiConfigMap.get("isHideForwardMenu")); - uiConfig.setHideRefreshMenu((Boolean) uiConfigMap.get("isHideRefreshMenu")); - uiConfig.setHideShareAppletMenu((Boolean) uiConfigMap.get("isHideShareAppletMenu")); - uiConfig.setHideSettingMenu((Boolean) uiConfigMap.get("isHideSettingMenu")); - uiConfig.setHideTransitionCloseButton((Boolean) uiConfigMap.get("hideTransitionCloseButton")); - Map capsuleConfigMap = (Map) uiConfigMap.get("capsuleConfig"); - if (capsuleConfigMap != null) { - FinAppConfig.UIConfig.CapsuleConfig capsuleConfig = new FinAppConfig.UIConfig.CapsuleConfig(); - capsuleConfig.capsuleWidth = (float) capsuleConfigMap.get("capsuleWidth"); - capsuleConfig.capsuleHeight = (float) capsuleConfigMap.get("capsuleHeight"); - capsuleConfig.capsuleRightMargin = (float) capsuleConfigMap.get("capsuleRightMargin"); - capsuleConfig.capsuleCornerRadius = (float) capsuleConfigMap.get("capsuleCornerRadius"); - capsuleConfig.capsuleBorderWidth = (float) capsuleConfigMap.get("capsuleBorderWidth"); - capsuleConfig.capsuleBgLightColor = (int) capsuleConfigMap.get("capsuleBgLightColor"); - capsuleConfig.capsuleBgDarkColor = (int) capsuleConfigMap.get("capsuleBgDarkColor"); - capsuleConfig.capsuleBorderLightColor = (int) capsuleConfigMap.get("capsuleBorderLightColor"); - capsuleConfig.capsuleBorderDarkColor = (int) capsuleConfigMap.get("capsuleBorderDarkColor"); - capsuleConfig.capsuleDividerLightColor = (int) capsuleConfigMap.get("capsuleDividerLightColor"); - capsuleConfig.capsuleDividerDarkColor = (int) capsuleConfigMap.get("capsuleDividerDarkColor"); - Integer moreLightImage = (Integer) capsuleConfigMap.get("moreLightImage"); - if (moreLightImage != null) { - capsuleConfig.moreLightImage = moreLightImage; - } - Integer moreDarkImage = (Integer) capsuleConfigMap.get("moreDarkImage"); - if (moreDarkImage != null) { - capsuleConfig.moreDarkImage = moreDarkImage; - } - capsuleConfig.moreBtnWidth = (float) capsuleConfigMap.get("moreBtnWidth"); - capsuleConfig.moreBtnLeftMargin = (float) capsuleConfigMap.get("moreBtnLeftMargin"); - Integer closeLightImage = (Integer) capsuleConfigMap.get("closeLightImage"); - if (closeLightImage != null) { - capsuleConfig.closeLightImage = closeLightImage; - } - Integer closeDarkImage = (Integer) capsuleConfigMap.get("closeDarkImage"); - if (closeDarkImage != null) { - capsuleConfig.closeDarkImage = closeDarkImage; - } - capsuleConfig.closeBtnWidth = (float) capsuleConfigMap.get("closeBtnWidth"); - capsuleConfig.closeBtnLeftMargin = (float) capsuleConfigMap.get("closeBtnLeftMargin"); - uiConfig.setCapsuleConfig(capsuleConfig); - } - Map navHomeConfigMap = (Map) uiConfigMap.get("navHomeConfig"); - if (navHomeConfigMap != null) { - FinAppConfig.UIConfig.NavHomeConfig navHomeConfig = new FinAppConfig.UIConfig.NavHomeConfig(); - navHomeConfig.width = (float) navHomeConfigMap.get("width"); - navHomeConfig.height = (float) navHomeConfigMap.get("height"); - navHomeConfig.leftMargin = (float) navHomeConfigMap.get("leftMargin"); - navHomeConfig.cornerRadius = (float) navHomeConfigMap.get("cornerRadius"); - navHomeConfig.borderWidth = (float) navHomeConfigMap.get("borderWidth"); - navHomeConfig.borderLightColor = (int) navHomeConfigMap.get("borderLightColor"); - navHomeConfig.borderDarkColor = (int) navHomeConfigMap.get("borderDarkColor"); - navHomeConfig.bgLightColor = (int) navHomeConfigMap.get("bgLightColor"); - navHomeConfig.bgDarkColor = (int) navHomeConfigMap.get("bgDarkColor"); - uiConfig.setNavHomeConfig(navHomeConfig); - } - Map authViewConfigMap = (Map) uiConfigMap.get("authViewConfig"); - if (authViewConfigMap != null) { - FinAppConfig.UIConfig.AuthViewConfig authViewConfig = new FinAppConfig.UIConfig.AuthViewConfig(); - authViewConfig.appletNameTextSize = (float) authViewConfigMap.get("appletNameTextSize"); - authViewConfig.appletNameLightColor = (int) authViewConfigMap.get("appletNameLightColor"); - authViewConfig.appletNameDarkColor = (int) authViewConfigMap.get("appletNameDarkColor"); - authViewConfig.authorizeTitleTextSize = (float) authViewConfigMap.get("authorizeTitleTextSize"); - authViewConfig.authorizeTitleLightColor = (int) authViewConfigMap.get("authorizeTitleLightColor"); - authViewConfig.authorizeTitleDarkColor = (int) authViewConfigMap.get("authorizeTitleDarkColor"); - authViewConfig.authorizeDescriptionTextSize = (float) authViewConfigMap.get("authorizeDescriptionTextSize"); - authViewConfig.authorizeDescriptionLightColor = (int) authViewConfigMap.get("authorizeDescriptionLightColor"); - authViewConfig.authorizeDescriptionDarkColor = (int) authViewConfigMap.get("authorizeDescriptionDarkColor"); - authViewConfig.agreementTitleTextSize = (float) authViewConfigMap.get("agreementTitleTextSize"); - authViewConfig.agreementTitleLightColor = (int) authViewConfigMap.get("agreementTitleLightColor"); - authViewConfig.agreementTitleDarkColor = (int) authViewConfigMap.get("agreementTitleDarkColor"); - authViewConfig.agreementDescriptionTextSize = (float) authViewConfigMap.get("agreementDescriptionTextSize"); - authViewConfig.agreementDescriptionLightColor = (int) authViewConfigMap.get("agreementDescriptionLightColor"); - authViewConfig.agreementDescriptionDarkColor = (int) authViewConfigMap.get("agreementDescriptionDarkColor"); - authViewConfig.linkLightColor = (int) authViewConfigMap.get("linkLightColor"); - authViewConfig.linkDarkColor = (int) authViewConfigMap.get("linkDarkColor"); - Map allowButtonLightConfig = (Map) authViewConfigMap.get("allowButtonLightConfig"); - if (allowButtonLightConfig != null) { - authViewConfig.allowButtonLightConfig = getAuthButtonConfig(allowButtonLightConfig); - } - Map allowButtonDarkConfig = (Map) authViewConfigMap.get("allowButtonDarkConfig"); - if (allowButtonDarkConfig != null) { - authViewConfig.allowButtonDarkConfig = getAuthButtonConfig(allowButtonDarkConfig); - } - Map rejectButtonLightConfig = (Map) authViewConfigMap.get("rejectButtonLightConfig"); - if (rejectButtonLightConfig != null) { - authViewConfig.rejectButtonLightConfig = getAuthButtonConfig(rejectButtonLightConfig); - } - Map rejectButtonDarkConfig = (Map) authViewConfigMap.get("rejectButtonDarkConfig"); - if (rejectButtonDarkConfig != null) { - authViewConfig.rejectButtonDarkConfig = getAuthButtonConfig(rejectButtonDarkConfig); - } - uiConfig.setAuthViewConfig(authViewConfig); - } - Map floatWindowConfigMap = (Map) uiConfigMap.get("floatWindowConfig"); - if (floatWindowConfigMap != null) { - FinAppConfig.UIConfig.FloatWindowConfig floatWindowConfig = new FinAppConfig.UIConfig.FloatWindowConfig(); - floatWindowConfig.floatMode = (boolean) floatWindowConfigMap.get("floatMode"); - floatWindowConfig.x = (int) floatWindowConfigMap.get("x"); - floatWindowConfig.y = (int) floatWindowConfigMap.get("y"); - floatWindowConfig.width = (int) floatWindowConfigMap.get("width"); - floatWindowConfig.height = (int) floatWindowConfigMap.get("height"); - uiConfig.setFloatWindowConfig(floatWindowConfig); - } - Integer webViewProgressBarColor = (Integer) uiConfigMap.get("webViewProgressBarColor"); - if (webViewProgressBarColor != null) { - uiConfig.setWebViewProgressBarColor(webViewProgressBarColor); - } - uiConfig.setHideWebViewProgressBar((Boolean) uiConfigMap.get("hideWebViewProgressBar")); - uiConfig.setMoreMenuStyle((Integer) uiConfigMap.get("moreMenuStyle")); - int isHideBackHomePriorityIndex = (Integer) uiConfigMap.get("isHideBackHomePriority"); - if (isHideBackHomePriorityIndex == 0) { - uiConfig.setIsHideBackHomePriority(FinAppConfigPriority.GLOBAL); - } else if (isHideBackHomePriorityIndex == 1) { - uiConfig.setIsHideBackHomePriority(FinAppConfigPriority.SPECIFIED); - } else if (isHideBackHomePriorityIndex == 2) { - uiConfig.setIsHideBackHomePriority(FinAppConfigPriority.APPLET_FILE); - } - uiConfig.setAutoAdaptDarkMode((Boolean) uiConfigMap.get("autoAdaptDarkMode")); - String appendingCustomUserAgent = (String) uiConfigMap.get("appendingCustomUserAgent"); - if (appendingCustomUserAgent != null) { - configBuilder.setCustomWebViewUserAgent(appendingCustomUserAgent); - } - uiConfig.setDisableSlideCloseAppletGesture((Boolean) uiConfigMap.get("disableSlideCloseAppletGesture")); - String appletText = (String) uiConfigMap.get("appletText"); - if (appletText != null) { - configBuilder.setAppletText(appletText); - } - String loadingLayoutCls = (String) uiConfigMap.get("loadingLayoutCls"); - if (loadingLayoutCls != null) { -// uiConfig.setLoadingLayoutCls(loadingLayoutCls); - } - + FinAppConfig.UIConfig uiConfig = InitUtils.createUIConfigFromMap(uiConfigMap); + if (uiConfig != null) { configBuilder.setUiConfig(uiConfig); } @@ -293,15 +163,4 @@ public class InitSDKModule extends BaseApi { FinAppClient.INSTANCE.init(application, finAppConfig, cb); } - private FinAppConfig.UIConfig.AuthViewConfig.AuthButtonConfig getAuthButtonConfig(Map map) { - return new FinAppConfig.UIConfig.AuthViewConfig.AuthButtonConfig( - (float) map.get("cornerRadius"), - (int) map.get("normalBackgroundColor"), - (int) map.get("pressedBackgroundColor"), - (int) map.get("normalBorderColor"), - (int) map.get("pressedBorderColor"), - (int) map.get("normalTextColor"), - (int) map.get("pressedTextColor") - ); - } } diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/util/InitUtils.java b/android/src/main/java/com/finogeeks/mop/api/mop/util/InitUtils.java new file mode 100644 index 0000000..9bec726 --- /dev/null +++ b/android/src/main/java/com/finogeeks/mop/api/mop/util/InitUtils.java @@ -0,0 +1,159 @@ +package com.finogeeks.mop.api.mop.util; + +import com.finogeeks.lib.applet.client.FinAppConfig; +import com.finogeeks.lib.applet.client.FinAppConfigPriority; + +import java.util.Map; + +public class InitUtils { + + public static FinAppConfig.UIConfig createUIConfigFromMap(Map map) { + if (map != null) { + FinAppConfig.UIConfig uiConfig = new FinAppConfig.UIConfig(); + uiConfig.setNavigationBarTitleLightColor((Integer) map.get("navigationBarTitleLightColor")); + uiConfig.setNavigationBarTitleDarkColor((Integer) map.get("navigationBarTitleDarkColor")); + uiConfig.setNavigationBarBackBtnLightColor((Integer) map.get("navigationBarBackBtnLightColor")); + uiConfig.setAlwaysShowBackInDefaultNavigationBar((Boolean) map.get("isAlwaysShowBackInDefaultNavigationBar")); + uiConfig.setClearNavigationBarNavButtonBackground((Boolean) map.get("isClearNavigationBarNavButtonBackground")); + uiConfig.setHideFeedbackAndComplaints((Boolean) map.get("isHideFeedbackAndComplaints")); + uiConfig.setHideBackHome((Boolean) map.get("isHideBackHome")); + uiConfig.setHideForwardMenu((Boolean) map.get("isHideForwardMenu")); + uiConfig.setHideRefreshMenu((Boolean) map.get("isHideRefreshMenu")); + uiConfig.setHideShareAppletMenu((Boolean) map.get("isHideShareAppletMenu")); + uiConfig.setHideSettingMenu((Boolean) map.get("isHideSettingMenu")); + uiConfig.setHideTransitionCloseButton((Boolean) map.get("hideTransitionCloseButton")); + Map capsuleConfigMap = (Map) map.get("capsuleConfig"); + if (capsuleConfigMap != null) { + FinAppConfig.UIConfig.CapsuleConfig capsuleConfig = new FinAppConfig.UIConfig.CapsuleConfig(); + capsuleConfig.capsuleWidth = (float) capsuleConfigMap.get("capsuleWidth"); + capsuleConfig.capsuleHeight = (float) capsuleConfigMap.get("capsuleHeight"); + capsuleConfig.capsuleRightMargin = (float) capsuleConfigMap.get("capsuleRightMargin"); + capsuleConfig.capsuleCornerRadius = (float) capsuleConfigMap.get("capsuleCornerRadius"); + capsuleConfig.capsuleBorderWidth = (float) capsuleConfigMap.get("capsuleBorderWidth"); + capsuleConfig.capsuleBgLightColor = (int) capsuleConfigMap.get("capsuleBgLightColor"); + capsuleConfig.capsuleBgDarkColor = (int) capsuleConfigMap.get("capsuleBgDarkColor"); + capsuleConfig.capsuleBorderLightColor = (int) capsuleConfigMap.get("capsuleBorderLightColor"); + capsuleConfig.capsuleBorderDarkColor = (int) capsuleConfigMap.get("capsuleBorderDarkColor"); + capsuleConfig.capsuleDividerLightColor = (int) capsuleConfigMap.get("capsuleDividerLightColor"); + capsuleConfig.capsuleDividerDarkColor = (int) capsuleConfigMap.get("capsuleDividerDarkColor"); + Integer moreLightImage = (Integer) capsuleConfigMap.get("moreLightImage"); + if (moreLightImage != null) { + capsuleConfig.moreLightImage = moreLightImage; + } + Integer moreDarkImage = (Integer) capsuleConfigMap.get("moreDarkImage"); + if (moreDarkImage != null) { + capsuleConfig.moreDarkImage = moreDarkImage; + } + capsuleConfig.moreBtnWidth = (float) capsuleConfigMap.get("moreBtnWidth"); + capsuleConfig.moreBtnLeftMargin = (float) capsuleConfigMap.get("moreBtnLeftMargin"); + Integer closeLightImage = (Integer) capsuleConfigMap.get("closeLightImage"); + if (closeLightImage != null) { + capsuleConfig.closeLightImage = closeLightImage; + } + Integer closeDarkImage = (Integer) capsuleConfigMap.get("closeDarkImage"); + if (closeDarkImage != null) { + capsuleConfig.closeDarkImage = closeDarkImage; + } + capsuleConfig.closeBtnWidth = (float) capsuleConfigMap.get("closeBtnWidth"); + capsuleConfig.closeBtnLeftMargin = (float) capsuleConfigMap.get("closeBtnLeftMargin"); + uiConfig.setCapsuleConfig(capsuleConfig); + } + Map navHomeConfigMap = (Map) map.get("navHomeConfig"); + if (navHomeConfigMap != null) { + FinAppConfig.UIConfig.NavHomeConfig navHomeConfig = new FinAppConfig.UIConfig.NavHomeConfig(); + navHomeConfig.width = (float) navHomeConfigMap.get("width"); + navHomeConfig.height = (float) navHomeConfigMap.get("height"); + navHomeConfig.leftMargin = (float) navHomeConfigMap.get("leftMargin"); + navHomeConfig.cornerRadius = (float) navHomeConfigMap.get("cornerRadius"); + navHomeConfig.borderWidth = (float) navHomeConfigMap.get("borderWidth"); + navHomeConfig.borderLightColor = (int) navHomeConfigMap.get("borderLightColor"); + navHomeConfig.borderDarkColor = (int) navHomeConfigMap.get("borderDarkColor"); + navHomeConfig.bgLightColor = (int) navHomeConfigMap.get("bgLightColor"); + navHomeConfig.bgDarkColor = (int) navHomeConfigMap.get("bgDarkColor"); + uiConfig.setNavHomeConfig(navHomeConfig); + } + Map authViewConfigMap = (Map) map.get("authViewConfig"); + if (authViewConfigMap != null) { + FinAppConfig.UIConfig.AuthViewConfig authViewConfig = new FinAppConfig.UIConfig.AuthViewConfig(); + authViewConfig.appletNameTextSize = (float) authViewConfigMap.get("appletNameTextSize"); + authViewConfig.appletNameLightColor = (int) authViewConfigMap.get("appletNameLightColor"); + authViewConfig.appletNameDarkColor = (int) authViewConfigMap.get("appletNameDarkColor"); + authViewConfig.authorizeTitleTextSize = (float) authViewConfigMap.get("authorizeTitleTextSize"); + authViewConfig.authorizeTitleLightColor = (int) authViewConfigMap.get("authorizeTitleLightColor"); + authViewConfig.authorizeTitleDarkColor = (int) authViewConfigMap.get("authorizeTitleDarkColor"); + authViewConfig.authorizeDescriptionTextSize = (float) authViewConfigMap.get("authorizeDescriptionTextSize"); + authViewConfig.authorizeDescriptionLightColor = (int) authViewConfigMap.get("authorizeDescriptionLightColor"); + authViewConfig.authorizeDescriptionDarkColor = (int) authViewConfigMap.get("authorizeDescriptionDarkColor"); + authViewConfig.agreementTitleTextSize = (float) authViewConfigMap.get("agreementTitleTextSize"); + authViewConfig.agreementTitleLightColor = (int) authViewConfigMap.get("agreementTitleLightColor"); + authViewConfig.agreementTitleDarkColor = (int) authViewConfigMap.get("agreementTitleDarkColor"); + authViewConfig.agreementDescriptionTextSize = (float) authViewConfigMap.get("agreementDescriptionTextSize"); + authViewConfig.agreementDescriptionLightColor = (int) authViewConfigMap.get("agreementDescriptionLightColor"); + authViewConfig.agreementDescriptionDarkColor = (int) authViewConfigMap.get("agreementDescriptionDarkColor"); + authViewConfig.linkLightColor = (int) authViewConfigMap.get("linkLightColor"); + authViewConfig.linkDarkColor = (int) authViewConfigMap.get("linkDarkColor"); + Map allowButtonLightConfig = (Map) authViewConfigMap.get("allowButtonLightConfig"); + if (allowButtonLightConfig != null) { + authViewConfig.allowButtonLightConfig = getAuthButtonConfig(allowButtonLightConfig); + } + Map allowButtonDarkConfig = (Map) authViewConfigMap.get("allowButtonDarkConfig"); + if (allowButtonDarkConfig != null) { + authViewConfig.allowButtonDarkConfig = getAuthButtonConfig(allowButtonDarkConfig); + } + Map rejectButtonLightConfig = (Map) authViewConfigMap.get("rejectButtonLightConfig"); + if (rejectButtonLightConfig != null) { + authViewConfig.rejectButtonLightConfig = getAuthButtonConfig(rejectButtonLightConfig); + } + Map rejectButtonDarkConfig = (Map) authViewConfigMap.get("rejectButtonDarkConfig"); + if (rejectButtonDarkConfig != null) { + authViewConfig.rejectButtonDarkConfig = getAuthButtonConfig(rejectButtonDarkConfig); + } + uiConfig.setAuthViewConfig(authViewConfig); + } + Map floatWindowConfigMap = (Map) map.get("floatWindowConfig"); + if (floatWindowConfigMap != null) { + FinAppConfig.UIConfig.FloatWindowConfig floatWindowConfig = new FinAppConfig.UIConfig.FloatWindowConfig(); + floatWindowConfig.floatMode = (boolean) floatWindowConfigMap.get("floatMode"); + floatWindowConfig.x = (int) floatWindowConfigMap.get("x"); + floatWindowConfig.y = (int) floatWindowConfigMap.get("y"); + floatWindowConfig.width = (int) floatWindowConfigMap.get("width"); + floatWindowConfig.height = (int) floatWindowConfigMap.get("height"); + uiConfig.setFloatWindowConfig(floatWindowConfig); + } + Integer webViewProgressBarColor = (Integer) map.get("webViewProgressBarColor"); + if (webViewProgressBarColor != null) { + uiConfig.setWebViewProgressBarColor(webViewProgressBarColor); + } + uiConfig.setHideWebViewProgressBar((Boolean) map.get("hideWebViewProgressBar")); + uiConfig.setMoreMenuStyle((Integer) map.get("moreMenuStyle")); + int isHideBackHomePriorityIndex = (Integer) map.get("isHideBackHomePriority"); + if (isHideBackHomePriorityIndex == 0) { + uiConfig.setIsHideBackHomePriority(FinAppConfigPriority.GLOBAL); + } else if (isHideBackHomePriorityIndex == 1) { + uiConfig.setIsHideBackHomePriority(FinAppConfigPriority.SPECIFIED); + } else if (isHideBackHomePriorityIndex == 2) { + uiConfig.setIsHideBackHomePriority(FinAppConfigPriority.APPLET_FILE); + } + uiConfig.setAutoAdaptDarkMode((Boolean) map.get("autoAdaptDarkMode")); + uiConfig.setDisableSlideCloseAppletGesture((Boolean) map.get("disableSlideCloseAppletGesture")); + String loadingLayoutCls = (String) map.get("loadingLayoutCls"); + if (loadingLayoutCls != null) { + uiConfig.setLoadingLayoutCls(loadingLayoutCls); + } + return uiConfig; + } + return null; + } + + private static FinAppConfig.UIConfig.AuthViewConfig.AuthButtonConfig getAuthButtonConfig(Map map) { + return new FinAppConfig.UIConfig.AuthViewConfig.AuthButtonConfig( + (float) map.get("cornerRadius"), + (int) map.get("normalBackgroundColor"), + (int) map.get("pressedBackgroundColor"), + (int) map.get("normalBorderColor"), + (int) map.get("pressedBorderColor"), + (int) map.get("normalTextColor"), + (int) map.get("pressedTextColor") + ); + } +} From 02902cc9650eed65ddabb82eebd2175c502b1c4f Mon Sep 17 00:00:00 2001 From: wangtao Date: Wed, 22 Mar 2023 16:17:23 +0800 Subject: [PATCH 08/17] =?UTF-8?q?fix:=20=E8=AE=BE=E7=BD=AE=E9=A1=B9?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Classes/Api/MOP_initSDK.m | 1 + ios/mop.podspec | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ios/Classes/Api/MOP_initSDK.m b/ios/Classes/Api/MOP_initSDK.m index 8205f7b..0f6cd2d 100644 --- a/ios/Classes/Api/MOP_initSDK.m +++ b/ios/Classes/Api/MOP_initSDK.m @@ -101,6 +101,7 @@ uiconfig.hideFeedbackMenu = [_uiConfig[@"isHideFeedbackAndComplaints"] boolValue]; uiconfig.hideForwardMenu = [_uiConfig[@"isHideForwardMenu"] boolValue]; uiconfig.autoAdaptDarkMode = [_uiConfig[@"autoAdaptDarkMode"] boolValue]; + uiconfig.hideSettingMenu = [_uiConfig[@"isHideSettingMenu"] boolValue]; uiconfig.appletText = _uiConfig[@"appletText"]; uiconfig.disableSlideCloseAppletGesture = [_uiConfig[@"disableSlideCloseAppletGesture"] boolValue]; diff --git a/ios/mop.podspec b/ios/mop.podspec index 1f7d386..c0169b5 100644 --- a/ios/mop.podspec +++ b/ios/mop.podspec @@ -17,7 +17,7 @@ A finclip miniprogram flutter sdk. s.dependency 'Flutter' s.ios.deployment_target = '9.0' - s.dependency 'FinApplet' , '2.39.11' - s.dependency 'FinAppletExt' , '2.39.11' + s.dependency 'FinApplet' , '2.40.0-dev20230322v02' + s.dependency 'FinAppletExt' , '2.40.0-dev20230322v02' end From acea046f33d0570c1bdabc97009ab30e57f5045e Mon Sep 17 00:00:00 2001 From: zhongweiguang Date: Wed, 22 Mar 2023 17:27:17 +0800 Subject: [PATCH 09/17] =?UTF-8?q?initSDK=E8=A1=A5=E5=85=85=E9=83=A8?= =?UTF-8?q?=E5=88=86=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/build.gradle | 2 +- .../finogeeks/mop/api/mop/InitSDKModule.java | 49 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index 5c3b04a..0465558 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -91,6 +91,6 @@ kapt { } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'com.finogeeks.lib:finapplet:2.39.12-alpha20230322v01' + implementation 'com.finogeeks.lib:finapplet:2.39.12-alpha20230322v02' implementation 'com.finogeeks.mop:plugins:2.39.11' } \ No newline at end of file diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/InitSDKModule.java b/android/src/main/java/com/finogeeks/mop/api/mop/InitSDKModule.java index 6211059..e7029fe 100644 --- a/android/src/main/java/com/finogeeks/mop/api/mop/InitSDKModule.java +++ b/android/src/main/java/com/finogeeks/mop/api/mop/InitSDKModule.java @@ -13,6 +13,7 @@ import com.finogeeks.mop.api.BaseApi; import com.finogeeks.mop.api.mop.util.InitUtils; import com.finogeeks.mop.interfaces.ICallback; import com.finogeeks.mop.service.MopPluginService; +import com.finogeeks.xlog.XLogLevel; import com.google.gson.Gson; import java.util.ArrayList; @@ -121,6 +122,54 @@ public class InitSDKModule extends BaseApi { if (schemes != null) { configBuilder.setSchemes(schemes); } + configBuilder.setDebugMode((Boolean) configMap.get("debug")); + Integer maxRunningApplet = (Integer) configMap.get("maxRunningApplet"); + if (maxRunningApplet != null) { + configBuilder.setMaxRunningApplet(maxRunningApplet); + } + Integer webViewMixedContentMode = (Integer) configMap.get("webViewMixedContentMode"); + if (webViewMixedContentMode != null) { + configBuilder.setWebViewMixedContentMode(webViewMixedContentMode); + } + configBuilder.setBindAppletWithMainProcess((Boolean) configMap.get("bindAppletWithMainProcess")); + String killAppletProcessNotice = (String) configMap.get("killAppletProcessNotice"); + if (killAppletProcessNotice != null) { + configBuilder.setKillAppletProcessNotice(killAppletProcessNotice); + } + configBuilder.setMinAndroidSdkVersion((Integer) configMap.get("minAndroidSdkVersion")); + configBuilder.setEnableScreenShot((Boolean) configMap.get("enableScreenShot")); + int screenShotPriorityIndex = (Integer) configMap.get("screenShotPriority"); + if (screenShotPriorityIndex == 0) { + configBuilder.setScreenShotPriority(FinAppConfigPriority.GLOBAL); + } else if (screenShotPriorityIndex == 1) { + configBuilder.setScreenShotPriority(FinAppConfigPriority.SPECIFIED); + } else if (screenShotPriorityIndex == 2) { + configBuilder.setScreenShotPriority(FinAppConfigPriority.APPLET_FILE); + } + int logLevelIndex = (Integer) configMap.get("logLevel"); + if (logLevelIndex == 0) { + configBuilder.setLogLevel(XLogLevel.LEVEL_VERBOSE); + } else if (logLevelIndex == 1) { + configBuilder.setLogLevel(XLogLevel.LEVEL_DEBUG); + } else if (logLevelIndex == 2) { + configBuilder.setLogLevel(XLogLevel.LEVEL_INFO); + } else if (logLevelIndex == 3) { + configBuilder.setLogLevel(XLogLevel.LEVEL_WARNING); + } else if (logLevelIndex == 4) { + configBuilder.setLogLevel(XLogLevel.LEVEL_ERROR); + } else if (logLevelIndex == 5) { + configBuilder.setLogLevel(XLogLevel.LEVEL_NONE); + } + Integer logMaxAliveSec = (Integer) configMap.get("logMaxAliveSec"); + if (logMaxAliveSec != null) { + configBuilder.setLogMaxAliveSec(logMaxAliveSec); + } + String logDir = (String) configMap.get("logDir"); + if (logDir != null) { + configBuilder.setXLogDir(logDir); + } + configBuilder.setEnablePreNewProcess((Boolean) configMap.get("enablePreNewProcess")); + Map uiConfigMap = (Map) param.get("uiConfig"); String appendingCustomUserAgent = (String) uiConfigMap.get("appendingCustomUserAgent"); if (appendingCustomUserAgent != null) { From dce531bdecf8c620fb47d06d486ec13b880162d0 Mon Sep 17 00:00:00 2001 From: zhongweiguang Date: Wed, 22 Mar 2023 17:27:17 +0800 Subject: [PATCH 10/17] =?UTF-8?q?initSDK=E8=A1=A5=E5=85=85=E9=83=A8?= =?UTF-8?q?=E5=88=86=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/build.gradle | 2 +- .../finogeeks/mop/api/mop/InitSDKModule.java | 49 +++++++++++++ lib/mop.dart | 69 ++++++++++++++++++- 3 files changed, 118 insertions(+), 2 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 5c3b04a..0465558 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -91,6 +91,6 @@ kapt { } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'com.finogeeks.lib:finapplet:2.39.12-alpha20230322v01' + implementation 'com.finogeeks.lib:finapplet:2.39.12-alpha20230322v02' implementation 'com.finogeeks.mop:plugins:2.39.11' } \ No newline at end of file diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/InitSDKModule.java b/android/src/main/java/com/finogeeks/mop/api/mop/InitSDKModule.java index 6211059..e7029fe 100644 --- a/android/src/main/java/com/finogeeks/mop/api/mop/InitSDKModule.java +++ b/android/src/main/java/com/finogeeks/mop/api/mop/InitSDKModule.java @@ -13,6 +13,7 @@ import com.finogeeks.mop.api.BaseApi; import com.finogeeks.mop.api.mop.util.InitUtils; import com.finogeeks.mop.interfaces.ICallback; import com.finogeeks.mop.service.MopPluginService; +import com.finogeeks.xlog.XLogLevel; import com.google.gson.Gson; import java.util.ArrayList; @@ -121,6 +122,54 @@ public class InitSDKModule extends BaseApi { if (schemes != null) { configBuilder.setSchemes(schemes); } + configBuilder.setDebugMode((Boolean) configMap.get("debug")); + Integer maxRunningApplet = (Integer) configMap.get("maxRunningApplet"); + if (maxRunningApplet != null) { + configBuilder.setMaxRunningApplet(maxRunningApplet); + } + Integer webViewMixedContentMode = (Integer) configMap.get("webViewMixedContentMode"); + if (webViewMixedContentMode != null) { + configBuilder.setWebViewMixedContentMode(webViewMixedContentMode); + } + configBuilder.setBindAppletWithMainProcess((Boolean) configMap.get("bindAppletWithMainProcess")); + String killAppletProcessNotice = (String) configMap.get("killAppletProcessNotice"); + if (killAppletProcessNotice != null) { + configBuilder.setKillAppletProcessNotice(killAppletProcessNotice); + } + configBuilder.setMinAndroidSdkVersion((Integer) configMap.get("minAndroidSdkVersion")); + configBuilder.setEnableScreenShot((Boolean) configMap.get("enableScreenShot")); + int screenShotPriorityIndex = (Integer) configMap.get("screenShotPriority"); + if (screenShotPriorityIndex == 0) { + configBuilder.setScreenShotPriority(FinAppConfigPriority.GLOBAL); + } else if (screenShotPriorityIndex == 1) { + configBuilder.setScreenShotPriority(FinAppConfigPriority.SPECIFIED); + } else if (screenShotPriorityIndex == 2) { + configBuilder.setScreenShotPriority(FinAppConfigPriority.APPLET_FILE); + } + int logLevelIndex = (Integer) configMap.get("logLevel"); + if (logLevelIndex == 0) { + configBuilder.setLogLevel(XLogLevel.LEVEL_VERBOSE); + } else if (logLevelIndex == 1) { + configBuilder.setLogLevel(XLogLevel.LEVEL_DEBUG); + } else if (logLevelIndex == 2) { + configBuilder.setLogLevel(XLogLevel.LEVEL_INFO); + } else if (logLevelIndex == 3) { + configBuilder.setLogLevel(XLogLevel.LEVEL_WARNING); + } else if (logLevelIndex == 4) { + configBuilder.setLogLevel(XLogLevel.LEVEL_ERROR); + } else if (logLevelIndex == 5) { + configBuilder.setLogLevel(XLogLevel.LEVEL_NONE); + } + Integer logMaxAliveSec = (Integer) configMap.get("logMaxAliveSec"); + if (logMaxAliveSec != null) { + configBuilder.setLogMaxAliveSec(logMaxAliveSec); + } + String logDir = (String) configMap.get("logDir"); + if (logDir != null) { + configBuilder.setXLogDir(logDir); + } + configBuilder.setEnablePreNewProcess((Boolean) configMap.get("enablePreNewProcess")); + Map uiConfigMap = (Map) param.get("uiConfig"); String appendingCustomUserAgent = (String) uiConfigMap.get("appendingCustomUserAgent"); if (appendingCustomUserAgent != null) { diff --git a/lib/mop.dart b/lib/mop.dart index 92abcdd..581252b 100644 --- a/lib/mop.dart +++ b/lib/mop.dart @@ -133,7 +133,7 @@ class Config { /// 对ft.request、ft.downloadFile、ft.uploadFile均会生效 Map? header; - /// header优先级设置,默认全局配置优先 + /// header优先级设置,默认全局配置优先 ConfigPriority headerPriority = ConfigPriority.ConfigGlobalPriority; /// iOS属性 @@ -155,6 +155,52 @@ class Config { /// 自定义的scheme数组 List? schemes; + /// Android属性 + /// 设置debug模式,影响调试和日志。 + bool debug = false; + + /// Android属性 + /// 设置最大同时运行小程序个数 + int? maxRunningApplet; + + /// Android属性 + /// WebView mixed content mode + int? webViewMixedContentMode; + + /// Android属性 + /// 小程序与app进程绑定,App被杀死,小程序同步关闭 + bool bindAppletWithMainProcess = false; + + /// Android属性 + /// App被杀后关闭小程序的提示文案 + String? killAppletProcessNotice; + + /// Android属性 + /// 最低支持的Android SDK版本 + int minAndroidSdkVersion = 21; // Build.VERSION_CODES.LOLLIPOP + + /// Android属性 + /// 是否允许截屏录屏,默认允许 + bool enableScreenShot = false; + + /// Android属性 + /// 截屏录屏配置项的优先级,默认GLOBAL + ConfigPriority screenShotPriority = ConfigPriority.ConfigGlobalPriority; + + /// 日志记录等级 + LogLevel logLevel = LogLevel.LEVEL_NONE; + + /// 日志文件最长缓存时间,单位秒。 + /// 最小不能小于1天,即不能小于 1 * 24 * 60 * 60 秒。 + int? logMaxAliveSec; + + /// XLog日志文件路径 + String? logDir; + + /// Android属性 + /// 是否提前创建进程 + bool enablePreNewProcess = false; + Config(this.finStoreConfigs); Map toMap() { @@ -184,6 +230,18 @@ class Config { "h5AjaxHookRequestKey": h5AjaxHookRequestKey, "pageCountLimit": pageCountLimit, "schemes": schemes, + "debug": debug, + "maxRunningApplet": maxRunningApplet, + "webViewMixedContentMode": webViewMixedContentMode, + "bindAppletWithMainProcess": bindAppletWithMainProcess, + "killAppletProcessNotice": killAppletProcessNotice, + "minAndroidSdkVersion": minAndroidSdkVersion, + "enableScreenShot": enableScreenShot, + "screenShotPriority": screenShotPriority.index, + "logLevel": logLevel.index, + "logMaxAliveSec": logMaxAliveSec, + "logDir": logDir, + "enablePreNewProcess": enablePreNewProcess, }; } } @@ -786,6 +844,15 @@ enum BOOLState { BOOLStateForbidden, // 所有版本强制关闭vconsole,且不可调api开启,多面板不展示打开、关闭调试菜单 } +enum LogLevel { + LEVEL_VERBOSE, + LEVEL_DEBUG, + LEVEL_INFO, + LEVEL_WARNING, + LEVEL_ERROR, + LEVEL_NONE +} + class Mop { static final Mop _instance = new Mop._internal(); late MethodChannel _channel; From f4269be3c51b24e36d9ef6f994f4be130e255c21 Mon Sep 17 00:00:00 2001 From: zhongweiguang Date: Wed, 22 Mar 2023 17:32:32 +0800 Subject: [PATCH 11/17] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/mop.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/mop.dart b/lib/mop.dart index 581252b..a62cd0e 100644 --- a/lib/mop.dart +++ b/lib/mop.dart @@ -190,6 +190,7 @@ class Config { /// 日志记录等级 LogLevel logLevel = LogLevel.LEVEL_NONE; + /// Android属性 /// 日志文件最长缓存时间,单位秒。 /// 最小不能小于1天,即不能小于 1 * 24 * 60 * 60 秒。 int? logMaxAliveSec; From 67ccec51e47ca6e9d34a35a3d494c1ff5d333448 Mon Sep 17 00:00:00 2001 From: wangtao Date: Thu, 23 Mar 2023 11:22:01 +0800 Subject: [PATCH 12/17] =?UTF-8?q?fix:=20ios=E6=B7=BB=E5=8A=A0=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E5=8F=82=E6=95=B0=E9=85=8D=E7=BD=AE=EF=BC=8C=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=AE=89=E5=8D=93=E6=97=A5=E5=BF=97=E7=AD=89=E7=BA=A7?= =?UTF-8?q?=E7=9A=84=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/finogeeks/mop/api/mop/InitSDKModule.java | 8 ++++---- ios/Classes/Api/MOP_initSDK.m | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/InitSDKModule.java b/android/src/main/java/com/finogeeks/mop/api/mop/InitSDKModule.java index e7029fe..fe11cdd 100644 --- a/android/src/main/java/com/finogeeks/mop/api/mop/InitSDKModule.java +++ b/android/src/main/java/com/finogeeks/mop/api/mop/InitSDKModule.java @@ -148,15 +148,15 @@ public class InitSDKModule extends BaseApi { } int logLevelIndex = (Integer) configMap.get("logLevel"); if (logLevelIndex == 0) { - configBuilder.setLogLevel(XLogLevel.LEVEL_VERBOSE); + configBuilder.setLogLevel(XLogLevel.LEVEL_ERROR); } else if (logLevelIndex == 1) { - configBuilder.setLogLevel(XLogLevel.LEVEL_DEBUG); + configBuilder.setLogLevel(XLogLevel.LEVEL_WARNING); } else if (logLevelIndex == 2) { configBuilder.setLogLevel(XLogLevel.LEVEL_INFO); } else if (logLevelIndex == 3) { - configBuilder.setLogLevel(XLogLevel.LEVEL_WARNING); + configBuilder.setLogLevel(XLogLevel.LEVEL_DEBUG); } else if (logLevelIndex == 4) { - configBuilder.setLogLevel(XLogLevel.LEVEL_ERROR); + configBuilder.setLogLevel(XLogLevel.LEVEL_VERBOSE); } else if (logLevelIndex == 5) { configBuilder.setLogLevel(XLogLevel.LEVEL_NONE); } diff --git a/ios/Classes/Api/MOP_initSDK.m b/ios/Classes/Api/MOP_initSDK.m index 0f6cd2d..57c0157 100644 --- a/ios/Classes/Api/MOP_initSDK.m +++ b/ios/Classes/Api/MOP_initSDK.m @@ -250,8 +250,10 @@ failure(@"初始化失败"); return; } + FATLogLevel logLevel = [self.config[@"logLevel"] integerValue]; + NSString *logDir = self.config[@"logDir"]; // [[FATExtClient sharedClient] fat_prepareExtensionApis]; - [[FATClient sharedClient].logManager initLogWithLogDir:nil logLevel:FATLogLevelVerbose consoleLog:YES]; + [[FATClient sharedClient].logManager initLogWithLogDir:logDir logLevel:logLevel consoleLog:YES]; [[FATClient sharedClient] setEnableLog:YES]; From 280592e88866e43f3e4f67897972a4e6915a5f46 Mon Sep 17 00:00:00 2001 From: wangtao Date: Thu, 23 Mar 2023 11:45:52 +0800 Subject: [PATCH 13/17] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E6=94=B9addWebExten?= =?UTF-8?q?tionApi=E7=B1=BB=E5=90=8D=E9=94=99=E8=AF=AF=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E7=94=9F=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20=09iOS=E6=B7=BB=E5=8A=A0changeUserId=E7=9A=84API=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...bExtentionApi.h => MOP_addWebExtentionApi.h} | 2 +- ...bExtentionApi.m => MOP_addWebExtentionApi.m} | 4 ++-- ios/Classes/Api/MOP_changeUserId.h | 16 ++++++++++++++++ ios/Classes/Api/MOP_changeUserId.m | 17 +++++++++++++++++ ios/Classes/Api/MOP_initSDK.m | 14 ++++++++++---- 5 files changed, 46 insertions(+), 7 deletions(-) rename ios/Classes/Api/{MOB_addWebExtentionApi.h => MOP_addWebExtentionApi.h} (81%) rename ios/Classes/Api/{MOB_addWebExtentionApi.m => MOP_addWebExtentionApi.m} (96%) create mode 100644 ios/Classes/Api/MOP_changeUserId.h create mode 100644 ios/Classes/Api/MOP_changeUserId.m diff --git a/ios/Classes/Api/MOB_addWebExtentionApi.h b/ios/Classes/Api/MOP_addWebExtentionApi.h similarity index 81% rename from ios/Classes/Api/MOB_addWebExtentionApi.h rename to ios/Classes/Api/MOP_addWebExtentionApi.h index d33d50d..53d26e7 100644 --- a/ios/Classes/Api/MOB_addWebExtentionApi.h +++ b/ios/Classes/Api/MOP_addWebExtentionApi.h @@ -9,7 +9,7 @@ NS_ASSUME_NONNULL_BEGIN -@interface MOB_addWebExtentionApi : MOPBaseApi +@interface MOP_addWebExtentionApi : MOPBaseApi @property(nonatomic, copy) NSString* name; @end diff --git a/ios/Classes/Api/MOB_addWebExtentionApi.m b/ios/Classes/Api/MOP_addWebExtentionApi.m similarity index 96% rename from ios/Classes/Api/MOB_addWebExtentionApi.m rename to ios/Classes/Api/MOP_addWebExtentionApi.m index ba81192..0059d5b 100644 --- a/ios/Classes/Api/MOB_addWebExtentionApi.m +++ b/ios/Classes/Api/MOP_addWebExtentionApi.m @@ -5,11 +5,11 @@ // Created by 王滔 on 2021/12/21. // -#import "MOB_addWebExtentionApi.h" +#import "MOP_addWebExtentionApi.h" #import "MopPlugin.h" #import -@implementation MOB_addWebExtentionApi +@implementation MOP_addWebExtentionApi - (void)setupApiWithSuccess:(void (^)(NSDictionary * _Nonnull))success failure:(void (^)(id _Nullable))failure cancel:(void (^)(void))cancel { diff --git a/ios/Classes/Api/MOP_changeUserId.h b/ios/Classes/Api/MOP_changeUserId.h new file mode 100644 index 0000000..d31b845 --- /dev/null +++ b/ios/Classes/Api/MOP_changeUserId.h @@ -0,0 +1,16 @@ +// +// MOP_changeUserId.h +// mop +// +// Created by 滔 on 2023/3/23. +// + +#import "MOPBaseApi.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface MOP_changeUserId : MOPBaseApi +@property (nonatomic, copy) NSString *userId; +@end + +NS_ASSUME_NONNULL_END diff --git a/ios/Classes/Api/MOP_changeUserId.m b/ios/Classes/Api/MOP_changeUserId.m new file mode 100644 index 0000000..c9ab9ef --- /dev/null +++ b/ios/Classes/Api/MOP_changeUserId.m @@ -0,0 +1,17 @@ +// +// MOP_changeUserId.m +// mop +// +// Created by 滔 on 2023/3/23. +// + +#import "MOP_changeUserId.h" +#import + +@implementation MOP_changeUserId +- (void)setupApiWithSuccess:(void (^)(NSDictionary * _Nonnull))success failure:(void (^)(id _Nullable))failure cancel:(void (^)(void))cancel +{ + [FATClient sharedClient].config.currentUserId = self.userId; + success(@{}); +} +@end diff --git a/ios/Classes/Api/MOP_initSDK.m b/ios/Classes/Api/MOP_initSDK.m index 57c0157..9b9a5bc 100644 --- a/ios/Classes/Api/MOP_initSDK.m +++ b/ios/Classes/Api/MOP_initSDK.m @@ -250,10 +250,16 @@ failure(@"初始化失败"); return; } - FATLogLevel logLevel = [self.config[@"logLevel"] integerValue]; - NSString *logDir = self.config[@"logDir"]; -// [[FATExtClient sharedClient] fat_prepareExtensionApis]; - [[FATClient sharedClient].logManager initLogWithLogDir:logDir logLevel:logLevel consoleLog:YES]; + + NSInteger logLevelIntValue = [self.config[@"logLevel"] integerValue]; + if (logLevelIntValue >= 5) { + [[FATClient sharedClient].logManager closeLog]; + } else { + FATLogLevel logLevel = logLevelIntValue; + NSString *logDir = self.config[@"logDir"]; + [[FATClient sharedClient].logManager initLogWithLogDir:logDir logLevel:logLevel consoleLog:YES]; + } + [[FATClient sharedClient] setEnableLog:YES]; From d63b37f4e95e8b33a954de61e6c99ccbbcc00b90 Mon Sep 17 00:00:00 2001 From: wangtao Date: Thu, 23 Mar 2023 14:23:22 +0800 Subject: [PATCH 14/17] =?UTF-8?q?fix:=20=E6=97=A5=E5=BF=97=E6=9E=9A?= =?UTF-8?q?=E4=B8=BE=E5=80=BC=E9=A1=BA=E5=BA=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/mop.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/mop.dart b/lib/mop.dart index a62cd0e..aeb3726 100644 --- a/lib/mop.dart +++ b/lib/mop.dart @@ -846,11 +846,11 @@ enum BOOLState { } enum LogLevel { - LEVEL_VERBOSE, - LEVEL_DEBUG, - LEVEL_INFO, - LEVEL_WARNING, - LEVEL_ERROR, + LEVEL_ERROR, // 设置为该等级,将会记录ERROR级别的日志 + LEVEL_WARNING, // 设置为该等级,将会记录ERROR和WARNING级别的日志 + LEVEL_INFO, // 设置为该等级,将会记录ERROR、WARNING和INFO级别的日志 + LEVEL_DEBUG, // 设置为该等级,将会记录ERROR、WARING、INFO和DEBUG级别的日志 + LEVEL_VERBOSE, // 设置为该等级,将会记录ERROR、WARING、INFO、DEBUG和VERBOSE级别的日志 LEVEL_NONE } From a91cfc31ba74b5b29ccb0086c45cf63190a0863b Mon Sep 17 00:00:00 2001 From: zhongweiguang Date: Fri, 24 Mar 2023 10:43:57 +0800 Subject: [PATCH 15/17] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/mop.dart | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/mop.dart b/lib/mop.dart index 9147afa..6cf813e 100644 --- a/lib/mop.dart +++ b/lib/mop.dart @@ -285,10 +285,10 @@ class UIConfig { /// 隐藏...弹出菜单中的 【返回首页】 菜单 bool isHideBackHome = false; - /// 隐藏...弹出菜单中的 【转发】 的菜单,默认为false + /// 隐藏...弹出菜单中的 【转发】 菜单,默认为false bool isHideForwardMenu = false; - /// 隐藏...弹出菜单中的 【分享】 的菜单,默认为true + /// 隐藏...弹出菜单中的 【分享】 菜单,默认为true bool isHideShareAppletMenu = true; /// 隐藏...弹出菜单中的 【添加到桌面】 菜单 @@ -1113,20 +1113,20 @@ class Mop { _appletHandlerApis["getUserInfo"] = (params) { return handler.getUserInfo(); }; - // _appletHandlerApis["getCustomMenus"] = (params) async { - // final res = await handler.getCustomMenus(params["appId"]); - // List> list = []; - // res.forEach((element) { - // Map map = Map(); - // map["menuId"] = element.menuId; - // map["image"] = element.image; - // map["title"] = element.title; - // map["type"] = element.type; - // list.add(map); - // }); - // debugPrint("registerAppletHandler getCustomMenus list $list"); - // return list; - // }; + _appletHandlerApis["getCustomMenus"] = (params) async { + final res = await handler.getCustomMenus(params["appId"]); + List> list = []; + res.forEach((element) { + Map map = Map(); + map["menuId"] = element.menuId; + map["image"] = element.image; + map["title"] = element.title; + map["type"] = element.type; + list.add(map); + }); + debugPrint("registerAppletHandler getCustomMenus list $list"); + return list; + }; _appletHandlerApis["onCustomMenuClick"] = (params) async { return handler.onCustomMenuClick( params["appId"], From 1780804df2d9a4dc072b5cc74089230fe7c9d1f7 Mon Sep 17 00:00:00 2001 From: wangtao Date: Fri, 24 Mar 2023 10:46:28 +0800 Subject: [PATCH 16/17] =?UTF-8?q?feat=EF=BC=9A=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=9A=90=E8=97=8F=E6=9B=B4=E5=A4=9A=E8=8F=9C=E5=8D=95=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=20=E6=94=B6=E8=97=8F=E5=92=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=88=B0=E6=A1=8C=E9=9D=A2=E7=9A=84=E6=8C=89=E9=92=AE=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Classes/Api/MOP_initSDK.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ios/Classes/Api/MOP_initSDK.m b/ios/Classes/Api/MOP_initSDK.m index 9b9a5bc..27c89cb 100644 --- a/ios/Classes/Api/MOP_initSDK.m +++ b/ios/Classes/Api/MOP_initSDK.m @@ -102,6 +102,8 @@ uiconfig.hideForwardMenu = [_uiConfig[@"isHideForwardMenu"] boolValue]; uiconfig.autoAdaptDarkMode = [_uiConfig[@"autoAdaptDarkMode"] boolValue]; uiconfig.hideSettingMenu = [_uiConfig[@"isHideSettingMenu"] boolValue]; + uiconfig.hideFavoriteMenu = [_uiConfig[@"isHideFavoriteMenu"] boolValue]; + uiconfig.hideAddToDesktopMenu = [_uiConfig[@"isHideAddToDesktopMenu"] boolValue]; uiconfig.appletText = _uiConfig[@"appletText"]; uiconfig.disableSlideCloseAppletGesture = [_uiConfig[@"disableSlideCloseAppletGesture"] boolValue]; From 368b7d843a2b198cc185286ff1b74f80bf669d91 Mon Sep 17 00:00:00 2001 From: zhongweiguang Date: Fri, 24 Mar 2023 10:57:54 +0800 Subject: [PATCH 17/17] =?UTF-8?q?android:=20=E6=96=B0=E5=A2=9EisHideAddToD?= =?UTF-8?q?esktopMenu=E3=80=81isHideFavoriteMenu=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/finogeeks/mop/api/mop/util/InitUtils.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/util/InitUtils.java b/android/src/main/java/com/finogeeks/mop/api/mop/util/InitUtils.java index 9bec726..2c104de 100644 --- a/android/src/main/java/com/finogeeks/mop/api/mop/util/InitUtils.java +++ b/android/src/main/java/com/finogeeks/mop/api/mop/util/InitUtils.java @@ -20,6 +20,8 @@ public class InitUtils { uiConfig.setHideForwardMenu((Boolean) map.get("isHideForwardMenu")); uiConfig.setHideRefreshMenu((Boolean) map.get("isHideRefreshMenu")); uiConfig.setHideShareAppletMenu((Boolean) map.get("isHideShareAppletMenu")); + uiConfig.setHideAddToDesktopMenu((Boolean) map.get("isHideAddToDesktopMenu")); + uiConfig.setHideFavoriteMenu((Boolean) map.get("isHideFavoriteMenu")); uiConfig.setHideSettingMenu((Boolean) map.get("isHideSettingMenu")); uiConfig.setHideTransitionCloseButton((Boolean) map.get("hideTransitionCloseButton")); Map capsuleConfigMap = (Map) map.get("capsuleConfig");