|
@@ -102,6 +102,22 @@
|
|
|
- (void)viewDidLoad {
|
|
|
[super viewDidLoad];
|
|
|
|
|
|
+ NSArray *arLanguages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
|
|
|
+ NSLog(@"arLanguages:%@",arLanguages);
|
|
|
+ ///获取设备当前地区的代码和APP语言环境
|
|
|
+ NSString *languageCode = [NSLocale preferredLanguages][0];
|
|
|
+
|
|
|
+ //目前支持 中文(简体 繁体) 英文 日语
|
|
|
+ if([languageCode rangeOfString:@"zh-Hans"].location != NSNotFound)
|
|
|
+ {
|
|
|
+ self.webUrl = @"https://www.baidu.com/";
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ self.webUrl = @"https://www.google.com";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
[self drawView];
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateBrowserWindow) name:WebviewReloadNotification object:nil];
|
|
@@ -262,7 +278,21 @@
|
|
|
|
|
|
}else { // 搜索
|
|
|
|
|
|
- NSString *text = [NSString stringWithFormat:@"https://www.baidu.com/s?wd=%@",self.webUrl];
|
|
|
+ NSString *text = @"";//[NSString stringWithFormat:@"https://www.baidu.com/s?wd=%@",self.webUrl];
|
|
|
+ NSArray *arLanguages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
|
|
|
+ NSLog(@"arLanguages:%@",arLanguages);
|
|
|
+ ///获取设备当前地区的代码和APP语言环境
|
|
|
+ NSString *languageCode = [NSLocale preferredLanguages][0];
|
|
|
+
|
|
|
+ //目前支持 中文(简体 繁体) 英文 日语
|
|
|
+ if([languageCode rangeOfString:@"zh-Hans"].location != NSNotFound)
|
|
|
+ {
|
|
|
+ text = [NSString stringWithFormat:@"https://www.baidu.com/s?wd=%@",self.webUrl];
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ text = [NSString stringWithFormat:@"https://www.google.com/search?q=%@",self.webUrl];
|
|
|
+ }
|
|
|
+
|
|
|
text = [text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
|
|
[self loadRequestURL:text];
|
|
|
}
|
|
@@ -299,7 +329,22 @@
|
|
|
[text hasPrefix:@"http://"]) {
|
|
|
[self loadRequestURL:text];
|
|
|
}else {
|
|
|
- text = [NSString stringWithFormat:@"https://www.baidu.com/s?wd=%@",text];
|
|
|
+ //text = [NSString stringWithFormat:@"https://www.baidu.com/s?wd=%@",text];
|
|
|
+
|
|
|
+ NSArray *arLanguages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
|
|
|
+ NSLog(@"arLanguages:%@",arLanguages);
|
|
|
+ ///获取设备当前地区的代码和APP语言环境
|
|
|
+ NSString *languageCode = [NSLocale preferredLanguages][0];
|
|
|
+
|
|
|
+ //目前支持 中文(简体 繁体) 英文 日语
|
|
|
+ if([languageCode rangeOfString:@"zh-Hans"].location != NSNotFound)
|
|
|
+ {
|
|
|
+ text = [NSString stringWithFormat:@"https://www.baidu.com/s?wd=%@",text];
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ text = [NSString stringWithFormat:@"https://www.google.com/search?q=%@",text];
|
|
|
+ }
|
|
|
+
|
|
|
text = [text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
|
|
[self loadRequestURL:text];
|
|
|
}
|
|
@@ -913,6 +958,23 @@
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
+- (void)setWebUrl:(NSString *)webUrl{
|
|
|
+
|
|
|
+ NSArray *arLanguages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
|
|
|
+ NSLog(@"arLanguages:%@",arLanguages);
|
|
|
+ ///获取设备当前地区的代码和APP语言环境
|
|
|
+ NSString *languageCode = [NSLocale preferredLanguages][0];
|
|
|
+
|
|
|
+ //目前支持 中文(简体 繁体) 英文 日语
|
|
|
+ if([languageCode rangeOfString:@"zh-Hans"].location != NSNotFound)
|
|
|
+ {
|
|
|
+ _webUrl = @"https://www.baidu.com/";
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ _webUrl = @"https://www.google.com";
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
- (void)dealloc {
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
|
}
|