修改mop
parent
6299dbbbd9
commit
233b18c972
35
lib/mop.dart
35
lib/mop.dart
|
@ -10,6 +10,7 @@ typedef MopEventErrorCallback = void Function(dynamic event);
|
||||||
|
|
||||||
typedef ExtensionApiHandler = Future<Map<String, dynamic>> Function(
|
typedef ExtensionApiHandler = Future<Map<String, dynamic>> Function(
|
||||||
dynamic params);
|
dynamic params);
|
||||||
|
typedef SyncExtensionApiHandler = Map<String, dynamic> Function(dynamic params);
|
||||||
typedef MopAppletHandler = Future Function(dynamic params);
|
typedef MopAppletHandler = Future Function(dynamic params);
|
||||||
|
|
||||||
class FinStoreConfig {
|
class FinStoreConfig {
|
||||||
|
@ -37,12 +38,16 @@ class FinStoreConfig {
|
||||||
/// 是否开启预加载基础库
|
/// 是否开启预加载基础库
|
||||||
bool enablePreloadFramework;
|
bool enablePreloadFramework;
|
||||||
|
|
||||||
|
/// google地图ApiKey
|
||||||
|
String? googleMapApiKey;
|
||||||
|
|
||||||
FinStoreConfig(this.sdkKey, this.sdkSecret, this.apiServer,
|
FinStoreConfig(this.sdkKey, this.sdkSecret, this.apiServer,
|
||||||
{this.apmServer,
|
{this.apmServer,
|
||||||
this.cryptType = "MD5",
|
this.cryptType = "MD5",
|
||||||
this.fingerprint,
|
this.fingerprint,
|
||||||
this.encryptServerData = false,
|
this.encryptServerData = false,
|
||||||
this.enablePreloadFramework = false});
|
this.enablePreloadFramework = false,
|
||||||
|
this.googleMapApiKey = ''});
|
||||||
|
|
||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap() {
|
||||||
return {
|
return {
|
||||||
|
@ -53,7 +58,8 @@ class FinStoreConfig {
|
||||||
"cryptType": cryptType,
|
"cryptType": cryptType,
|
||||||
"fingerprint": fingerprint,
|
"fingerprint": fingerprint,
|
||||||
"encryptServerData": encryptServerData,
|
"encryptServerData": encryptServerData,
|
||||||
"enablePreloadFramework": enablePreloadFramework
|
"enablePreloadFramework": enablePreloadFramework,
|
||||||
|
"googleMapApiKey": googleMapApiKey,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -933,6 +939,8 @@ class Mop {
|
||||||
|
|
||||||
final Map<String, ExtensionApiHandler> _extensionApis = {};
|
final Map<String, ExtensionApiHandler> _extensionApis = {};
|
||||||
|
|
||||||
|
final Map<String, SyncExtensionApiHandler> _syncExtensionApis = {};
|
||||||
|
|
||||||
Map<String, ExtensionApiHandler> _webExtensionApis = {};
|
Map<String, ExtensionApiHandler> _webExtensionApis = {};
|
||||||
|
|
||||||
factory Mop() {
|
factory Mop() {
|
||||||
|
@ -979,6 +987,14 @@ class Mop {
|
||||||
if (apiHandler != null) {
|
if (apiHandler != null) {
|
||||||
return await apiHandler(call.arguments);
|
return await apiHandler(call.arguments);
|
||||||
}
|
}
|
||||||
|
} else if (call.method.toLowerCase().startsWith("syncextensionapi:")) {
|
||||||
|
final name =
|
||||||
|
call.method.substring("syncextensionapi:".length);
|
||||||
|
final handler = _syncExtensionApis[name];
|
||||||
|
debugPrint("syncExtensionApisName:$name,handler:$handler");
|
||||||
|
if (handler != null) {
|
||||||
|
return handler(call.arguments);
|
||||||
|
}
|
||||||
} else if (call.method.startsWith("webExtentionApi:")) {
|
} else if (call.method.startsWith("webExtentionApi:")) {
|
||||||
final name = call.method.substring("webExtentionApi:".length);
|
final name = call.method.substring("webExtentionApi:".length);
|
||||||
final handler = _webExtensionApis[name];
|
final handler = _webExtensionApis[name];
|
||||||
|
@ -1221,12 +1237,27 @@ class Mop {
|
||||||
_channel.invokeMethod("registerExtensionApi", {"name": name});
|
_channel.invokeMethod("registerExtensionApi", {"name": name});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// register sync extension api
|
||||||
|
/// 注册拓展api(同步)
|
||||||
|
void registerSyncExtensionApi(String name, SyncExtensionApiHandler handler) {
|
||||||
|
_syncExtensionApis[name] = handler;
|
||||||
|
_channel.invokeMethod("registerSyncExtensionApi", {"name": name});
|
||||||
|
}
|
||||||
|
|
||||||
/// register webview extension api
|
/// register webview extension api
|
||||||
/// 注册webview拓展api
|
/// 注册webview拓展api
|
||||||
void addWebExtentionApi(String name, ExtensionApiHandler handler) {
|
void addWebExtentionApi(String name, ExtensionApiHandler handler) {
|
||||||
_webExtensionApis[name] = handler;
|
_webExtensionApis[name] = handler;
|
||||||
_channel.invokeMethod("addWebExtentionApi", {"name": name});
|
_channel.invokeMethod("addWebExtentionApi", {"name": name});
|
||||||
}
|
}
|
||||||
|
///显示加载中
|
||||||
|
Future showLoading() async {
|
||||||
|
return await _channel.invokeMethod("showLoading");
|
||||||
|
}
|
||||||
|
///隐藏加载中
|
||||||
|
Future hideLoading() async {
|
||||||
|
return await _channel.invokeMethod("hideLoading");
|
||||||
|
}
|
||||||
|
|
||||||
/// 原生调用webview中的js方法
|
/// 原生调用webview中的js方法
|
||||||
/// [appId] 小程序id
|
/// [appId] 小程序id
|
||||||
|
|
Loading…
Reference in New Issue