角色数据完善
This commit is contained in:
parent
626c4d6fb8
commit
2c6bb330af
|
|
@ -0,0 +1,59 @@
|
||||||
|
//
|
||||||
|
// TopHeaderManager.swift
|
||||||
|
// Visual_Novel_iOS
|
||||||
|
//
|
||||||
|
// Created by mh on 2025/11/10.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
import Combine
|
||||||
|
import SnapKit
|
||||||
|
|
||||||
|
final class TopHeaderManager {
|
||||||
|
|
||||||
|
static let shared = TopHeaderManager()
|
||||||
|
|
||||||
|
private(set) lazy var headerView: CLTopHeaderView = {
|
||||||
|
let view = CLTopHeaderView()
|
||||||
|
return view
|
||||||
|
}()
|
||||||
|
|
||||||
|
private var hostingView: UIView?
|
||||||
|
private var topConstraint: Constraint?
|
||||||
|
private var heightConstraint: Constraint?
|
||||||
|
|
||||||
|
private init() {}
|
||||||
|
|
||||||
|
var jumpPublisher: AnyPublisher<JumpTarget, Never> {
|
||||||
|
headerView.jumpPublisher
|
||||||
|
}
|
||||||
|
|
||||||
|
func attachIfNeeded(to viewController: UIViewController) {
|
||||||
|
guard hostingView !== viewController.view else { return }
|
||||||
|
detach()
|
||||||
|
let container = viewController.view!
|
||||||
|
container.addSubview(headerView)
|
||||||
|
headerView.snp.makeConstraints { make in
|
||||||
|
topConstraint = make.top.equalToSuperview().constraint
|
||||||
|
make.leading.trailing.equalToSuperview()
|
||||||
|
heightConstraint = make.height.equalTo(UIDevice().navHeight).constraint
|
||||||
|
}
|
||||||
|
hostingView = container
|
||||||
|
headerView.isHidden = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func show() {
|
||||||
|
headerView.isHidden = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func hide() {
|
||||||
|
headerView.isHidden = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func detach() {
|
||||||
|
headerView.removeFromSuperview()
|
||||||
|
hostingView = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -28,6 +28,7 @@ class SessionController: CLBaseViewController {
|
||||||
var pureBgOperateView:SessionPureBgOperateView!
|
var pureBgOperateView:SessionPureBgOperateView!
|
||||||
|
|
||||||
var titleStr: String? = nil
|
var titleStr: String? = nil
|
||||||
|
var avatar: String? = nil
|
||||||
|
|
||||||
// 长按菜单响应的cell
|
// 长按菜单响应的cell
|
||||||
var menuCell: SessionCell?
|
var menuCell: SessionCell?
|
||||||
|
|
@ -83,10 +84,12 @@ class SessionController: CLBaseViewController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
convenience init(conversationId: String, title: String? = "") {
|
convenience init(conversationId: String, title: String? = "", avatar: String? = "") {
|
||||||
self.init()
|
self.init()
|
||||||
self.conversationId = conversationId
|
self.conversationId = conversationId
|
||||||
self.titleStr = title
|
self.titleStr = title
|
||||||
|
self.avatar = avatar
|
||||||
|
self.navigationView.iconImgView.sd_setImage(with: URL(string: avatar ?? ""), placeholderImage: nil)
|
||||||
conversation = V2NIMConversation()
|
conversation = V2NIMConversation()
|
||||||
|
|
||||||
let stings = conversationId.components(separatedBy: "|")
|
let stings = conversationId.components(separatedBy: "|")
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ struct RoleListRequest: Codable {
|
||||||
var limit = 20
|
var limit = 20
|
||||||
var name: String = ""
|
var name: String = ""
|
||||||
var sourceId: String = ""
|
var sourceId: String = ""
|
||||||
var tagId: [String]?
|
var tagIds: [String]?
|
||||||
}
|
}
|
||||||
|
|
||||||
// model
|
// model
|
||||||
|
|
@ -31,12 +31,20 @@ struct RoleItem: Codable {
|
||||||
var id: String = ""
|
var id: String = ""
|
||||||
var name: String = ""
|
var name: String = ""
|
||||||
var coverImage: String = ""
|
var coverImage: String = ""
|
||||||
|
// 角色头像
|
||||||
|
var headPortrait: String = ""
|
||||||
var score: Double?
|
var score: Double?
|
||||||
var description: String = ""
|
var description: String = ""
|
||||||
var updateTime: String = ""
|
var updateTime: String = ""
|
||||||
var sourceId: String = ""
|
var sourceId: String = ""
|
||||||
var sourceType: Int = 0
|
var sourceType: Int = 0
|
||||||
var commonCount: Int?
|
var commonCount: Int?
|
||||||
|
var tags: [tagItem] = []
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tagItem: Codable {
|
||||||
|
var name: String = ""
|
||||||
|
var tagId: String = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
class ChatRoleViewModel {
|
class ChatRoleViewModel {
|
||||||
|
|
@ -47,7 +55,7 @@ class ChatRoleViewModel {
|
||||||
req.limit = limit
|
req.limit = limit
|
||||||
req.name = name
|
req.name = name
|
||||||
req.sourceId = sourceId
|
req.sourceId = sourceId
|
||||||
req.tagId = tagId
|
req.tagIds = tagId
|
||||||
|
|
||||||
let params = req.toNonNilDictionary()
|
let params = req.toNonNilDictionary()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -133,9 +133,13 @@ class CLRoleCollectionCell: UICollectionViewCell {
|
||||||
|
|
||||||
// MARK: data
|
// MARK: data
|
||||||
func setupData(item: RoleItem) {
|
func setupData(item: RoleItem) {
|
||||||
descLab.text = item.name
|
descLab.text = item.description
|
||||||
nameLab.text = item.name
|
nameLab.text = item.name
|
||||||
coverImgView.sd_setImage(with: URL(string: item.coverImage), placeholderImage: nil)
|
coverImgView.sd_setImage(with: URL(string: item.coverImage), placeholderImage: nil)
|
||||||
|
tagLab.text = item.tags.compactMap { $0.name }.joined(separator: "/")
|
||||||
|
// 0:小说;1:漫剧;2:用户自定义
|
||||||
|
self.bookBgImgView.isHidden = item.sourceType != 0
|
||||||
|
self.playImgView.isHidden = item.sourceType != 1
|
||||||
// coverImgView.
|
// coverImgView.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,7 @@ extension RolesRootPageView: UICollectionViewDelegate, UICollectionViewDataSourc
|
||||||
if data.count > indexPath.item {
|
if data.count > indexPath.item {
|
||||||
let item = data[indexPath.item]
|
let item = data[indexPath.item]
|
||||||
let sessionId = "439217670979585@r@t"
|
let sessionId = "439217670979585@r@t"
|
||||||
AppRouter.goChatVC(conversationId: sessionId, title: item.name, complete: nil)
|
AppRouter.goChatVC(conversationId: sessionId, title: item.name, avatar: item.headPortrait, complete: nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,11 +35,11 @@ extension AppRouter{
|
||||||
complete?()
|
complete?()
|
||||||
}
|
}
|
||||||
|
|
||||||
static func goChatVC(conversationId: String?, title: String? = nil, complete: (() -> Void)? = nil) {
|
static func goChatVC(conversationId: String?, title: String? = nil, avatar: String? = nil, complete: (() -> Void)? = nil) {
|
||||||
// guard UserCore.shared.checkUserLoginIfNotPushUserToLogin() else{return}
|
// guard UserCore.shared.checkUserLoginIfNotPushUserToLogin() else{return}
|
||||||
|
|
||||||
guard let sessionId = conversationId else{return}
|
guard let sessionId = conversationId else{return}
|
||||||
let vc = SessionController(conversationId: sessionId, title: title)
|
let vc = SessionController(conversationId: sessionId, title: title, avatar: avatar)
|
||||||
let nvc = UIWindow.getTopViewController(base: UIWindow.applicationKey?.rootViewController)?.navigationController
|
let nvc = UIWindow.getTopViewController(base: UIWindow.applicationKey?.rootViewController)?.navigationController
|
||||||
nvc?.pushViewController(vc, animated: true)
|
nvc?.pushViewController(vc, animated: true)
|
||||||
complete?()
|
complete?()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue