From 233b18c9723812f3e14c4b27fce237436fa56ccf Mon Sep 17 00:00:00 2001 From: Stewen <784547228@qq.com> Date: Wed, 6 Dec 2023 15:33:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9mop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/mop.dart | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/lib/mop.dart b/lib/mop.dart index 0f42a2c..4d6c194 100644 --- a/lib/mop.dart +++ b/lib/mop.dart @@ -10,6 +10,7 @@ typedef MopEventErrorCallback = void Function(dynamic event); typedef ExtensionApiHandler = Future> Function( dynamic params); +typedef SyncExtensionApiHandler = Map Function(dynamic params); typedef MopAppletHandler = Future Function(dynamic params); class FinStoreConfig { @@ -37,12 +38,16 @@ class FinStoreConfig { /// 是否开启预加载基础库 bool enablePreloadFramework; + /// google地图ApiKey + 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 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 _extensionApis = {}; + final Map _syncExtensionApis = {}; + Map _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 /// 注册webview拓展api 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"); + } /// 原生调用webview中的js方法 /// [appId] 小程序id