From 3791672084d09463495e41e959f3e2b9f82c0c74 Mon Sep 17 00:00:00 2001 From: Sean Date: Wed, 13 Mar 2024 17:25:01 +0800 Subject: [PATCH] =?UTF-8?q?sdk=20=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/build.gradle | 4 +- .../finogeeks/mop/api/mop/AppletModule.java | 39 +++++++- .../mop/api/mop/ExtensionApiModule.java | 14 +-- .../finogeeks/mop/api/mop/InitSDKModule.java | 6 ++ .../finogeeks/mop/api/mop/util/InitUtils.java | 1 + ios/Classes/Api/MOPAppletDelegate.m | 54 +++-------- ios/Classes/Api/MOP_initSDK.m | 6 +- ios/Classes/Api/MOP_initialize.m | 5 +- ios/mop.podspec | 5 +- ios/mop.podspec.tpl | 3 +- lib/mop.dart | 96 ++++++++++++------- pubspec.yaml | 2 +- 12 files changed, 131 insertions(+), 104 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 4d05b42..cc5d53b 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.42.13' - implementation 'com.finogeeks.mop:plugins:2.42.13' + implementation 'com.finogeeks.lib:finapplet:2.43.5' + implementation 'com.finogeeks.mop:plugins:2.43.5' } \ No newline at end of file diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/AppletModule.java b/android/src/main/java/com/finogeeks/mop/api/mop/AppletModule.java index 830e62d..a5350f1 100644 --- a/android/src/main/java/com/finogeeks/mop/api/mop/AppletModule.java +++ b/android/src/main/java/com/finogeeks/mop/api/mop/AppletModule.java @@ -64,12 +64,19 @@ public class AppletModule extends BaseApi { Map params = (Map) param.get("params"); String apiServer = (String) param.get("apiServer"); Boolean isSingleProcess = (Boolean) param.get("isSingleProcess"); + Boolean isSingTask = (Boolean) param.get("isSingTask"); IFinAppletRequest.ProcessMode processMode; if (Boolean.TRUE.equals(isSingleProcess)) { processMode = IFinAppletRequest.ProcessMode.SINGLE; } else { processMode = IFinAppletRequest.ProcessMode.MULTI; } + IFinAppletRequest.TaskMode taskMode; + if (Boolean.TRUE.equals(isSingTask)) { + taskMode = IFinAppletRequest.TaskMode.SINGLE; + } else { + taskMode = IFinAppletRequest.TaskMode.MULTI; + } // mContext是FlutterActivity, // 在Android 6.0、7.0系统的部分设备中热启动小程序时,如果context参数用mContext,会出现无法启动小程序的问题 // 所以这里使用Application Context @@ -82,7 +89,9 @@ public class AppletModule extends BaseApi { IFinAppletRequest.Companion.fromAppId(apiServer, appId) .setStartParams(startParams) .setSequence(sequence) - .setProcessMode(processMode), + .setProcessMode(processMode) + .setTaskMode(taskMode) + , null ); // FinAppClient.INSTANCE.getAppletApiManager().startApplet(context, apiServer, appId, sequence, startParams,null); @@ -154,12 +163,19 @@ public class AppletModule extends BaseApi { String offlineMiniprogramZipPath = (String) param.get("offlineMiniprogramZipPath"); String offlineFrameworkZipPath = (String) param.get("offlineFrameworkZipPath"); Boolean isSingleProcess = (Boolean) param.get("isSingleProcess"); + Boolean isSingTask = (Boolean) param.get("isSingTask"); IFinAppletRequest.ProcessMode processMode; if (Boolean.TRUE.equals(isSingleProcess)) { processMode = IFinAppletRequest.ProcessMode.SINGLE; } else { processMode = IFinAppletRequest.ProcessMode.MULTI; } + IFinAppletRequest.TaskMode taskMode; + if (Boolean.TRUE.equals(isSingTask)) { + taskMode = IFinAppletRequest.TaskMode.SINGLE; + } else { + taskMode = IFinAppletRequest.TaskMode.MULTI; + } Log.d("MopPlugin", "startApplet (appId=" + appId + ", sequence=" + sequence + ", apiServer=" + apiServer + ", isSingleProcess:" + isSingleProcess); // mContext是FlutterActivity, @@ -175,7 +191,8 @@ public class AppletModule extends BaseApi { .setSequence(sequence) .setStartParams(params) .setOfflineParams(offlineFrameworkZipPath, offlineMiniprogramZipPath) - .setProcessMode(processMode), + .setProcessMode(processMode) + .setTaskMode(taskMode), null); // 改成通过request来启动小程序 // FinAppClient.INSTANCE.getAppletApiManager().startApplet(context, IFinAppletRequest.Companion.fromAppId("apiServer", "appId") @@ -186,14 +203,21 @@ public class AppletModule extends BaseApi { private void scanOpenApplet(Map param, ICallback callback) { String info = String.valueOf(param.get("info")); Boolean isSingleProcess = (Boolean) param.get("isSingleProcess"); + Boolean isSingTask = (Boolean) param.get("isSingTask"); IFinAppletRequest.ProcessMode processMode; if (Boolean.TRUE.equals(isSingleProcess)) { processMode = IFinAppletRequest.ProcessMode.SINGLE; } else { processMode = IFinAppletRequest.ProcessMode.MULTI; } + IFinAppletRequest.TaskMode taskMode; + if (Boolean.TRUE.equals(isSingTask)) { + taskMode = IFinAppletRequest.TaskMode.SINGLE; + } else { + taskMode = IFinAppletRequest.TaskMode.MULTI; + } FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, IFinAppletRequest.Companion.fromDecrypt(info) - .setProcessMode(processMode), null); + .setProcessMode(processMode).setTaskMode(taskMode), null); // FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, new StartAppletDecryptRequest(info),null); callback.onSuccess(new HashMap()); } @@ -201,14 +225,21 @@ public class AppletModule extends BaseApi { private void qrcodeOpenApplet(Map param, ICallback callback) { String qrcode = String.valueOf(param.get("qrcode")); Boolean isSingleProcess = (Boolean) param.get("isSingleProcess"); + Boolean isSingTask = (Boolean) param.get("isSingTask"); IFinAppletRequest.ProcessMode processMode; if (Boolean.TRUE.equals(isSingleProcess)) { processMode = IFinAppletRequest.ProcessMode.SINGLE; } else { processMode = IFinAppletRequest.ProcessMode.MULTI; } + IFinAppletRequest.TaskMode taskMode; + if (Boolean.TRUE.equals(isSingTask)) { + taskMode = IFinAppletRequest.TaskMode.SINGLE; + } else { + taskMode = IFinAppletRequest.TaskMode.MULTI; + } FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, IFinAppletRequest.Companion.fromQrCode(qrcode) - .setProcessMode(processMode), new FinCallback() { + .setProcessMode(processMode).setTaskMode(taskMode), new FinCallback() { @Override public void onSuccess(String s) { callback.onSuccess(new HashMap()); diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/ExtensionApiModule.java b/android/src/main/java/com/finogeeks/mop/api/mop/ExtensionApiModule.java index bd03f09..0298c20 100644 --- a/android/src/main/java/com/finogeeks/mop/api/mop/ExtensionApiModule.java +++ b/android/src/main/java/com/finogeeks/mop/api/mop/ExtensionApiModule.java @@ -25,30 +25,24 @@ public class ExtensionApiModule extends BaseApi { private static final String TAG = "ExtensionApiModule"; - private final Context cur; - private Handler handler = new Handler(Looper.getMainLooper()); public ExtensionApiModule(Context context) { super(context); - cur = context; - } @Override public String[] apis() { - return new String[]{"registerExtensionApi", "registerSyncExtensionApi", "addWebExtentionApi"}; + return new String[]{"registerExtensionApi","registerSyncExtensionApi","addWebExtentionApi"}; } @Override public void invoke(String s, Map param, ICallback iCallback) { - boolean isFinAppProcess = FinAppClient.INSTANCE.isFinAppProcess(cur); - Log.d(TAG, "ExtensionApiModule invoke register api s:" + s + " param:" + param +" isFinAppProcess:"+isFinAppProcess); if(s.equals("registerExtensionApi")) { MethodChannel channel = MopPluginService.getInstance().getMethodChannel(); String name = (String) param.get("name"); Log.d(TAG, "registerExtensionApi:" + name); - FinAppClient.INSTANCE.getExtensionApiManager().registerApi(new com.finogeeks.lib.applet.api.BaseApi(cur) { + FinAppClient.INSTANCE.getExtensionApiManager().registerApi(new com.finogeeks.lib.applet.api.BaseApi(getContext()) { @Override public String[] apis() { return new String[]{name}; @@ -56,7 +50,7 @@ public class ExtensionApiModule extends BaseApi { @Override public void invoke(String s, JSONObject jsonObject, com.finogeeks.lib.applet.interfaces.ICallback iCallback) { - Log.d("MopPlugin", "invoke extensionApi:" + s + ",params:" + jsonObject+" isFinAppProcess:"+isFinAppProcess); + Log.d("MopPlugin", "invoke extensionApi:" + s + ",params:" + jsonObject); Map params = GsonUtil.gson.fromJson(jsonObject.toString(), HashMap.class); handler.post(() -> { channel.invokeMethod("extensionApi:" + name, params, new MethodChannel.Result() { @@ -162,7 +156,7 @@ public class ExtensionApiModule extends BaseApi { MethodChannel channel = MopPluginService.getInstance().getMethodChannel(); String name = (String) param.get("name"); Log.d(TAG, "addWebExtentionApi:" + name); - FinAppClient.INSTANCE.getExtensionWebApiManager().registerApi(new com.finogeeks.lib.applet.api.BaseApi(cur) { + FinAppClient.INSTANCE.getExtensionWebApiManager().registerApi(new com.finogeeks.lib.applet.api.BaseApi(getContext()) { @Override public String[] apis() { return new String[]{name}; 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 5dc64c3..7ebe41a 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 @@ -138,6 +138,12 @@ public class InitSDKModule extends BaseApi { if (maxRunningApplet != null) { configBuilder.setMaxRunningApplet(maxRunningApplet); } + + Integer backgroundFetchPeriod = (Integer) configMap.get("backgroundFetchPeriod"); + if (backgroundFetchPeriod != null) { + configBuilder.setBackgroundFetchPeriod(backgroundFetchPeriod); + } + Integer webViewMixedContentMode = (Integer) configMap.get("webViewMixedContentMode"); if (webViewMixedContentMode != null) { configBuilder.setWebViewMixedContentMode(webViewMixedContentMode); 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 ba2e082..f04c29a 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 @@ -39,6 +39,7 @@ public class InitUtils { uiConfig.setHideShareAppletMenu((Boolean) map.get("isHideShareAppletMenu")); uiConfig.setHideAddToDesktopMenu((Boolean) map.get("isHideAddToDesktopMenu")); uiConfig.setHideFavoriteMenu((Boolean) map.get("isHideFavoriteMenu")); + uiConfig.setHideClearCacheMenu((Boolean) map.get("isHideClearCacheMenu")); uiConfig.setHideSettingMenu((Boolean) map.get("isHideSettingMenu")); uiConfig.setHideTransitionCloseButton((Boolean) map.get("hideTransitionCloseButton")); uiConfig.setUseNativeLiveComponent((Boolean) map.get("useNativeLiveComponent")); diff --git a/ios/Classes/Api/MOPAppletDelegate.m b/ios/Classes/Api/MOPAppletDelegate.m index 9245269..71f72a8 100644 --- a/ios/Classes/Api/MOPAppletDelegate.m +++ b/ios/Classes/Api/MOPAppletDelegate.m @@ -37,46 +37,26 @@ if([result isKindOfClass:[FlutterError class]]|| [result isKindOfClass:[FlutterMethodNotImplemented class] ]) { completion(FATExtensionCodeFailure,nil); - }else - { + } else { completion(FATExtensionCodeSuccess,result); } }]; } -- (NSDictionary *)getUserInfoWithAppletInfo:(FATAppletInfo *)appletInfo { - NSLog(@"getUserInfoWithAppletInfo"); - __block NSDictionary *userInfo; - CFRunLoopRef runLoop = CFRunLoopGetCurrent(); - - FlutterMethodChannel *channel = [[MopPlugin instance] methodChannel]; - [channel invokeMethod:@"extensionApi:getUserInfo" arguments:nil result:^(id _Nullable result) { - userInfo = result; - CFRunLoopStop(runLoop); - }]; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - CFRunLoopStop(runLoop); - }); - CFRunLoopRun(); - return userInfo; -} - - (BOOL)appletInfo:(FATAppletInfo *)appletInfo didClickMoreBtnAtPath:(NSString *)path { __block BOOL flag; CFRunLoopRef runLoop = CFRunLoopGetCurrent(); FlutterMethodChannel *channel = [[MopPlugin instance] methodChannel]; - NSLog(@"appletInfo:didClickMoreBtnAtPath,appId=%@,path=%@,channel=%@",appletInfo.appId,path,channel); [channel invokeMethod:@"extensionApi:customCapsuleMoreButtonClick" arguments:@{@"appId": appletInfo.appId} result:^(id _Nullable result) { if ([result isKindOfClass:[NSNumber class]]) { flag = [result boolValue]; } CFRunLoopStop(runLoop); }]; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ CFRunLoopStop(runLoop); }); - CFRunLoopRun(); return flag; } @@ -89,17 +69,14 @@ [channel invokeMethod:@"extensionApi:getCustomMenus" arguments:@{@"appId": appletInfo.appId} result:^(id _Nullable result) { if ([result isKindOfClass:[NSArray class]]) { list = result; - NSLog(@"customMenusInApplet2222:list=%@",list); } CFRunLoopStop(runLoop); }]; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ CFRunLoopStop(runLoop); }); - CFRunLoopRun(); - NSLog(@"customMenusInApplet:%@,list=%@",path,list); - + NSMutableArray *models = [NSMutableArray array]; for (NSDictionary *data in list) { MopCustomMenuModel *model = [[MopCustomMenuModel alloc] init]; @@ -125,13 +102,11 @@ } [models addObject:model]; } - + return models; } - - (void)clickCustomItemMenuWithInfo:(NSDictionary *)contentInfo inApplet:(FATAppletInfo *)appletInfo completion:(void (^)(FATExtensionCode code, NSDictionary *result))completion { - NSLog(@"HJH1,clickCustomItemMenuWithInfo"); NSError *parseError = nil; NSMutableDictionary *shareDic = [[NSMutableDictionary alloc] initWithDictionary:[self dictionaryRepresentation:appletInfo]]; [shareDic setValue:@{@"desc" : shareDic[@"originalInfo"][@"customData"][@"detailDescription"]} forKey:@"params"]; @@ -139,20 +114,19 @@ NSData *jsonData = [NSJSONSerialization dataWithJSONObject:shareDic options:NSJSONWritingPrettyPrinted error:&parseError]; NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; NSDictionary *arguments = @{ - @"appId": contentInfo[@"appId"], - @"path": contentInfo[@"path"], - @"menuId": contentInfo[@"menuId"], - @"appInfo": jsonString + @"appId": contentInfo[@"appId"], + @"path": contentInfo[@"path"], + @"menuId": contentInfo[@"menuId"], + @"appInfo": jsonString }; FlutterMethodChannel *channel = [[MopPlugin instance] methodChannel]; [channel invokeMethod:@"extensionApi:onCustomMenuClick" arguments:arguments result:^(id _Nullable result) { - + }]; - + if ([@"Desktop" isEqualToString:contentInfo[@"menuId"]]) { [self addToDesktopItemClick:appletInfo path:contentInfo[@"path"]]; } - NSLog(@"HJH2,clickCustomItemMenuWithInfo"); } - (NSDictionary *)dictionaryRepresentation:(FATAppletInfo *)object { @@ -177,7 +151,7 @@ NSDictionary *params = @{@"appId":appletId}; FlutterMethodChannel *channel = [[MopPlugin instance] methodChannel]; [channel invokeMethod:@"extensionApi:appletDidOpen" arguments:params result:^(id _Nullable result) { - + }]; } @@ -196,9 +170,9 @@ static NSString *scheme = @"fatae55433be2f62915";//App对应的scheme [url appendFormat:@"?iconpath=%@", appInfo.appAvatar]; [url appendFormat:@"&apptitle=%@", appInfo.appTitle.fat_encodeString]; [url appendFormat:@"&linkhref=%@", herf]; - + NSLog(@"跳转到中间页面:%@", url); - + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]]; } diff --git a/ios/Classes/Api/MOP_initSDK.m b/ios/Classes/Api/MOP_initSDK.m index 9f4965a..dd8857d 100644 --- a/ios/Classes/Api/MOP_initSDK.m +++ b/ios/Classes/Api/MOP_initSDK.m @@ -7,8 +7,6 @@ #import "Mop_initSDK.h" #import "MOPTools.h" -#import "FinAppletExt.h" - @implementation MOP_initSDK @@ -70,6 +68,9 @@ config.schemes = self.config[@"schemes"]; config.webViewInspectable = [self.config[@"debug"] boolValue]; NSInteger languageInteger = [self.config[@"language"] integerValue]; + if (self.config[@"backgroundFetchPeriod"]) { + config.backgroundFetchPeriod = [self.config[@"backgroundFetchPeriod"] integerValue]; + } if (languageInteger == 1) { config.language = FATPreferredLanguageEnglish; } else { @@ -110,6 +111,7 @@ uiconfig.hideRefreshMenu = [_uiConfig[@"isHideRefreshMenu"] boolValue]; uiconfig.hideFavoriteMenu = [_uiConfig[@"isHideFavoriteMenu"] boolValue]; uiconfig.hideAddToDesktopMenu = [_uiConfig[@"isHideAddToDesktopMenu"] boolValue]; + uiconfig.hideClearCacheMenu = [_uiConfig[@"isHideClearCacheMenu"] boolValue]; // 胶囊配置 if (_uiConfig[@"capsuleConfig"]) { diff --git a/ios/Classes/Api/MOP_initialize.m b/ios/Classes/Api/MOP_initialize.m index e8fe5f8..7293c4c 100644 --- a/ios/Classes/Api/MOP_initialize.m +++ b/ios/Classes/Api/MOP_initialize.m @@ -7,7 +7,7 @@ #import "MOP_initialize.h" #import -#import "FinAppletExt.h" +#import #import #import "MOPTools.h" @@ -127,9 +127,6 @@ // [[FATExtClient sharedClient] fat_prepareExtensionApis]; [[FATClient sharedClient].logManager initLogWithLogDir:nil logLevel:FATLogLevelVerbose consoleLog:YES]; - - [[FATClient sharedClient] setEnableLog:YES]; - success(@{}); diff --git a/ios/mop.podspec b/ios/mop.podspec index cd5c7c6..be499bd 100644 --- a/ios/mop.podspec +++ b/ios/mop.podspec @@ -21,9 +21,8 @@ A finclip miniprogram flutter sdk. s.vendored_libraries = 'Classes/FinAppletExt/Vendor/Lame/libmp3lame.a' s.static_framework = true - s.dependency 'FinApplet' , '2.43.0-dev20230103v05' - s.dependency 'FinAppletExt' , '2.43.0-dev20230103v05' + s.dependency 'FinApplet' , '2.43.5' + s.dependency 'FinAppletExt' , '2.43.5' s.dependency 'FinAppletBLE' , '2.43.0-dev20230103v05' - end diff --git a/ios/mop.podspec.tpl b/ios/mop.podspec.tpl index 29605f6..9f65269 100644 --- a/ios/mop.podspec.tpl +++ b/ios/mop.podspec.tpl @@ -22,8 +22,7 @@ A finclip miniprogram flutter sdk. s.static_framework = true s.dependency 'FinApplet' , '__finapplet_version__' -# s.dependency 'FinAppletExt' , '__finapplet_version__' s.dependency 'FinAppletBLE' - + s.dependency 'FinAppletExt' , '__finapplet_version__' end diff --git a/lib/mop.dart b/lib/mop.dart index 4d6c194..ae6cb48 100644 --- a/lib/mop.dart +++ b/lib/mop.dart @@ -46,8 +46,8 @@ class FinStoreConfig { this.cryptType = "MD5", this.fingerprint, this.encryptServerData = false, - this.enablePreloadFramework = false, - this.googleMapApiKey = ''}); + this.enablePreloadFramework = true, + this.googleMapApiKey = ''}); Map toMap() { return { @@ -166,7 +166,6 @@ class Config { /// 自定义的scheme数组 List? schemes; - /// Android属性 /// 设置debug模式,影响调试和日志。 bool debug = false; @@ -201,7 +200,6 @@ class Config { /// 日志记录等级 LogLevel logLevel = LogLevel.LEVEL_NONE; - /// Android属性 /// 日志文件最长缓存时间,单位秒。 /// 最小不能小于1天,即不能小于 1 * 24 * 60 * 60 秒。 int? logMaxAliveSec; @@ -241,6 +239,9 @@ class Config { /// 是否开启j2v8 bool enableJ2V8 = false; + /// 周期性更新的时间间隔(小时), 设置为0不会发起周期性更新请求,接收设置范围为3-12小时 + int backgroundFetchPeriod = 12; + Config(this.finStoreConfigs); Map toMap() { @@ -282,11 +283,12 @@ class Config { "logMaxAliveSec": logMaxAliveSec, "logDir": logDir, "enablePreNewProcess": enablePreNewProcess, - "language":language.index, + "language": language.index, "useLocalTbsCore": useLocalTbsCore, "tbsCoreUrl": tbsCoreUrl, "enableJ2V8": enableJ2V8, "customLanguagePath": customLanguagePath, + "backgroundFetchPeriod": backgroundFetchPeriod, "localeLanguage": localeLanguage, }; } @@ -342,12 +344,15 @@ class UIConfig { /// 隐藏...弹出菜单中的 【收藏】 菜单 bool isHideFavoriteMenu = true; - // 隐藏...弹出菜单中的 【重新进入小程序】 菜单,默认为false + /// 隐藏...弹出菜单中的 【重新进入小程序】 菜单,默认为false bool isHideRefreshMenu = false; - // 隐藏...弹出菜单中的 【设置】 菜单,默认为false + /// 隐藏...弹出菜单中的 【设置】 菜单,默认为false bool isHideSettingMenu = false; + /// 隐藏...弹出菜单中的 【清理缓存】 菜单,默认为false + bool isHideClearCacheMenu = false; + /// 胶囊按钮配置 CapsuleConfig? capsuleConfig; @@ -369,7 +374,7 @@ class UIConfig { // 是否自适应暗黑模式。如果设置为true,则更多页面、关于等原生页面会随着手机切换暗黑,也自动调整为暗黑模式 bool autoAdaptDarkMode = false; - // 是否使用内置的live组件,默认为false。(目前仅iOS支持) + // 是否使用内置的live组件,默认为false。 // 配置为true时,需要依赖Live扩展SDK。 bool useNativeLiveComponent = false; @@ -421,6 +426,7 @@ class UIConfig { "isHideSettingMenu": isHideSettingMenu, "isHideAddToDesktopMenu": isHideAddToDesktopMenu, "isHideFavoriteMenu": isHideFavoriteMenu, + "isHideClearCacheMenu": isHideClearCacheMenu, "hideTransitionCloseButton": hideTransitionCloseButton, "capsuleConfig": capsuleConfig?.toMap(), "navHomeConfig": navHomeConfig?.toMap(), @@ -787,12 +793,16 @@ class BaseAppletRequest { // 是否以单进程模式运行,仅限android,默认为false bool isSingleProcess; + // 是否以单任务模式运行,仅限android,默认为false + bool isSingTask; + BaseAppletRequest({ required this.apiServer, required this.appletId, this.startParams, this.animated = true, this.isSingleProcess = false, + this.isSingTask = false, }); Map toMap() { @@ -802,6 +812,7 @@ class BaseAppletRequest { "startParams": startParams, "animated": animated, "isSingleProcess": isSingleProcess, + "isSingTask": isSingTask, }; } } @@ -835,6 +846,9 @@ class RemoteAppletRequest { // 是否以单进程模式运行,仅限android,默认为false bool isSingleProcess; + // 是否以单任务模式运行,仅限android,默认为false + bool isSingTask; + RemoteAppletRequest({ required this.apiServer, required this.appletId, @@ -845,6 +859,7 @@ class RemoteAppletRequest { this.animated = true, this.transitionStyle = TranstionStyle.TranstionStyleUp, this.isSingleProcess = false, + this.isSingTask = false, }); Map toMap() { @@ -853,7 +868,8 @@ class RemoteAppletRequest { "appletId": appletId, "animated": animated, "isSingleProcess": isSingleProcess, - "transitionStyle":transitionStyle.index, + "isSingTask": isSingTask, + "transitionStyle": transitionStyle.index, }; if (startParams != null) result["startParams"] = startParams; if (offlineMiniprogramZipPath != null) @@ -876,13 +892,18 @@ class QRCodeAppletRequest { // 是否以单进程模式运行,仅限android,默认为false bool isSingleProcess; - QRCodeAppletRequest(this.qrCode, {this.isSingleProcess = false}); + // 是否以单任务模式运行,仅限android,默认为false + bool isSingTask; + + QRCodeAppletRequest(this.qrCode, + {this.isSingleProcess = false, this.isSingTask = false}); Map toMap() { return { "apiServer": qrCode, "animated": animated, "isSingleProcess": isSingleProcess, + "isSingTask": isSingTask, }; } } @@ -915,8 +936,8 @@ enum BOOLState { } enum LanguageType { - Chinese, // 中文 - English, // 英文 + Chinese, // 中文 + English, // 英文 } enum LogLevel { @@ -1020,24 +1041,21 @@ class Mop { /// [customWebViewUserAgent] 设置自定义webview ua /// [appletIntervalUpdateLimit] 设置小程序批量更新周期 /// [maxRunningApplet] 设置最大同时运行小程序个数 - Future initialize( - String sdkkey, - String secret, { - String? apiServer, - String? apiPrefix, - String? cryptType, - bool encryptServerData = false, - bool disablePermission = false, - String? userId, - bool debug = false, - bool bindAppletWithMainProcess = false, - int? pageCountLimit = 0, - List? finStoreConfigs, - UIConfig? uiConfig, - String? customWebViewUserAgent, - int? appletIntervalUpdateLimit, - int? maxRunningApplet - }) async { + Future initialize(String sdkkey, String secret, + {String? apiServer, + String? apiPrefix, + String? cryptType, + bool encryptServerData = false, + bool disablePermission = false, + String? userId, + bool debug = false, + bool bindAppletWithMainProcess = false, + int? pageCountLimit = 0, + List? finStoreConfigs, + UIConfig? uiConfig, + String? customWebViewUserAgent, + int? appletIntervalUpdateLimit, + int? maxRunningApplet}) async { List>? storeConfigs = finStoreConfigs?.map((e) => e.toMap()).toList(); @@ -1077,9 +1095,9 @@ class Mop { /// [query] is miniprogram query parameters. example key1=value1&key2=value2 /// [sequence] is miniprogram sequence. example 0,1.2.3,4,5... /// [apiServer] is optional. the mop server address. default is https://mp.finogeek.com - /// [apiPrefix] is optional. the mop server prefix. default is /api/v1/mop - /// [fingerprint] is optional. the mop sdk fingerprint. is nullable - /// [cryptType] is optional. cryptType, should be MD5/SM + /// [scene] + /// [shareDepth] + /// [isSingleProcess] Future openApplet( final String appId, { final String? path, @@ -1089,6 +1107,7 @@ class Mop { final String? scene, final String? shareDepth, final bool isSingleProcess = false, + final bool isSingTask = false, }) async { Map params = {'appId': appId}; Map param = {}; @@ -1100,6 +1119,7 @@ class Mop { if (scene != null) param["scene"] = scene; if (shareDepth != null) param["shareDepth"] = shareDepth; params["isSingleProcess"] = isSingleProcess; + params["isSingTask"] = isSingTask; final Map ret = await _channel.invokeMethod('openApplet', params); return ret; } @@ -1112,19 +1132,23 @@ class Mop { /// 通过二维码打开小程序 /// [qrcode] 二维码内容 - Future qrcodeOpenApplet(String qrcode, {bool isSingleProcess = false}) async { + Future qrcodeOpenApplet(String qrcode, + {bool isSingleProcess = false, bool isSingTask = false}) async { Map params = { 'qrcode': qrcode, 'isSingleProcess': isSingleProcess, + 'isSingTask': isSingTask, }; return await _channel.invokeMapMethod("qrcodeOpenApplet", params); } /// (扫码后)解密-鉴权-打开小程序 - Future scanOpenApplet(String info, {bool isSingleProcess = false}) async { + Future scanOpenApplet(String info, + {bool isSingleProcess = false, bool isSingTask = false}) async { Map params = { 'info': info, 'isSingleProcess': isSingleProcess, + 'isSingTask': isSingTask, }; return await _channel.invokeMapMethod("scanOpenApplet", params); } @@ -1297,7 +1321,7 @@ class Mop { .invokeMapMethod("sdkVersion") .then((value) => value?["data"]); } - + /// 获取国密加密 Future getSMSign(String plainText) async { var result = diff --git a/pubspec.yaml b/pubspec.yaml index 6371b6b..1bb336b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: mop description: A Finogeeks MiniProgram Flutter SDK. -version: '2.42.13' +version: '2.43.5' homepage: https://github.com/finogeeks/mop-flutter-sdk environment: