forked from didi/DoKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 新增JS脚本插件 * 优化页面切换效果 * update README Co-authored-by: carefree <[email protected]>
- Loading branch information
Showing
26 changed files
with
509 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
iOS/DoraemonKit/Resource/Assets.xcassets/doraemon_js.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+5.44 KB
iOS/DoraemonKit/Resource/Assets.xcassets/doraemon_js.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.98 KB
iOS/DoraemonKit/Resource/Assets.xcassets/doraemon_js.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,5 +47,7 @@ | |
|
||
- (UIViewController *)doraemon_viewController; | ||
|
||
- (NSArray *)doraemon_findViewsForClass:(Class)clazz; | ||
|
||
@end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
iOS/DoraemonKit/Src/Core/Plugin/Common/JavaScript/DoraemonJavaScriptDetailViewController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// DoraemonJavaScriptDetailViewController.h | ||
// DoraemonKit | ||
// | ||
// Created by carefree on 2022/5/11. | ||
// | ||
|
||
#import "DoraemonBaseViewController.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface DoraemonJavaScriptDetailViewController : DoraemonBaseViewController | ||
|
||
@property (nonatomic, copy) NSString *key; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
62 changes: 62 additions & 0 deletions
62
iOS/DoraemonKit/Src/Core/Plugin/Common/JavaScript/DoraemonJavaScriptDetailViewController.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// | ||
// DoraemonJavaScriptDetailViewController.m | ||
// DoraemonKit | ||
// | ||
// Created by carefree on 2022/5/11. | ||
// | ||
|
||
#import "DoraemonJavaScriptDetailViewController.h" | ||
#import "DoraemonKit.h" | ||
#import "DoraemonDefine.h" | ||
#import "DoraemonToastUtil.h" | ||
#import "DoraemonCacheManager.h" | ||
#import "DoraemonJavaScriptManager.h" | ||
|
||
@interface DoraemonJavaScriptDetailViewController () | ||
|
||
@property (nonatomic, weak) UITextView *textView; | ||
|
||
@end | ||
|
||
@implementation DoraemonJavaScriptDetailViewController | ||
|
||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
|
||
self.title = DoraemonLocalizedString(@"脚本执行"); | ||
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:@selector(runScript)]; | ||
UIEdgeInsets edge = UIEdgeInsetsMake(10, 10, 0, 10); | ||
CGFloat width = self.view.bounds.size.width - edge.left - edge.right; | ||
CGFloat height = self.view.bounds.size.height - edge.top - edge.bottom; | ||
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(edge.left, edge.top + IPHONE_NAVIGATIONBAR_HEIGHT, width, 30)]; | ||
titleLabel.text = DoraemonLocalizedString(@"JS代码"); | ||
|
||
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(edge.left, CGRectGetMaxY(titleLabel.frame) + edge.top, width, height - 200)]; | ||
textView.layer.borderWidth = 1 / UIScreen.mainScreen.scale; | ||
textView.layer.borderColor = [[UIColor lightGrayColor] CGColor]; | ||
textView.layer.cornerRadius = 6; | ||
textView.font = [UIFont systemFontOfSize:16]; | ||
textView.textContainerInset = UIEdgeInsetsMake(8, 3, 8, 3); | ||
|
||
[self.view addSubview:titleLabel]; | ||
[self.view addSubview:textView]; | ||
self.textView = textView; | ||
|
||
if (self.key.length > 0) { | ||
self.textView.text = [DoraemonCacheManager.sharedInstance jsHistoricalRecordForKey:self.key]; | ||
} | ||
} | ||
|
||
#pragma mark - Private | ||
- (void)runScript { | ||
NSString *value = self.textView.text; | ||
if (value.length == 0) { | ||
[DoraemonToastUtil showToastBlack:@"脚本不能为空" inView:self.view]; | ||
return; | ||
} | ||
[DoraemonCacheManager.sharedInstance saveJsHistoricalRecordWithText:value forKey:self.key]; | ||
[DoraemonManager.shareInstance hiddenHomeWindow]; | ||
[DoraemonJavaScriptManager.shareInstance evalJavaScript:value]; | ||
} | ||
|
||
@end |
17 changes: 17 additions & 0 deletions
17
iOS/DoraemonKit/Src/Core/Plugin/Common/JavaScript/DoraemonJavaScriptPlugin.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// DoraemonJavaScriptPlugin.h | ||
// AFNetworking | ||
// | ||
// Created by carefree on 2022/5/11. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "DoraemonPluginProtocol.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface DoraemonJavaScriptPlugin : NSObject<DoraemonPluginProtocol> | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
19 changes: 19 additions & 0 deletions
19
iOS/DoraemonKit/Src/Core/Plugin/Common/JavaScript/DoraemonJavaScriptPlugin.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// DoraemonJavaScriptPlugin.m | ||
// AFNetworking | ||
// | ||
// Created by carefree on 2022/5/11. | ||
// | ||
|
||
#import "DoraemonJavaScriptPlugin.h" | ||
#import "DoraemonJavaScriptManager.h" | ||
#import "DoraemonHomeWindow.h" | ||
|
||
@implementation DoraemonJavaScriptPlugin | ||
|
||
- (void)pluginDidLoad { | ||
[[DoraemonHomeWindow shareInstance] hide]; | ||
[[DoraemonJavaScriptManager shareInstance] show]; | ||
} | ||
|
||
@end |
16 changes: 16 additions & 0 deletions
16
iOS/DoraemonKit/Src/Core/Plugin/Common/JavaScript/DoraemonJavaScriptViewController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// DoraemonJavaScriptViewController.h | ||
// DoraemonKit | ||
// | ||
// Created by carefree on 2022/5/11. | ||
// | ||
|
||
#import "DoraemonBaseViewController.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface DoraemonJavaScriptViewController : DoraemonBaseViewController | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
Oops, something went wrong.