Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
陈高翔
/
DreamSleep-iOS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 6b150246
由
cgx
编写于
2022-04-25 11:30:14 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
网络缺省页白天黑夜模式适配
1 个父辈
e932fb68
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
209 行增加
和
29 行删除
DreamSleep/DreamSleep.xcodeproj/project.pbxproj
DreamSleep/DreamSleep/H5/DsWebController.m
DreamSleep/DreamSleep/H5/ExceptionDefaultView.h
DreamSleep/DreamSleep/H5/ExceptionDefaultView.m
DreamSleep/DreamSleep/Network/DSNetworkTool.h
DreamSleep/DreamSleep/Profile/InviteFriend/ShareAlertView.m
DreamSleep/DreamSleep/Resource/Assets.xcassets/Default/Contents.json
DreamSleep/DreamSleep/Resource/Assets.xcassets/Default/netDefault.imageset/Contents.json
DreamSleep/DreamSleep/Resource/Assets.xcassets/Default/netDefault.imageset/netDefault.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/Default/netDefault.imageset/netDefault@2x.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/Default/netDefault.imageset/netDefault@3x.png
DreamSleep/DreamSleep.xcodeproj/project.pbxproj
查看文件 @
6b15024
...
...
@@ -85,6 +85,7 @@
D0B5ECC827F2E97A003EDFE3 /* MacroFuncUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B5ECC727F2E97A003EDFE3 /* MacroFuncUtil.m */; };
D0B5ECD527F2F0B2003EDFE3 /* AdaptationUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B5ECD427F2F0B2003EDFE3 /* AdaptationUtil.m */; };
D0B5ECD827F2F1B0003EDFE3 /* ServerAPIUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B5ECD727F2F1B0003EDFE3 /* ServerAPIUtil.m */; };
D0BB9AA4281626F200DB209E /* ExceptionDefaultView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BB9AA3281626F200DB209E /* ExceptionDefaultView.m */; };
D0BE32E62814D42B006539BE /* HomeRequestModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BE32E52814D42B006539BE /* HomeRequestModel.m */; };
D0BE32E9281551EB006539BE /* ShareAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BE32E8281551EB006539BE /* ShareAlertView.m */; };
D0C09ED728007D9100709D4C /* relax_normal_lottie.json in Resources */ = {isa = PBXBuildFile; fileRef = D0C09ED328007D9100709D4C /* relax_normal_lottie.json */; };
...
...
@@ -271,6 +272,8 @@
D0B5ECD427F2F0B2003EDFE3 /* AdaptationUtil.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AdaptationUtil.m; sourceTree = "<group>"; };
D0B5ECD627F2F1B0003EDFE3 /* ServerAPIUtil.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ServerAPIUtil.h; sourceTree = "<group>"; };
D0B5ECD727F2F1B0003EDFE3 /* ServerAPIUtil.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ServerAPIUtil.m; sourceTree = "<group>"; };
D0BB9AA2281626F200DB209E /* ExceptionDefaultView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ExceptionDefaultView.h; sourceTree = "<group>"; };
D0BB9AA3281626F200DB209E /* ExceptionDefaultView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ExceptionDefaultView.m; sourceTree = "<group>"; };
D0BE32E42814D42B006539BE /* HomeRequestModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeRequestModel.h; sourceTree = "<group>"; };
D0BE32E52814D42B006539BE /* HomeRequestModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeRequestModel.m; sourceTree = "<group>"; };
D0BE32E7281551EB006539BE /* ShareAlertView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ShareAlertView.h; sourceTree = "<group>"; };
...
...
@@ -607,10 +610,12 @@
D07A657A2815897A00C15AF6 /* H5 */ = {
isa = PBXGroup;
children = (
D07A657B28158A1900C15AF6 /* DsWebController.h */,
D07A657C28158A1900C15AF6 /* DsWebController.m */,
D07A65812815911D00C15AF6 /* DsMaskView.h */,
D07A65822815911D00C15AF6 /* DsMaskView.m */,
D0BB9AA2281626F200DB209E /* ExceptionDefaultView.h */,
D0BB9AA3281626F200DB209E /* ExceptionDefaultView.m */,
D07A657B28158A1900C15AF6 /* DsWebController.h */,
D07A657C28158A1900C15AF6 /* DsWebController.m */,
);
path = H5;
sourceTree = "<group>";
...
...
@@ -1036,6 +1041,7 @@
D09D0E9D280D73B6008DEDAB /* InviteController.m in Sources */,
D04B3D9A27F6D4D90022F8DF /* LeadingController.m in Sources */,
D053BEE9280F9E310028CCFC /* CloseAlertView.m in Sources */,
D0BB9AA4281626F200DB209E /* ExceptionDefaultView.m in Sources */,
D0B5ECD827F2F1B0003EDFE3 /* ServerAPIUtil.m in Sources */,
D0B5ECA627F2D9DE003EDFE3 /* AppDelegate.m in Sources */,
D07DACA82810557D0067A1BF /* RSKImageCropViewController.m in Sources */,
...
...
DreamSleep/DreamSleep/H5/DsWebController.m
查看文件 @
6b15024
...
...
@@ -8,12 +8,15 @@
#import "DsWebController.h"
#import <WebKit/webKit.h>
#import "DsMaskView.h"
#import "ExceptionDefaultView.h"
@interface
DsWebController
()
<
WKNavigationDelegate
>
@property
(
nonatomic
,
copy
)
NSString
*
naviTitle
;
@property
(
nonatomic
,
strong
)
NSURL
*
linkUrl
;
@property
(
nonatomic
,
strong
)
WKWebView
*
webView
;
@property
(
nonatomic
,
strong
)
NSMutableURLRequest
*
request
;
@property
(
nonatomic
,
strong
)
UIProgressView
*
progressView
;
@property
(
nonatomic
,
strong
)
ExceptionDefaultView
*
exceptionView
;
@end
@implementation
DsWebController
...
...
@@ -30,7 +33,7 @@
[
super
viewDidLoad
];
self
.
navigationItem
.
title
=
self
.
naviTitle
;
self
.
view
.
backgroundColor
=
DSWhite
;
self
.
view
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
VCViewBG
)
;
[
self
.
view
addSubview
:
self
.
webView
];
[
self
.
view
addSubview
:
self
.
progressView
];
...
...
@@ -41,8 +44,6 @@
[
self
.
progressView
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
top
.
left
.
right
.
equalTo
(
self
.
view
);
}];
[
DsMaskView
showMaskWithSuperView
:
self
.
view
];
}
-
(
void
)
dealloc
{
...
...
@@ -60,23 +61,21 @@
}
#pragma mark - WKNavigationDelegate
// 开始加载
-
(
void
)
webView
:
(
WKWebView
*
)
webView
didCommitNavigation
:
(
WKNavigation
*
)
navigation
{
-
(
void
)
webView
:
(
WKWebView
*
)
webView
didStartProvisionalNavigation
:
(
null_unspecified
WKNavigation
*
)
navigation
{
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
YES
];
}
// 加载成功
-
(
void
)
webView
:
(
WKWebView
*
)
webView
didFinishNavigation
:
(
WKNavigation
*
)
navigation
{
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
NO
];
self
.
exceptionView
.
hidden
=
YES
;
[
DsMaskView
showMaskWithSuperView
:
self
.
view
];
self
.
webView
.
hidden
=
NO
;
}
// 加载失败
-
(
void
)
webView
:
(
WKWebView
*
)
webView
didFailProvisionalNavigation
:
(
WKNavigation
*
)
navigation
withError
:
(
NSError
*
)
error
{
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
NO
];
DSLog
(
@"加载失败:%@"
,
error
.
userInfo
);
// 显示加载失败状态视图
self
.
exceptionView
.
hidden
=
NO
;
}
#pragma mark - lazy
...
...
@@ -84,12 +83,15 @@
if
(
!
_webView
)
{
_webView
=
[[
WKWebView
alloc
]
init
];
_webView
.
navigationDelegate
=
self
;
_webView
.
backgroundColor
=
DSWhite
;
_webView
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
VCViewBG
);
_webView
.
scrollView
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
VCViewBG
);
_webView
.
scrollView
.
showsVerticalScrollIndicator
=
NO
;
_webView
.
hidden
=
YES
;
_webView
.
scrollView
.
contentInsetAdjustmentBehavior
=
UIScrollViewContentInsetAdjustmentNever
;
[
_webView
addObserver
:
self
forKeyPath
:
@"estimatedProgress"
options
:
NSKeyValueObservingOptionNew
context
:
nil
];
NSURLRequest
*
request
=
[
NSURLRequest
requestWithURL
:
self
.
linkUrl
];
[
_webView
loadRequest
:
request
];
NSMutableURLRequest
*
request
=
[[
NSMutableURLRequest
alloc
]
initWithURL
:
self
.
linkUrl
cachePolicy
:
NSURLRequestUseProtocolCachePolicy
timeoutInterval
:
10
.
0
];
self
.
request
=
request
;
[
_webView
loadRequest
:
self
.
request
];
}
return
_webView
;
}
...
...
@@ -98,11 +100,24 @@
if
(
!
_progressView
)
{
_progressView
=
[[
UIProgressView
alloc
]
init
];
_progressView
.
progressTintColor
=
HighlightColor
;
_progressView
.
trackTintColor
=
DSWhite
;
_progressView
.
dk_trackTintColorPicker
=
DKColorPickerWithKey
(
VCViewBG
)
;
}
return
_progressView
;
}
-
(
ExceptionDefaultView
*
)
exceptionView
{
if
(
!
_exceptionView
)
{
WS
(
weakSelf
);
_exceptionView
=
[[
ExceptionDefaultView
alloc
]
initWithType
:
ExceptionTypeNet
block
:
^
{
weakSelf
.
progressView
.
hidden
=
NO
;
weakSelf
.
progressView
.
progress
=
0
;
weakSelf
.
exceptionView
.
hidden
=
YES
;
[
weakSelf
.
webView
loadRequest
:
self
.
request
];
}
superView
:
self
.
view
];
}
return
_exceptionView
;
}
#pragma mark - H5页面导航栏为默认模式
-
(
NaviStyle
)
navigationBarStyle
{
return
NaviStyleDefault
;
...
...
DreamSleep/DreamSleep/H5/ExceptionDefaultView.h
0 → 100644
查看文件 @
6b15024
//
// ExceptionDefaultView.h
// DreamSleep
//
// Created by peter on 2022/4/25.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
// 异常处理类型
typedef
NS_ENUM
(
NSInteger
,
ExceptionType
)
{
ExceptionTypeNet
};
// 处理事件回调
typedef
void
(
^
DealBlock
)(
void
);
/// 异常缺省页
@interface
ExceptionDefaultView
:
UIView
-
(
instancetype
)
initWithType
:(
ExceptionType
)
type
block
:(
DealBlock
)
block
superView
:(
UIView
*
)
superView
;
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/H5/ExceptionDefaultView.m
0 → 100644
查看文件 @
6b15024
//
// ExceptionDefaultView.m
// DreamSleep
//
// Created by peter on 2022/4/25.
//
#import "ExceptionDefaultView.h"
@interface
ExceptionDefaultView
()
@property
(
nonatomic
,
strong
)
UIImageView
*
exceptionIV
;
@property
(
nonatomic
,
strong
)
UILabel
*
exceptLab
;
@property
(
nonatomic
,
strong
)
UIButton
*
dealBtn
;
@property
(
nonatomic
,
copy
)
DealBlock
dealBlock
;
@property
(
nonatomic
,
assign
)
ExceptionType
type
;
@end
@implementation
ExceptionDefaultView
-
(
instancetype
)
initWithType
:(
ExceptionType
)
type
block
:(
DealBlock
)
block
superView
:(
UIView
*
)
superView
{
if
(
self
=
[
super
initWithFrame
:
CGRectZero
])
{
_dealBlock
=
block
;
_type
=
type
;
self
.
hidden
=
YES
;
[
superView
addSubview
:
self
];
[
self
addSubview
:
self
.
exceptionIV
];
[
self
addSubview
:
self
.
exceptLab
];
[
self
addSubview
:
self
.
dealBtn
];
[
self
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
left
.
right
.
equalTo
(
superView
);
make
.
center
.
equalTo
(
superView
);
}];
[
self
.
exceptionIV
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
centerX
.
equalTo
(
self
);
make
.
top
.
equalTo
(
self
);
}];
[
self
.
exceptLab
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
centerX
.
equalTo
(
self
);
make
.
left
.
equalTo
(
self
).
offset
(
5
);
make
.
right
.
equalTo
(
self
).
offset
(
-
5
);
make
.
top
.
equalTo
(
self
.
exceptionIV
.
mas_bottom
).
offset
(
42
);
}];
[
self
.
dealBtn
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
centerX
.
equalTo
(
self
);
make
.
size
.
mas_equalTo
(
CGSizeMake
(
155
,
40
));
make
.
top
.
equalTo
(
self
.
exceptLab
.
mas_bottom
).
offset
(
42
);
make
.
bottom
.
equalTo
(
self
).
offset
(
-
30
);
}];
}
return
self
;
}
-
(
void
)
dealloc
{
DSLog
(
@"deallocdeallocdealloc"
);
}
#pragma mark - Actions
-
(
void
)
dealAction
{
if
(
self
.
dealBlock
)
{
self
.
dealBlock
();
}
}
#pragma mark - lazy
-
(
UIImageView
*
)
exceptionIV
{
if
(
!
_exceptionIV
)
{
_exceptionIV
=
[[
UIImageView
alloc
]
initWithImage
:[
UIImage
imageNamed
:
@"netDefault"
]];
}
return
_exceptionIV
;
}
-
(
UILabel
*
)
exceptLab
{
if
(
!
_exceptLab
)
{
_exceptLab
=
[
UILabel
labWithText
:[
self
getExceptionInfoWithType
:
self
.
type
]
font
:
SysFont
(
14
)
fit
:
YES
];
_exceptLab
.
textAlignment
=
NSTextAlignmentCenter
;
_exceptLab
.
dk_textColorPicker
=
DKColorPickerWithKey
(
SubTEXT
);
}
return
_exceptLab
;
}
-
(
UIButton
*
)
dealBtn
{
if
(
!
_dealBtn
)
{
_dealBtn
=
[
UIButton
btnWithTitle
:[
self
getDealBtnTitleWithType
:
self
.
type
]
titleColor
:
DSWhite
font
:
BoldFont
(
16
)
bgColor
:
BrandColor
];
[
_dealBtn
addTarget
:
self
action
:
@selector
(
dealAction
)
forControlEvents
:
UIControlEventTouchUpInside
];
[
_dealBtn
cornerRadius
:
20
];
}
return
_dealBtn
;
}
#pragma mark - private
-
(
NSString
*
)
getExceptionInfoWithType
:
(
ExceptionType
)
type
{
NSString
*
info
=
@""
;
if
(
type
==
ExceptionTypeNet
)
{
info
=
@"当前网络环境较差,点击刷新重新加载~"
;
}
return
info
;
}
-
(
NSString
*
)
getDealBtnTitleWithType
:
(
ExceptionType
)
type
{
NSString
*
title
=
@""
;
if
(
type
==
ExceptionTypeNet
)
{
title
=
@"刷新"
;
}
return
title
;
}
@end
DreamSleep/DreamSleep/Network/DSNetworkTool.h
查看文件 @
6b15024
...
...
@@ -5,19 +5,6 @@
// Created by peter on 2022/4/13.
//
//typedef NS_ENUM(NSInteger, DSErrCode) {
// /** 网络故障 */
// DSErrCodeNetFail = -9,
// /** 业务逻辑成功 */
// DSErrCodeSuccess = -1,
// /** token验证失败 */
// DSErrCodeTokenFail = 401,
// /** 数据异常 */
// DSErrCodeDataWrong = -666,
// /** 异常数据错误,需要额外处理异常 */
// DSErrCodeNeedExtraDeal = 400022
//};
// 响应码
typedef
NS_ENUM
(
NSInteger
,
DSResCode
)
{
/** 网络故障 */
...
...
DreamSleep/DreamSleep/Profile/InviteFriend/ShareAlertView.m
查看文件 @
6b15024
...
...
@@ -20,6 +20,9 @@
self
.
backgroundColor
=
AlertDarkColor
;
self
.
backgroundColor
=
[
self
.
backgroundColor
colorWithAlphaComponent
:
0
.
6
];
UITapGestureRecognizer
*
tapGR
=
[[
UITapGestureRecognizer
alloc
]
initWithTarget
:
self
action
:
@selector
(
tapAction
:
)];
[
self
addGestureRecognizer
:
tapGR
];
[
self
addSubview
:
self
.
shareView
];
[
self
.
shareView
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
centerX
.
equalTo
(
self
);
...
...
@@ -82,6 +85,12 @@
}
}
-
(
void
)
tapAction
:(
UITapGestureRecognizer
*
)
gesture
{
if
(
!
CGRectContainsPoint
(
self
.
shareView
.
frame
,
[
gesture
locationInView
:
self
]))
{
[
self
dismissShareAlertView
];
}
}
#pragma mark - public
-
(
void
)
showShareAlertView
{
[
DSKeyWindow
addSubview
:
self
];
...
...
DreamSleep/DreamSleep/Resource/Assets.xcassets/Default/Contents.json
0 → 100644
查看文件 @
6b15024
{
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
DreamSleep/DreamSleep/Resource/Assets.xcassets/Default/netDefault.imageset/Contents.json
0 → 100644
查看文件 @
6b15024
{
"images"
:
[
{
"filename"
:
"netDefault.png"
,
"idiom"
:
"universal"
,
"scale"
:
"1x"
},
{
"filename"
:
"netDefault@2x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"2x"
},
{
"filename"
:
"netDefault@3x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"3x"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
DreamSleep/DreamSleep/Resource/Assets.xcassets/Default/netDefault.imageset/netDefault.png
0 → 100644
查看文件 @
6b15024
23.9 KB
DreamSleep/DreamSleep/Resource/Assets.xcassets/Default/netDefault.imageset/netDefault@2x.png
0 → 100644
查看文件 @
6b15024
66.8 KB
DreamSleep/DreamSleep/Resource/Assets.xcassets/Default/netDefault.imageset/netDefault@3x.png
0 → 100644
查看文件 @
6b15024
130.8 KB
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论