From d86d2e232bc9dc87a89d8b00025a7a73d1e745fa Mon Sep 17 00:00:00 2001 From: wangtao Date: Sun, 19 Mar 2023 11:51:51 +0800 Subject: [PATCH] =?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.