File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -115,10 +115,14 @@ - (void)refreshCodeViewData{
115115 [self .webContentView loadRequest: [NSURLRequest requestWithURL: imageUrl]];
116116 }else if ([@[@" file" , @" sym_link" , @" executable" ] containsObject: _myCodeFile.file.mode]){
117117 NSString *contentStr = [WebContentManager codePatternedWithContent: _myCodeFile isEdit: NO ];
118- [self .webContentView loadHTMLString: contentStr baseURL: nil ];
118+ [self .webContentView loadHTMLString: contentStr baseURL: [ NSURL URLWithString: [ self p_baseHref ]] ];
119119 }
120120}
121121
122+ - (NSString *)p_baseHref {// 写在 html 文件里的,没有 baseHref 的话,锚点会异常
123+ return @" https://coding.net/" ;
124+ }
125+
122126#pragma mark UIWebViewDelegate
123127- (BOOL )webView : (UIWebView *)webView shouldStartLoadWithRequest : (NSURLRequest *)request navigationType : (UIWebViewNavigationType)navigationType {
124128 DebugLog (@" strLink=[%@ ]" ,request.URL .absoluteString );
@@ -133,6 +137,10 @@ - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)
133137 return YES ;
134138 }
135139 }
140+ if ([request.URL.absoluteString isEqualToString: [self p_baseHref ]] ||
141+ [request.URL.absoluteString hasPrefix: [[self p_baseHref ] stringByAppendingString: @" #" ]]) {
142+ return YES ;
143+ }
136144 UIViewController *vc = [BaseViewController analyseVCFromLinkStr: request.URL.absoluteString];
137145 if (vc) {
138146 [self .navigationController pushViewController: vc animated: YES ];
Original file line number Diff line number Diff line change @@ -105,4 +105,8 @@ - (NSDictionary *)toCreateParams{
105105
106106@implementation CodeFile_RealFile
107107
108+ - (void )setPreview : (NSString *)preview {
109+ _preview = [preview stringByReplacingOccurrencesOfString: @" {{CodingUrl}}" withString: @" " ];
110+ }
111+
108112@end
You can’t perform that action at this time.
0 commit comments