|
@@ -193,7 +193,7 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
config.selectionGranularity = WKSelectionGranularityDynamic;
|
|
|
config.allowsInlineMediaPlayback = YES;
|
|
|
config.mediaTypesRequiringUserActionForPlayback = NO;
|
|
|
-
|
|
|
+
|
|
|
config.processPool = [KSBaseWKWebViewController singleWkProcessPool];
|
|
|
config.websiteDataStore = [WKWebsiteDataStore defaultDataStore];
|
|
|
[self configUserAgent:config];
|
|
@@ -215,9 +215,9 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
_myWebView.navigationDelegate = self;
|
|
|
_myWebView.scrollView.bounces = NO;
|
|
|
#ifdef DEBUG
|
|
|
- if (@available(iOS 16.4, *)) {
|
|
|
- _myWebView.inspectable = YES;
|
|
|
- }
|
|
|
+ if (@available(iOS 16.4, *)) {
|
|
|
+ _myWebView.inspectable = YES;
|
|
|
+ }
|
|
|
#endif
|
|
|
// 加载进度条和title
|
|
|
[_myWebView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:nil];
|
|
@@ -229,7 +229,7 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
make.bottom.mas_equalTo(self.view.mas_bottom);
|
|
|
}];
|
|
|
_myWebView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
|
|
-
|
|
|
+
|
|
|
[self setupProgress];
|
|
|
|
|
|
[self loadRequest];
|
|
@@ -297,7 +297,7 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
return;
|
|
|
}
|
|
|
else if ([self.myWebView canGoBack]) {
|
|
|
-
|
|
|
+
|
|
|
[self.myWebView goBack];
|
|
|
}
|
|
|
else {
|
|
@@ -308,7 +308,7 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
#pragma mark - WKScriptMessageHandler
|
|
|
- (void)userContentController:(WKUserContentController *)userContentController
|
|
|
didReceiveScriptMessage:(WKScriptMessage *)message {
|
|
|
-
|
|
|
+
|
|
|
if ([message.name isEqualToString:SCRIPT_NAME]) {
|
|
|
NSDictionary *parm = [self convertJsonStringToNSDictionary:message.body];
|
|
|
// 回到主线程
|
|
@@ -360,13 +360,13 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
if ([valueDic ks_stringValueForKey:@"PDF"]) {
|
|
|
NSString *url = [valueDic ks_stringValueForKey:@"downloadUrl"];
|
|
|
[KSNetworkingManager downloadFileRequestWithFileUrl:url progress:^(int64_t bytesRead, int64_t totalBytes) {
|
|
|
-
|
|
|
+
|
|
|
} success:^(NSURL * _Nonnull fileUrl) {
|
|
|
[LOADING_MANAGER KSShowMsg:@"下载成功" promptCompletion:^{
|
|
|
[self displaySource:fileUrl];
|
|
|
}];
|
|
|
} faliure:^(NSError * _Nonnull error) {
|
|
|
-
|
|
|
+
|
|
|
}];
|
|
|
}
|
|
|
}
|
|
@@ -588,7 +588,7 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
}
|
|
|
else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"saveFile"]) { // 下载资源
|
|
|
NSDictionary *content = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
-
|
|
|
+
|
|
|
NSString *url = [content ks_stringValueForKey:@"url"];
|
|
|
[self downFile:url];
|
|
|
}
|
|
@@ -679,7 +679,7 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
[contentParm setValue:@(3) forKey:@"status"];
|
|
|
[contentParm setValue:@(0) forKey:@"progress"];
|
|
|
[contentParm setValue:lessonCoursewareDetailId forKey:@"lessonCoursewareDetailId"];
|
|
|
-
|
|
|
+
|
|
|
NSMutableDictionary *sendParm = [NSMutableDictionary dictionary];
|
|
|
[sendParm setValue:@"downloadCoursewareToCache" forKey:@"api"];
|
|
|
[sendParm setValue:contentParm forKey:@"content"];
|
|
@@ -760,7 +760,7 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
- (void)videCropImage:(UIImage *)cover content:(NSDictionary *)content {
|
|
|
NSData *imgData = [UIImage turnsImaegDataByImage:cover];
|
|
|
NSString *fileName = @"videoCoverImage";
|
|
|
-
|
|
|
+
|
|
|
[LOADING_MANAGER showCustomLoading:@"上传中..."];
|
|
|
[UPLOAD_MANAGER configWithfilePath:@"/user/"];
|
|
|
[UPLOAD_MANAGER uploadFile:imgData fileName:fileName fileSuffix:[UIImage typeForImageData:imgData] progress:^(int64_t bytesWritten, int64_t totalBytes) {
|
|
@@ -799,27 +799,39 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
|
|
|
- (void)saveFileWithUrl:(NSURL *)fileUrl {
|
|
|
if ([fileUrl.absoluteString hasSuffix:@".mp4"]) { // 视频
|
|
|
- [LOADING_MANAGER showCustomLoading:@"视频保存中..."];
|
|
|
- [[TZImageManager manager] saveVideoWithUrl:fileUrl completion:^(PHAsset *asset, NSError *error) {
|
|
|
- if (!error) {
|
|
|
- dispatch_main_async_safe(^{
|
|
|
- [LOADING_MANAGER removeCustomLoading];
|
|
|
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"已保存到相册"];
|
|
|
- });
|
|
|
+ [RecordCheckManager checkPhotoLibraryPremissionAvaiableCallback:^(PREMISSIONTYPE type) {
|
|
|
+ if (type == PREMISSIONTYPE_YES) {
|
|
|
+ [self saveVideo:fileUrl];
|
|
|
}
|
|
|
else {
|
|
|
- dispatch_main_async_safe(^{
|
|
|
- [LOADING_MANAGER removeCustomLoading];
|
|
|
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"保存视频错误"];
|
|
|
- });
|
|
|
+ [self showAlertWithMessage:@"请开启相册访问权限" type:CHECKDEVICETYPE_CAMREA];
|
|
|
}
|
|
|
}];
|
|
|
+
|
|
|
}
|
|
|
else { // 音频
|
|
|
[self saveFileToPhone:fileUrl];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+- (void)saveVideo:(NSURL *)fileUrl {
|
|
|
+ [LOADING_MANAGER showCustomLoading:@"视频保存中..."];
|
|
|
+ [[TZImageManager manager] saveVideoWithUrl:fileUrl completion:^(PHAsset *asset, NSError *error) {
|
|
|
+ if (!error) {
|
|
|
+ dispatch_main_async_safe(^{
|
|
|
+ [LOADING_MANAGER removeCustomLoading];
|
|
|
+ [LOADING_MANAGER MBShowAUTOHidingInWindow:@"已保存到相册"];
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ dispatch_main_async_safe(^{
|
|
|
+ [LOADING_MANAGER removeCustomLoading];
|
|
|
+ [LOADING_MANAGER MBShowAUTOHidingInWindow:@"保存视频错误"];
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
- (void)saveFileToPhone:(NSURL *)fileUrl {
|
|
|
self.isDownloadFile = YES;
|
|
|
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithURL:fileUrl inMode:UIDocumentPickerModeExportToService];
|