修改mop

phiz_2.42.7.12
Stewen 2023-12-06 15:33:23 +08:00
parent 6299dbbbd9
commit 233b18c972
1 changed files with 33 additions and 2 deletions

View File

@ -10,6 +10,7 @@ typedef MopEventErrorCallback = void Function(dynamic event);
typedef ExtensionApiHandler = Future<Map<String, dynamic>> Function(
dynamic params);
typedef SyncExtensionApiHandler = Map<String, dynamic> Function(dynamic params);
typedef MopAppletHandler = Future Function(dynamic params);
class FinStoreConfig {
@ -37,12 +38,16 @@ class FinStoreConfig {
///
bool enablePreloadFramework;
/// googleApiKey
String? googleMapApiKey;
FinStoreConfig(this.sdkKey, this.sdkSecret, this.apiServer,
{this.apmServer,
this.cryptType = "MD5",
this.fingerprint,
this.encryptServerData = false,
this.enablePreloadFramework = false});
this.enablePreloadFramework = false,
this.googleMapApiKey = ''});
Map<String, dynamic> toMap() {
return {
@ -53,7 +58,8 @@ class FinStoreConfig {
"cryptType": cryptType,
"fingerprint": fingerprint,
"encryptServerData": encryptServerData,
"enablePreloadFramework": enablePreloadFramework
"enablePreloadFramework": enablePreloadFramework,
"googleMapApiKey": googleMapApiKey,
};
}
}
@ -933,6 +939,8 @@ class Mop {
final Map<String, ExtensionApiHandler> _extensionApis = {};
final Map<String, SyncExtensionApiHandler> _syncExtensionApis = {};
Map<String, ExtensionApiHandler> _webExtensionApis = {};
factory Mop() {
@ -979,6 +987,14 @@ class Mop {
if (apiHandler != null) {
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:")) {
final name = call.method.substring("webExtentionApi:".length);
final handler = _webExtensionApis[name];
@ -1221,12 +1237,27 @@ class Mop {
_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
/// webviewapi
void addWebExtentionApi(String name, ExtensionApiHandler handler) {
_webExtensionApis[name] = handler;
_channel.invokeMethod("addWebExtentionApi", {"name": name});
}
///
Future showLoading() async {
return await _channel.invokeMethod("showLoading");
}
///
Future hideLoading() async {
return await _channel.invokeMethod("hideLoading");
}
/// webviewjs
/// [appId] id