feat:添加新的初始化方法,增加config和uiconfig参数

master
wangtao 2023-03-19 11:51:51 +08:00
parent ce244c0623
commit d86d2e232b
4 changed files with 756 additions and 2 deletions

View File

@ -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"];

View File

@ -0,0 +1,18 @@
//
// Mop_newInitialize.h
// mop
//
// Created by on 2023/3/17.
//
#import <UIKit/UIKit.h>
#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

View File

@ -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<NSString *,id> * _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

View File

@ -51,9 +51,198 @@ class FinStoreConfig {
}
}
class FATConfig {
/**
id->->id
userId
//退
userId
*/
String? currentUserId;
/**
finclipfinogeeksuserAgentfinogeeks
*/
String? productIdentification;
/**
SDK
trueSDK使api
*/
bool disableAuthorize = false;
/**
true
*/
bool appletAutoAuthorize = false;
/**
SDKAPIfalse
trueSDKAPI
*/
bool disableGetSuperviseInfo = false;
/**
webviewfalse,
trueHttps
*/
bool ignoreWebviewCertAuth = false;
/**
SDKwifi使x
0~5003
*/
int appletIntervalUpdateLimit = 3;
/**
apm
*/
Map<String,String>? apmExtension;
/** Crashfalse(iOS)
UnrecognizedSelectorKVONotificationTimerContainer(nil)String (nil)
便
*/
bool startCrashProtection = false;
Map? theme;
/**
*
* false
*/
bool enableApmDataCompression = false;
/**
使
YES
*/
bool encryptServerData = false;
/**
debug
FATBOOLStateUndefinedapp.json debug:true vconsole
FATBOOLStateTruevconsole
FATBOOLStateFalse
FATBOOLStateForbiddenvconsoleapi
*/
@property (nonatomic, assign) FATBOOLState enableAppletDebug;
/**
*/
bool enableWatermark = false;
/**
*/
ConfigPriority watermarkPriority = ConfigPriority.ConfigGlobalPriority;
/**
FATBaseLoadingView
swiftSwiftDemo.FCloadingViewSwiftDemoFCloadingView
*/
String? baseLoadingViewClass;
/**
FATBaseLoadFailedView
swiftSwiftDemo.FCloadingViewSwiftDemoFCloadingView
*/
String? baseLoadFailedViewClass;
/**
header
apikey
ft.requestft.downloadFileft.uploadFile
*/
Map<String,dynamic>? header;
/**
header
*/
ConfigPriority headerPriority = ConfigPriority.ConfigGlobalPriority;
/**
H5hook
宿app http httpsH5request bodySDKhook request
body宿App宿Apprequestbody
URLProtocolbody
*/
bool enableH5AjaxHook = false;
/**
enableH5AjaxHookhook requestrequest url FinClipHookBridge-RequestId=xxx
Key FinClip-RequestIdFinClip-RequestId=xxx
*/
String? h5AjaxHookRequestKey;
/**
0
55navigateTo 4
*/
int pageCountLimit = 0;
/**
scheme
*/
List<String> schemes = [];
Map<String, dynamic> 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<String, dynamic>? 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;
/// ServiceSDK
bool hideTransitionCloseButton = false;
@ -78,21 +279,57 @@ class UIConfig {
///
CapsuleConfig? capsuleConfig;
//
NavHomeConfig? navHomeConfig;
FloatWindowConfig? floatWindowConfig;
//UI
AuthViewConfig? authViewConfig;
//iOS
//H5 0xFFFFAA00
int? progressBarColor;
//H5false
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<String, dynamic> 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<String, dynamic> toMap() {
return {
"width": width,
"height": height,
"leftMargin": leftMargin,
"cornerRadius": cornerRadius,
"borderWidth": borderWidth,
"borderLightColor": borderLightColor,
"borderDarkColor": borderDarkColor,
"bgLightColor": bgLightColor,
"bgDarkColor": bgDarkColor,
};
}
}
class AuthViewConfig {
/**
PingFangSC-Regular16
*/
int appletNameFont;
/**
#202020
*/
int appletNameLightColor;
/**
#D0D0D0
*/
int appletNameDarkColor;
/**
icon22pt@2× @3×
*/
int agreementLightImage;
/**
icon22pt@2× @3×
*/
int agreementDarkImage;
/**
PingFangSC-Medium17
使PingFangSC-Regular
*/
int authorizeTitleFont;
/**
#202020
使
*/
int authorizeTitleLightColor;
/**
#D0D0D0
使
*/
int authorizeTitleDarkColor;
/**
PingFangSC-Regular14
*/
int authorizeDescriptionFont;
/**
#666666
*/
int authorizeDescriptionLightColor;
/**
#8C8C8C
*/
int authorizeDescriptionDarkColor;
/**
PingFangSC-Regular16
*/
int agreementTitleFont;
/**
#202020
*/
int agreementTitleLightColor;
/**
#D0D0D0
*/
int agreementTitleDarkColor;
/**
PingFangSC-Regular14
*/
int agreementDescriptionFont;
/**
#202020
*/
int agreementDescriptionLightColor;
/**
#D0D0D0
*/
int agreementDescriptionDarkColor;
/**
icon22pt@2× @3×
*/
int authorizeSelectedLightImage;
/**
icon22pt@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<String, dynamic> 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<String, dynamic> 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<Map> newInitialize(
FATConfig config,
{
UIConfig? uiConfig
}
}) async {
List<Map<String, dynamic>>? 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.