From 1fca68e124c60c98d879ffe592094d115022fed5 Mon Sep 17 00:00:00 2001 From: hujianhui Date: Wed, 22 Dec 2021 21:03:38 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=B0=E6=A1=8C?= =?UTF-8?q?=E9=9D=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Classes/Api/MOPAppletDelegate.m | 47 +++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/ios/Classes/Api/MOPAppletDelegate.m b/ios/Classes/Api/MOPAppletDelegate.m index d01d99a..0b0390a 100644 --- a/ios/Classes/Api/MOPAppletDelegate.m +++ b/ios/Classes/Api/MOPAppletDelegate.m @@ -9,6 +9,12 @@ #import "MopPlugin.h" #import "MopCustomMenuModel.h" +@interface NSString (FATEncode) +- (NSString *)fat_encodeString; + +@end + + @implementation MOPAppletDelegate + (instancetype)instance @@ -87,6 +93,11 @@ [channel invokeMethod:@"extensionApi:onCustomMenuClick" arguments:arguments result:^(id _Nullable result) { }]; + + if ([@"Desktop" isEqualToString:customMenu.menuId]) { + [self addToDesktopItemClick:appletInfo path:path]; + } + } - (void)clickCustomItemMenuWithInfo:(NSDictionary *)contentInfo completion:(void (^)(FATExtensionCode code, NSDictionary *result))completion { @@ -102,6 +113,12 @@ }]; } +- (void)clickCustomItemMenuWithInfo:(NSDictionary *)contentInfo inApplet:(FATAppletInfo *)appletInfo completion:(void (^)(FATExtensionCode code, NSDictionary *result))completion { + if ([@"Desktop" isEqualToString:contentInfo[@"menuId"]]) { + [self addToDesktopItemClick:appletInfo path:contentInfo[@"path"]]; + } +} + - (void)applet:(NSString *)appletId didOpenCompletion:(NSError *)error { if (!appletId) { return; @@ -113,4 +130,34 @@ }]; } +static NSString *scheme = @"fatae55433be2f62915";//App对应的scheme + +- (void)addToDesktopItemClick:(FATAppletInfo *)appInfo path:(NSString *)path { + NSMutableString *herf = [NSString stringWithFormat:@"%@://applet/appid/%@?", scheme, appInfo.appId].mutableCopy; + NSString *query = [NSString stringWithFormat:@"apiServer=%@&path=%@",appInfo.apiServer, path]; + + if ([appInfo.startParams[@"query"] length]) { + query = [NSString stringWithFormat:@"%@&query=%@",query, appInfo.startParams[@"query"]]; + } + [herf appendString:query.fat_encodeString]; + + NSMutableString *url = [NSMutableString stringWithFormat:@"%@/mop/scattered-page/#/desktopicon", appInfo.apiServer]; + [url appendFormat:@"?iconpath=%@", appInfo.appAvatar]; + [url appendFormat:@"&apptitle=%@", appInfo.appTitle.fat_encodeString]; + [url appendFormat:@"&linkhref=%@", herf]; + + NSLog(@"跳转到中间页面:%@", url); + + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]]; +} + + +@end + +@implementation NSString (FATEncode) + +- (NSString *)fat_encodeString { + return (__bridge NSString *)CFURLCreateStringByAddingPercentEscapes( NULL, (__bridge CFStringRef)self, NULL, (CFStringRef)@"!*'();:@&=+$,/?%#[]", kCFStringEncodingUTF8); +} + @end From 8f21e461922d9054b56f73a88c2113caea362e3e Mon Sep 17 00:00:00 2001 From: hujianhui Date: Fri, 24 Dec 2021 15:02:17 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=86=B7=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E6=97=B6=E4=B8=8D=E8=83=BD=E8=B7=B3=E8=BD=AC=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Classes/MopPlugin.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ios/Classes/MopPlugin.m b/ios/Classes/MopPlugin.m index 3f51f4e..efa087b 100644 --- a/ios/Classes/MopPlugin.m +++ b/ios/Classes/MopPlugin.m @@ -88,6 +88,11 @@ static MopPlugin *_instance; - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options { + if (![FATClient sharedClient].inited) { + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [[FATClient sharedClient] handleOpenURL:url]; + }); + } return [[FATClient sharedClient] handleOpenURL:url]; } From 48816278078b33d49b9f0e8410d5a992b0c74384 Mon Sep 17 00:00:00 2001 From: hujianhui Date: Mon, 27 Dec 2021 18:22:04 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=B0=E6=A1=8C?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Classes/Api/MOPAppletDelegate.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ios/Classes/Api/MOPAppletDelegate.m b/ios/Classes/Api/MOPAppletDelegate.m index 0b0390a..4a210d9 100644 --- a/ios/Classes/Api/MOPAppletDelegate.m +++ b/ios/Classes/Api/MOPAppletDelegate.m @@ -76,6 +76,9 @@ FATAppletMenuStyle style = [typeString isEqualToString:@"onMiniProgram"] ? FATAppletMenuStyleOnMiniProgram : FATAppletMenuStyleCommon; model.menuType = style; } + if ([@"Desktop" isEqualToString:model.menuId] && FATAppletVersionTypeRelease != appletInfo.appletVersionType) { + continue; + } [models addObject:model]; }