调整标题

This commit is contained in:
Fin 2024-11-27 18:26:57 +08:00
parent ff866de90f
commit ba899f0a04
3 changed files with 9 additions and 4 deletions

View File

@ -17,6 +17,11 @@ class Server: Codable {
let address: String
var key: String
var state: Client.ClienState
var host: String {
return URL(string: address)?.host ?? ""
}
init(id: String = UUID().uuidString, address: String, key: String, state: Client.ClienState = .ok) {
self.id = id
self.address = address

View File

@ -120,7 +120,7 @@ class HomeViewModel: ViewModel, ViewModelType {
]
func transform(input: Input) -> Output {
let title = BehaviorRelay(value: URL(string: ServerManager.shared.currentServer.address)?.host ?? "")
let title = BehaviorRelay(value: ServerManager.shared.currentServer.host)
let sectionModel = SectionModel(
model: "previews",
@ -195,7 +195,7 @@ class HomeViewModel: ViewModel, ViewModelType {
default: break
}
// url scheme state便
title.accept(ServerManager.shared.currentServer.address)
title.accept(ServerManager.shared.currentServer.host)
})
.disposed(by: rx.disposeBag)
@ -207,7 +207,7 @@ class HomeViewModel: ViewModel, ViewModelType {
(model as! ServerListViewModel).currentServerChanged.asDriver(onErrorDriveWith: .empty())
}
.map { server -> String in
(try? server.address.asURL().host) ?? ""
server.host
}
.drive(title)
.disposed(by: rx.disposeBag)

View File

@ -81,7 +81,7 @@ class NewServerViewModel: ViewModel, ViewModelType {
ServerManager.shared.setCurrentServer(serverId: server.id)
ServerManager.shared.syncAllServers()
strongSelf.pop.accept(strongSelf.url)
strongSelf.pop.accept(URL(string: strongSelf.url)?.host ?? "")
showSnackbar.accept(NSLocalizedString("AddedSuccessfully"))
case .failure(let error):
showSnackbar.accept("\(NSLocalizedString("InvalidServer"))\(error.rawString())")