Skip to content

Commit 2285577

Browse files
committed
bugfix
1 parent b4649b0 commit 2285577

File tree

5 files changed

+24
-24
lines changed

5 files changed

+24
-24
lines changed

Coding_iOS/Controllers/EACodeReleaseViewController.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ - (void)viewWillAppear:(BOOL)animated{
6363

6464
#pragma Data
6565
- (void)refresh{
66-
if (_curRelease.title.length <= 0) {
66+
if (!_curRelease.author) {
6767
[self.view beginLoading];
6868
}
6969
__weak typeof(self) weakSelf = self;
@@ -77,15 +77,15 @@ - (void)refresh{
7777
weakSelf.curRelease = data;
7878
[weakSelf.myTableView reloadData];
7979
}
80-
[weakSelf.view configBlankPage:EaseBlankPageTypeView hasData:weakSelf.curRelease.title.length > 0 hasError:(error != nil) reloadButtonBlock:^(id sender) {
80+
[weakSelf.view configBlankPage:EaseBlankPageTypeView hasData:(weakSelf.curRelease.author != nil) hasError:(error != nil) reloadButtonBlock:^(id sender) {
8181
[weakSelf refresh];
8282
}];
8383
}];
8484
}
8585

8686
#pragma mark TableM
8787
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
88-
return _curRelease.title.length > 0? 4: 0;
88+
return _curRelease.author != nil? 4: 0;
8989
}
9090

9191
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

Coding_iOS/Controllers/EALocalCodeViewController.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,12 @@ - (void)webViewDidFinishLoad:(UIWebView *)webView{
8080
}
8181

8282
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
83-
if (error.code != NSURLErrorCancelled) {
84-
[_activityIndicator stopAnimating];
83+
[_activityIndicator stopAnimating];
84+
if (error.code == NSURLErrorCancelled) {
85+
NSLog(@"Canceled request: %@", webView.request.URL);
86+
}else if ([error.domain isEqualToString:@"WebKitErrorDomain"] && (error.code == 102 || error.code == 204)) {
87+
NSLog(@"ignore: %@", error);
88+
}else {
8589
[NSObject showError:error];
8690
}
8791
}

Coding_iOS/Models/Login.m

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#define kLoginPreUserEmail @"pre_user_email"
1515
#define kLoginUserDict @"user_dict"
1616
#define kLoginDataListPath @"login_data_list_path.plist"
17-
#define kLoginPassword [NSString stringWithFormat:@"password|%@", [self curLoginUser].global_key]
17+
#define kLoginPasswordKey(_key_) [NSString stringWithFormat:@"password|%@", _key_]
1818

1919
static User *curLoginUser;
2020

@@ -40,6 +40,7 @@ - (NSDictionary *)toParams{
4040
if (self.j_captcha.length > 0) {
4141
params[@"j_captcha"] = self.j_captcha;
4242
}
43+
[Login p_setPassword:self.password forAccount:self.email];//保存一下密码
4344
return params;
4445
}
4546

@@ -197,16 +198,23 @@ +(BOOL)isLoginUserGlobalKey:(NSString *)global_key{
197198
// Git Clone 需要用 http 的方式校验
198199
+ (void)setPassword:(NSString *)password{
199200
if ([self curLoginUser].global_key) {
200-
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
201-
[defaults setObject:password forKey:kLoginPassword];
202-
[defaults synchronize];
201+
[self p_setPassword:password forAccount:[self curLoginUser].global_key];
203202
}
204203
}
205204

205+
+ (void)p_setPassword:(NSString *)password forAccount:(NSString *)account{
206+
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
207+
[defaults setObject:password forKey:kLoginPasswordKey(account)];
208+
[defaults synchronize];
209+
}
210+
206211
+ (NSString *)curPassword{
207-
if ([self curLoginUser].global_key) {
212+
if ([self isLogin]) {
208213
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
209-
return [defaults objectForKey:kLoginPassword];
214+
User *curU = [self curLoginUser];
215+
return ([defaults objectForKey:kLoginPasswordKey(curU.global_key)] ?:
216+
[defaults objectForKey:kLoginPasswordKey(curU.email)] ?:
217+
[defaults objectForKey:kLoginPasswordKey(curU.phone)]);
210218
}else{
211219
return nil;
212220
}

Coding_iOS/Util/OC_Category/NSURL+Common.m

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,6 @@ - (NSString *)ea_lang{
6161
return [[self.class p_sufToLangDict][fileSuffix] firstObject] ?: @"";
6262
}
6363

64-
+ (NSArray *)p_textItemTypeList{
65-
static NSArray *textItemTypeList = nil;
66-
if (!textItemTypeList) {
67-
textItemTypeList = @[
68-
@"public.plain-text",
69-
@"public.html",
70-
@"public.data",
71-
];
72-
}
73-
return textItemTypeList;
74-
}
75-
7664
+ (NSDictionary *)p_sufToLangDict{
7765
static NSDictionary *sufToLangDict = nil;
7866
if (!sufToLangDict) {

Coding_iOS/Views/Cell/EACodeReleaseListCell.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
3131
- (void)setCurCodeRelease:(EACodeRelease *)curCodeRelease{
3232
_curCodeRelease = curCodeRelease;
3333

34-
_titleL.text = _curCodeRelease.title;
34+
_titleL.text = _curCodeRelease.title.length > 0? _curCodeRelease.title: _curCodeRelease.tag_name;
3535
_tag_nameL.text = _curCodeRelease.tag_name;
3636
_authorL.text = _curCodeRelease.author.name;
3737
_created_atL.text = [_curCodeRelease.created_at stringTimesAgo];

0 commit comments

Comments
 (0)