Commit 75f581e6 by ludi

补全搜索关键词部分

parent 4657f684
......@@ -753,6 +753,8 @@
BE78CCB72C538D8000F38855 /* FUSSearchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE78CAA32C538D7D00F38855 /* FUSSearchViewController.swift */; };
BE78CCBB2C538D8000F38855 /* FUSPopularTagModel.h in Headers */ = {isa = PBXBuildFile; fileRef = BE78CAA82C538D7D00F38855 /* FUSPopularTagModel.h */; };
BE78CCBC2C538D8000F38855 /* FUSPopularTagModel.m in Sources */ = {isa = PBXBuildFile; fileRef = BE78CAA92C538D7D00F38855 /* FUSPopularTagModel.m */; };
F05A12112F4B000100000001 /* FUSSearchAddedJumpModel.h in Headers */ = {isa = PBXBuildFile; fileRef = F05A12122F4B000100000001 /* FUSSearchAddedJumpModel.h */; };
F05A12132F4B000100000001 /* FUSSearchAddedJumpModel.m in Sources */ = {isa = PBXBuildFile; fileRef = F05A12142F4B000100000001 /* FUSSearchAddedJumpModel.m */; };
BE78CCC02C538D8000F38855 /* FUSSearchTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE78CAAE2C538D7D00F38855 /* FUSSearchTableViewCell.swift */; };
BE78CCC22C538D8000F38855 /* NSBundle+TZImagePicker.h in Headers */ = {isa = PBXBuildFile; fileRef = BE78CAB22C538D7D00F38855 /* NSBundle+TZImagePicker.h */; };
BE78CCC32C538D8000F38855 /* NSBundle+TZImagePicker.m in Sources */ = {isa = PBXBuildFile; fileRef = BE78CAB32C538D7D00F38855 /* NSBundle+TZImagePicker.m */; };
......@@ -1812,6 +1814,8 @@
BE78CAA42C538D7D00F38855 /* FUSSearchViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = FUSSearchViewController.xib; sourceTree = "<group>"; };
BE78CAA82C538D7D00F38855 /* FUSPopularTagModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSPopularTagModel.h; sourceTree = "<group>"; };
BE78CAA92C538D7D00F38855 /* FUSPopularTagModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSPopularTagModel.m; sourceTree = "<group>"; };
F05A12122F4B000100000001 /* FUSSearchAddedJumpModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSSearchAddedJumpModel.h; sourceTree = "<group>"; };
F05A12142F4B000100000001 /* FUSSearchAddedJumpModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSSearchAddedJumpModel.m; sourceTree = "<group>"; };
BE78CAAE2C538D7D00F38855 /* FUSSearchTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FUSSearchTableViewCell.swift; sourceTree = "<group>"; };
BE78CAAF2C538D7D00F38855 /* FUSSearchTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = FUSSearchTableViewCell.xib; sourceTree = "<group>"; };
BE78CAB22C538D7D00F38855 /* NSBundle+TZImagePicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSBundle+TZImagePicker.h"; sourceTree = "<group>"; };
......@@ -3559,6 +3563,8 @@
children = (
BE78CAA82C538D7D00F38855 /* FUSPopularTagModel.h */,
BE78CAA92C538D7D00F38855 /* FUSPopularTagModel.m */,
F05A12122F4B000100000001 /* FUSSearchAddedJumpModel.h */,
F05A12142F4B000100000001 /* FUSSearchAddedJumpModel.m */,
);
path = Model;
sourceTree = "<group>";
......@@ -4014,6 +4020,7 @@
BE78C89C2C53594B00F38855 /* FUSUserCenterModule.h in Headers */,
BE189A5D2C7323FE0008418B /* FSRPrivacyViewController.h in Headers */,
BE78CCB32C538D8000F38855 /* FUSMainSearchViewController.h in Headers */,
F05A12112F4B000100000001 /* FUSSearchAddedJumpModel.h in Headers */,
BE78CC052C538D7F00F38855 /* FUSPrivacySettingViewController.h in Headers */,
BE78CC332C538D7F00F38855 /* FUSSettingNetworkCherkAlert.h in Headers */,
BE78CC6F2C538D7F00F38855 /* FUSPublishPhotoCollectionViewCell.h in Headers */,
......@@ -4921,6 +4928,7 @@
BE78CC872C538D8000F38855 /* FUSNewsFeedCommentDetailListView.m in Sources */,
BE78CCB62C538D8000F38855 /* FUSSearchHttpHelper.swift in Sources */,
BE78CCBC2C538D8000F38855 /* FUSPopularTagModel.m in Sources */,
F05A12132F4B000100000001 /* FUSSearchAddedJumpModel.m in Sources */,
008AC5182D12CAAC00FECA7B /* FUSBackpackPropsView.swift in Sources */,
BE78CCEC2C538D8000F38855 /* FUSImagePickerViewController.m in Sources */,
BE78CC512C538D7F00F38855 /* FUSNewsFeedMessageDBHelper.m in Sources */,
......
......@@ -43,19 +43,31 @@ class FUSSearchHttpHelper: NSObject {
/// - pageIndex: 页码
/// - success:
/// - failure:
static func fus_searchUser(withKeyWord keyword:String, pageIndex:String,success: @escaping(_ listModel:NSArray, _ code:Int?)->Void, failure:@escaping((_ msg:String? ,_ code:Int?) -> Void)){
static func fus_searchUser(withKeyWord keyword:String, pageIndex:String,success: @escaping(_ listModel:NSArray, _ addedJumpModel:FUSSearchAddedJumpModel?, _ code:Int?)->Void, failure:@escaping((_ msg:String? ,_ code:Int?) -> Void)){
FUSHttpHelper.postRequestBinary(withUrl: FUSUserCenterURLs.fus_URL_ONLINE_SEARCH() as String, params: ["keyword":keyword,"page":pageIndex], success: { (dataDict, code) in
let list:NSArray = dataDict?["data"]! as! NSArray
var list:NSArray = []
let listTemp:NSMutableArray = []
var addedJumpModel:FUSSearchAddedJumpModel?
if dataDict?["data"] != nil {
list = dataDict?["data"]! as! NSArray
}
for dict in list{
let model = FUSMainSearchModel.fus_model(withDict: dict as? [AnyHashable : Any] ?? .init())
listTemp.add(model)
}
success(listTemp, Int(code))
if let addedDict = dataDict?["added"] as? [AnyHashable: Any] {
let model = FUSSearchAddedJumpModel.fus_model(withDict: addedDict)
if model.jumpType.isEmpty == false {
addedJumpModel = model
}
}
success(listTemp, addedJumpModel, Int(code))
}) { (dataDict, code) in
......
......@@ -38,6 +38,9 @@ public class FUSSearchViewController: FUSBaseViewController, UITableViewDelegate
private var startTimer:Timer?
private var recordDict = NSMutableDictionary()
/// 当前关键词下最近一次已处理的 added 跳转标识,用于避免重复触发。
private var lastHandledAddedJumpIdentifier = ""
var tableView:UITableView!
public override func viewDidLoad() {
......@@ -144,6 +147,7 @@ public class FUSSearchViewController: FUSBaseViewController, UITableViewDelegate
self.dataSource?.removeAllObjects()
self.tableView.reloadData()
self.pageindex = 1
self.lastHandledAddedJumpIdentifier = ""
if self.searchTextField.text != nil {
self.bgViewTopContraint.constant = -30
......@@ -322,7 +326,7 @@ public class FUSSearchViewController: FUSBaseViewController, UITableViewDelegate
return
}
FUSSearchHttpHelper.fus_searchUser(withKeyWord: keyword, pageIndex: pageIndex, success: { (models, code) in
FUSSearchHttpHelper.fus_searchUser(withKeyWord: keyword, pageIndex: pageIndex, success: { (models, addedJumpModel, code) in
UIApplication.shared.isNetworkActivityIndicatorVisible = false
if pageIndex == "1"{
......@@ -343,6 +347,11 @@ public class FUSSearchViewController: FUSBaseViewController, UITableViewDelegate
}
}
if let addedJumpModel = addedJumpModel,
addedJumpModel.jumpType.isEmpty == false {
self.fus_handleAddedJumpIfNeeded(addedJumpModel, keyword: keyword)
}
self.tableView.reloadData()
......@@ -359,6 +368,24 @@ public class FUSSearchViewController: FUSBaseViewController, UITableViewDelegate
}
}
/// 在同一轮关键词搜索中仅处理一次 added 跳转,避免重复打开页面。
/// - Parameters:
/// - addedJumpModel: 搜索接口返回的附加跳转模型。
/// - keyword: 当前触发搜索的关键词。
private func fus_handleAddedJumpIfNeeded(_ addedJumpModel: FUSSearchAddedJumpModel, keyword: String) {
let identifier = "\(keyword)|\(addedJumpModel.jumpType)|\(addedJumpModel.jumpParam)"
guard identifier.isEmpty == false else {
return
}
guard identifier != self.lastHandledAddedJumpIdentifier else {
return
}
self.lastHandledAddedJumpIdentifier = identifier
FUSRouter.userRouter().fus_handleTaskJumpAction(withJumpType: addedJumpModel.jumpType, tid: 0, url: addedJumpModel.jumpParam) {
}
}
// MARK: --UITableViewDataSource
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
......
//
// FUSSearchAddedJumpModel.h
// FusiLive
//
// Created by ludy on 2026/6/8.
// Copyright © 2024年 FusiYa. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// 搜索接口附带的额外跳转模型,用于承接 `/search/v2` 返回的 `added` 信息。
@interface FUSSearchAddedJumpModel : NSObject
/// 跳转类型,用于复用现有任务跳转链路。
@property (nonatomic, copy) NSString *jumpType;
/// 跳转参数,用于透传给现有任务跳转链路。
@property (nonatomic, copy) NSString *jumpParam;
/// 根据接口返回的 added 字典创建跳转模型。
/// - Parameter dict: 搜索接口返回的 added 字典。
+ (instancetype)fus_modelWithDict:(NSDictionary *)dict;
@end
NS_ASSUME_NONNULL_END
//
// FUSSearchAddedJumpModel.m
// FusiLive
//
// Created by ludy on 2026/6/8.
// Copyright © 2024年 FusiYa. All rights reserved.
//
#import "FUSSearchAddedJumpModel.h"
@implementation FUSSearchAddedJumpModel
+ (instancetype)fus_modelWithDict:(NSDictionary *)dict {
FUSSearchAddedJumpModel *model = [[FUSSearchAddedJumpModel alloc] init];
model.jumpType = [dict[@"jumpUrl"] isKindOfClass:NSString.class] ? dict[@"jumpUrl"] : @"";
model.jumpParam = [dict[@"jumpParam"] isKindOfClass:NSString.class] ? dict[@"jumpParam"] : @"";
return model;
}
@end
......@@ -9,6 +9,7 @@
#define FUSUserCenterOCHeader_h
#import "FUSMainSearchModel.h"
#import "FUSSearchAddedJumpModel.h"
#import "FUSLoginHttpHelper.h"
#import "FUSZoneHttpRequest.h"
......
......@@ -531,7 +531,7 @@
// 在线搜索
+ (NSString *)fus_URL_ONLINE_SEARCH {
return [FUSConfig.sharedInstanced.pathConfigs apiUrl:@"/user/searchmore.html"];
return [FUSConfig.sharedInstanced.pathConfigs apiUrl:@"/search/v2"];
}
// 亲密关系搜索
......
......@@ -49,6 +49,7 @@
#import "FUSTaskCenterListModel.h"
#import "FUSUserCenterModule/FUSUserCenterModule-Swift.h"
#import <FUSCommon/FUSCommon-Swift.h>
@interface FUSUserCenterRouter ()
......@@ -838,10 +839,13 @@
}];
} else if ([jumpType isEqualToString:@"yazhai://_jump_url"]) {
FUSWKWebViewController *wkwVC = [[FUSWKWebViewController alloc] init];
wkwVC.webUrlString = url;
wkwVC.shouldIncludeIdentifyInfo = YES;
[[UIViewController fus_topViewController].navigationController pushViewController:wkwVC animated:YES];
[[FUSFlutterBridge shared] openFlutterDispatchIfSupportedWithWebUrl:url showHeadInUserData:YES fallback:^{
FUSWKWebViewController *wkwVC = [[FUSWKWebViewController alloc] init];
wkwVC.webUrlString = url;
wkwVC.shouldIncludeIdentifyInfo = YES;
[[UIViewController fus_topViewController].navigationController pushViewController:wkwVC animated:YES];
}];
} else if ([jumpType isEqualToString:@"yazhai://_app_share"]) {
[self fus_requestShareContent:[NSString stringWithFormat:@"%ld",tid]];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment