Feat/start applet
parent
fc3dd3e550
commit
ed0ba0b3c0
|
@ -91,6 +91,6 @@ kapt {
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
implementation 'com.finogeeks.lib:finapplet:2.37.4-alpha20220727v13'
|
implementation 'com.finogeeks.lib:finapplet:2.37.3'
|
||||||
implementation 'com.finogeeks.mop:plugins:2.37.1'
|
implementation 'com.finogeeks.mop:plugins:2.37.3'
|
||||||
}
|
}
|
|
@ -91,6 +91,7 @@ public class AppletManageModule extends BaseApi {
|
||||||
FinAppClient.INSTANCE.getAppletApiManager().clearApplets();
|
FinAppClient.INSTANCE.getAppletApiManager().clearApplets();
|
||||||
callback.onSuccess(null);
|
callback.onSuccess(null);
|
||||||
} else if (event.equals("removeUsedApplet")) {
|
} else if (event.equals("removeUsedApplet")) {
|
||||||
|
Log.d("MopPlugin", "removeUsedApplet:params:" + param);
|
||||||
if (param.containsKey("appId") && param.get("appId") instanceof String) {
|
if (param.containsKey("appId") && param.get("appId") instanceof String) {
|
||||||
String appId = (String) param.get("appId");
|
String appId = (String) param.get("appId");
|
||||||
FinAppClient.INSTANCE.getAppletApiManager().removeUsedApplet(appId);
|
FinAppClient.INSTANCE.getAppletApiManager().removeUsedApplet(appId);
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class AppletModule extends BaseApi {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] apis() {
|
public String[] apis() {
|
||||||
return new String[]{"openApplet", "scanOpenApplet","qrcodeOpenApplet", "changeUserId"};
|
return new String[]{"openApplet", "scanOpenApplet","qrcodeOpenApplet", "changeUserId", "startApplet"};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -44,6 +44,8 @@ public class AppletModule extends BaseApi {
|
||||||
qrcodeOpenApplet(param,callback);
|
qrcodeOpenApplet(param,callback);
|
||||||
} else if ("changeUserId".equals(event)) {
|
} else if ("changeUserId".equals(event)) {
|
||||||
changeUserId(param, callback);
|
changeUserId(param, callback);
|
||||||
|
} else if ("startApplet".equals(event)) {
|
||||||
|
startApplet(param, callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,6 +120,43 @@ public class AppletModule extends BaseApi {
|
||||||
callback.onSuccess(new HashMap());
|
callback.onSuccess(new HashMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void startApplet(Map param, ICallback callback) {
|
||||||
|
if (param.get("appletId") == null) {
|
||||||
|
callback.onFail(new HashMap() {
|
||||||
|
{
|
||||||
|
put("info", "appId不能为空");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Log.d("MopPlugin", "startApplet:params:" + param);
|
||||||
|
String appId = String.valueOf(param.get("appletId"));
|
||||||
|
Integer sequence = (Integer) param.get("sequence");
|
||||||
|
Map<String, String> params = (Map) param.get("startParams");
|
||||||
|
String apiServer = (String) param.get("apiServer");
|
||||||
|
String offlineMiniprogramZipPath = (String) param.get("offlineMiniprogramZipPath");
|
||||||
|
String offlineFrameworkZipPath = (String) param.get("offlineFrameworkZipPath");
|
||||||
|
Log.d("MopPlugin", "startApplet (appId=" + appId + ", sequence=" + sequence + " apiServer=" + apiServer + ")");
|
||||||
|
// mContext是FlutterActivity,
|
||||||
|
// 在Android 6.0、7.0系统的部分设备中热启动小程序时,如果context参数用mContext,会出现无法启动小程序的问题
|
||||||
|
// 所以这里使用Application Context
|
||||||
|
Context context = mContext.getApplicationContext();
|
||||||
|
// String dir = context.getFilesDir();
|
||||||
|
// FinAppInfo.StartParams startParams = params == null ? null : new FinAppInfo.StartParams(params.get("path"), params.get("query"), params.get("scene"));
|
||||||
|
// Log.d(TAG, "openApplet:" + appId + "," + param + "," + apiServer);
|
||||||
|
|
||||||
|
FinAppClient.INSTANCE.getAppletApiManager().startApplet(context,
|
||||||
|
IFinAppletRequest.Companion.fromAppId(apiServer, appId)
|
||||||
|
.setSequence(sequence)
|
||||||
|
.setStartParams(params)
|
||||||
|
.setOfflineParams(offlineFrameworkZipPath, offlineMiniprogramZipPath),
|
||||||
|
null);
|
||||||
|
// 改成通过request来启动小程序
|
||||||
|
// FinAppClient.INSTANCE.getAppletApiManager().startApplet(context, IFinAppletRequest.Companion.fromAppId("apiServer", "appId")
|
||||||
|
// .setStartParams(params).setOfflinexxxx);
|
||||||
|
callback.onSuccess(new HashMap());
|
||||||
|
}
|
||||||
|
|
||||||
private void scanOpenApplet(Map param, ICallback callback) {
|
private void scanOpenApplet(Map param, ICallback callback) {
|
||||||
String info = String.valueOf(param.get("info"));
|
String info = String.valueOf(param.get("info"));
|
||||||
FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, IFinAppletRequest.Companion.fromDecrypt(info), null);
|
FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, IFinAppletRequest.Companion.fromDecrypt(info), null);
|
||||||
|
|
|
@ -41,5 +41,7 @@
|
||||||
</array>
|
</array>
|
||||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||||
<false/>
|
<false/>
|
||||||
|
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||||
|
<true/>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|
|
@ -42,7 +42,7 @@ packages:
|
||||||
name: collection
|
name: collection
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.15.0"
|
version: "1.16.0"
|
||||||
cupertino_icons:
|
cupertino_icons:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -56,7 +56,7 @@ packages:
|
||||||
name: fake_async
|
name: fake_async
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.3.0"
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
|
@ -95,6 +95,13 @@ packages:
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.11"
|
version: "0.12.11"
|
||||||
|
material_color_utilities:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: material_color_utilities
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "0.1.4"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -108,14 +115,14 @@ packages:
|
||||||
path: ".."
|
path: ".."
|
||||||
relative: true
|
relative: true
|
||||||
source: path
|
source: path
|
||||||
version: "2.36.3"
|
version: "2.37.3"
|
||||||
path:
|
path:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path
|
name: path
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.0"
|
version: "1.8.1"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
|
@ -127,7 +134,7 @@ packages:
|
||||||
name: source_span
|
name: source_span
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.1"
|
version: "1.8.2"
|
||||||
stack_trace:
|
stack_trace:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -162,21 +169,14 @@ packages:
|
||||||
name: test_api
|
name: test_api
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.4.3"
|
version: "0.4.9"
|
||||||
typed_data:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: typed_data
|
|
||||||
url: "https://pub.flutter-io.cn"
|
|
||||||
source: hosted
|
|
||||||
version: "1.3.0"
|
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vector_math
|
name: vector_math
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.1"
|
version: "2.1.2"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.14.0 <3.0.0"
|
dart: ">=2.17.0-0 <3.0.0"
|
||||||
flutter: ">=2.2.3"
|
flutter: ">=2.2.3"
|
||||||
|
|
|
@ -126,7 +126,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// [[FATExtClient sharedClient] fat_prepareExtensionApis];
|
// [[FATExtClient sharedClient] fat_prepareExtensionApis];
|
||||||
|
[[FATClient sharedClient].logManager initLogWithLogDir:nil logLevel:FATLogLevelVerbose consoleLog:YES];
|
||||||
|
|
||||||
|
|
||||||
[[FATClient sharedClient] setEnableLog:YES];
|
[[FATClient sharedClient] setEnableLog:YES];
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
//
|
||||||
|
// MOP_openApplet.h
|
||||||
|
// mop
|
||||||
|
//
|
||||||
|
// Created by 杨涛 on 2020/2/27.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "MOPBaseApi.h"
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@interface MOP_startApplet : MOPBaseApi
|
||||||
|
|
||||||
|
@property (nonatomic, copy) NSString *appletId;
|
||||||
|
@property (nonatomic, copy) NSString *apiServer;
|
||||||
|
@property (nonatomic, copy) NSString *sequence;
|
||||||
|
@property (nonatomic, copy) NSDictionary *startParams;
|
||||||
|
@property (nonatomic, copy) NSString *offlineMiniprogramZipPath;
|
||||||
|
@property (nonatomic, copy) NSString *offlineFrameworkZipPath;
|
||||||
|
@property (nonatomic, strong) NSString *animated;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,40 @@
|
||||||
|
//
|
||||||
|
// MOP_openApplet.m
|
||||||
|
// mop
|
||||||
|
//
|
||||||
|
// Created by 杨涛 on 2020/2/27.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "MOP_startApplet.h"
|
||||||
|
#import "MOPTools.h"
|
||||||
|
#import <FinApplet/FinApplet.h>
|
||||||
|
|
||||||
|
@implementation MOP_startApplet
|
||||||
|
|
||||||
|
- (void)setupApiWithSuccess:(void (^)(NSDictionary<NSString *,id> * _Nonnull))success failure:(void (^)(id _Nullable))failure cancel:(void (^)(void))cancel
|
||||||
|
{
|
||||||
|
UIViewController *currentVC = [MOPTools topViewController];
|
||||||
|
|
||||||
|
FATAppletRequest *request = [[FATAppletRequest alloc] init];
|
||||||
|
request.appletId = self.appletId;
|
||||||
|
request.apiServer = self.apiServer;
|
||||||
|
request.startParams = self.startParams;
|
||||||
|
if (self.sequence){
|
||||||
|
request.sequence = @([self.sequence intValue]);
|
||||||
|
}
|
||||||
|
request.offlineMiniprogramZipPath = self.offlineMiniprogramZipPath;
|
||||||
|
request.offlineFrameworkZipPath = self.offlineFrameworkZipPath;
|
||||||
|
request.animated = [self.animated boolValue];
|
||||||
|
|
||||||
|
// 启动小程序
|
||||||
|
[[FATClient sharedClient] startAppletWithRequest:request InParentViewController:currentVC completion:^(BOOL result, NSError *error) {
|
||||||
|
if (result){
|
||||||
|
success(@{});
|
||||||
|
} else {
|
||||||
|
failure(error.description);
|
||||||
|
}
|
||||||
|
} closeCompletion:^(void) {
|
||||||
|
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
@end
|
|
@ -17,7 +17,7 @@ A finclip miniprogram flutter sdk.
|
||||||
s.dependency 'Flutter'
|
s.dependency 'Flutter'
|
||||||
s.ios.deployment_target = '9.0'
|
s.ios.deployment_target = '9.0'
|
||||||
|
|
||||||
s.dependency 'FinApplet' , '2.37.3'
|
s.dependency 'FinApplet' , '2.37.4-alpha20220729v13'
|
||||||
s.dependency 'FinAppletExt' , '2.37.3'
|
s.dependency 'FinAppletExt' , '2.37.4-alpha20220729v13'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
93
lib/mop.dart
93
lib/mop.dart
|
@ -1,5 +1,4 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:ffi';
|
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
@ -217,6 +216,91 @@ class FloatWindowConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class BaseAppletRequest {
|
||||||
|
// 服务器地址,必填
|
||||||
|
String apiServer;
|
||||||
|
// 小程序id,必填
|
||||||
|
String appletId;
|
||||||
|
// 小程序的启动参数,非必填
|
||||||
|
Map<String, String>? startParams;
|
||||||
|
// iOS端打开小程序时是否显示动画,默认为true。
|
||||||
|
bool? animated;
|
||||||
|
|
||||||
|
BaseAppletRequest({
|
||||||
|
required this.apiServer,
|
||||||
|
required this.appletId,
|
||||||
|
this.startParams,
|
||||||
|
this.animated = true,
|
||||||
|
});
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() {
|
||||||
|
return {
|
||||||
|
"apiServer": apiServer,
|
||||||
|
"appletId": appletId,
|
||||||
|
"startParams": startParams,
|
||||||
|
"animated": animated
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class RemoteAppletRequest {
|
||||||
|
// 服务器地址,必填
|
||||||
|
String apiServer;
|
||||||
|
// 小程序id,必填
|
||||||
|
String appletId;
|
||||||
|
// 小程序的启动参数,非必填
|
||||||
|
Map<String, String>? startParams;
|
||||||
|
// 小程序的索引,(审核小程序时必填)
|
||||||
|
int? sequence;
|
||||||
|
// 离线小程序压缩包路径,非必填
|
||||||
|
String? offlineMiniprogramZipPath;
|
||||||
|
// 离线基础库压缩包路径,非必填
|
||||||
|
String? offlineFrameworkZipPath;
|
||||||
|
// iOS端打开小程序时是否显示动画,默认为true。
|
||||||
|
bool animated;
|
||||||
|
|
||||||
|
RemoteAppletRequest({
|
||||||
|
required this.apiServer,
|
||||||
|
required this.appletId,
|
||||||
|
this.startParams,
|
||||||
|
this.sequence,
|
||||||
|
this.offlineMiniprogramZipPath,
|
||||||
|
this.offlineFrameworkZipPath,
|
||||||
|
this.animated = true,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toMap() {
|
||||||
|
Map<String, dynamic> result = {
|
||||||
|
"apiServer": apiServer,
|
||||||
|
"appletId": appletId,
|
||||||
|
"animated": animated
|
||||||
|
};
|
||||||
|
if (startParams != null) result["startParams"] = startParams;
|
||||||
|
if (offlineMiniprogramZipPath != null) result["offlineMiniprogramZipPath"] = offlineMiniprogramZipPath;
|
||||||
|
if (offlineFrameworkZipPath != null) result["offlineFrameworkZipPath"] = offlineFrameworkZipPath;
|
||||||
|
if (sequence != null) result["sequence"] = sequence;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class QRCodeAppletRequest {
|
||||||
|
// 二维码内容
|
||||||
|
String qrCode;
|
||||||
|
// 是否显示打开动画
|
||||||
|
bool animated = true;
|
||||||
|
|
||||||
|
QRCodeAppletRequest(this.qrCode);
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() {
|
||||||
|
return {
|
||||||
|
"apiServer": qrCode,
|
||||||
|
"animated": animated
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enum Anim {
|
enum Anim {
|
||||||
SlideFromLeftToRightAnim,
|
SlideFromLeftToRightAnim,
|
||||||
SlideFromRightToLeftAnim,
|
SlideFromRightToLeftAnim,
|
||||||
|
@ -376,6 +460,13 @@ class Mop {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Future<Map> startApplet(RemoteAppletRequest request) async {
|
||||||
|
Map<String, dynamic> params = request.toMap();
|
||||||
|
final Map ret = await _channel.invokeMethod('startApplet', params);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
/// get current using applet
|
/// get current using applet
|
||||||
/// 获取当前正在使用的小程序信息
|
/// 获取当前正在使用的小程序信息
|
||||||
|
|
28
pubspec.lock
28
pubspec.lock
|
@ -42,14 +42,14 @@ packages:
|
||||||
name: collection
|
name: collection
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.15.0"
|
version: "1.16.0"
|
||||||
fake_async:
|
fake_async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: fake_async
|
name: fake_async
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.3.0"
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
|
@ -88,6 +88,13 @@ packages:
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.11"
|
version: "0.12.11"
|
||||||
|
material_color_utilities:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: material_color_utilities
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "0.1.4"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -101,7 +108,7 @@ packages:
|
||||||
name: path
|
name: path
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.0"
|
version: "1.8.1"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
|
@ -113,7 +120,7 @@ packages:
|
||||||
name: source_span
|
name: source_span
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.1"
|
version: "1.8.2"
|
||||||
stack_trace:
|
stack_trace:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -148,21 +155,14 @@ packages:
|
||||||
name: test_api
|
name: test_api
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.4.3"
|
version: "0.4.9"
|
||||||
typed_data:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: typed_data
|
|
||||||
url: "https://pub.flutter-io.cn"
|
|
||||||
source: hosted
|
|
||||||
version: "1.3.0"
|
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vector_math
|
name: vector_math
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.1"
|
version: "2.1.2"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.14.0 <3.0.0"
|
dart: ">=2.17.0-0 <3.0.0"
|
||||||
flutter: ">=2.2.3"
|
flutter: ">=2.2.3"
|
||||||
|
|
Loading…
Reference in New Issue