diff --git a/.version b/.version index 2f57b4f..291bdc0 100644 --- a/.version +++ b/.version @@ -1,6 +1,6 @@ { - "latestVersionNum": 14, - "latestVersion": "2.0.0-RC", + "latestVersionNum": 15, + "latestVersion": "2.1.0", "updateType": "hint", - "releaseNotes": "1. 使用TCA重构,逻辑代码抽离到store后,更清晰! \n2. 使用Table组件,统一,删除,双击,右键操作。 \n3. zset默认按score顺序返回 \n4. keys, set , zset, hash等scan 优化,没有使用通配符时,直接查找 \n5. 还有很多改变,后面增加新功能时会顺手很多了!" + "releaseNotes": "1. 使用界面添加Key时,无法同时设置key名和value bug #43! \n2. 登录redis后修改窗标题 #41。 \n3. redis 列表拖拽排序 #35 \n4. 测试链接loading没有消失bug!" } diff --git a/redis-pro.xcodeproj/project.pbxproj b/redis-pro.xcodeproj/project.pbxproj index 4f34b3a..09b684f 100644 --- a/redis-pro.xcodeproj/project.pbxproj +++ b/redis-pro.xcodeproj/project.pbxproj @@ -1223,7 +1223,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 14; + CURRENT_PROJECT_VERSION = 15; DEVELOPMENT_ASSET_PATHS = "\"redis-pro/Preview Content\""; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = "redis-pro/Info.plist"; @@ -1232,7 +1232,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 2.0.0; + MARKETING_VERSION = 2.1.0; PRODUCT_BUNDLE_IDENTIFIER = "com.cmushroom.redis-pro"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -1248,7 +1248,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 14; + CURRENT_PROJECT_VERSION = 15; DEVELOPMENT_ASSET_PATHS = "\"redis-pro/Preview Content\""; DEVELOPMENT_TEAM = ""; ENABLE_PREVIEWS = YES; @@ -1258,7 +1258,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 2.0.0; + MARKETING_VERSION = 2.1.0; PRODUCT_BUNDLE_IDENTIFIER = "com.cmushroom.redis-pro"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/redis-pro.xcodeproj/project.xcworkspace/xcuserdata/chengpan.xcuserdatad/UserInterfaceState.xcuserstate b/redis-pro.xcodeproj/project.xcworkspace/xcuserdata/chengpan.xcuserdatad/UserInterfaceState.xcuserstate index 52f97aa..a265fda 100644 Binary files a/redis-pro.xcodeproj/project.xcworkspace/xcuserdata/chengpan.xcuserdatad/UserInterfaceState.xcuserstate and b/redis-pro.xcodeproj/project.xcworkspace/xcuserdata/chengpan.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/redis-pro.xcodeproj/xcuserdata/chengpan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/redis-pro.xcodeproj/xcuserdata/chengpan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index d775bd4..7ce1ede 100644 --- a/redis-pro.xcodeproj/xcuserdata/chengpan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/redis-pro.xcodeproj/xcuserdata/chengpan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -7,15 +7,15 @@ @@ -23,113 +23,81 @@ - - - - - - + startingLineNumber = "316" + endingLineNumber = "316" + landmarkName = "tableView(_:pasteboardWriterForRow:)" + landmarkType = "7"> + startingLineNumber = "334" + endingLineNumber = "334" + landmarkName = "tableView(_:acceptDrop:row:dropOperation:)" + landmarkType = "7"> + startingLineNumber = "341" + endingLineNumber = "341" + landmarkName = "tableView(_:acceptDrop:row:dropOperation:)" + landmarkType = "7"> + startingLineNumber = "312" + endingLineNumber = "312" + landmarkName = "tableView(_:pasteboardWriterForRow:)" + landmarkType = "7"> diff --git a/redis-pro/Common/UserDefaults/RedisDefaults.swift b/redis-pro/Common/UserDefaults/RedisDefaults.swift index d299a0f..b939d83 100644 --- a/redis-pro/Common/UserDefaults/RedisDefaults.swift +++ b/redis-pro/Common/UserDefaults/RedisDefaults.swift @@ -95,6 +95,13 @@ class RedisDefaults { return r } + static func save(_ redisModels:[RedisModel]) -> Bool { + let redisDics = redisModels.map { $0.dictionary } + + userDefaults.set(redisDics, forKey: UserDefaulsKeysEnum.RedisFavoriteListKey.rawValue) + logger.info("save all redis to user defaults complete") + return true + } static func delete(redisModel:RedisModel) -> String? { return delete(id: redisModel.id) diff --git a/redis-pro/Model/RedisModel.swift b/redis-pro/Model/RedisModel.swift index 640557c..c099236 100644 --- a/redis-pro/Model/RedisModel.swift +++ b/redis-pro/Model/RedisModel.swift @@ -9,11 +9,12 @@ import Foundation import SwiftUI class RedisModel: NSObject, ObservableObject, Identifiable { - var id: String = UUID().uuidString + @objc var id: String = UUID().uuidString @objc @Published var name: String = "New Favorite" @Published var host: String = "127.0.0.1" @Published var port: Int = 6379 @Published var database: Int = 0 + var user: String = "default" @Published var password: String = "" @Published var isFavorite: Bool = false @Published var ping: Bool = false diff --git a/redis-pro/Store/FavoriteStore.swift b/redis-pro/Store/FavoriteStore.swift index 3fb84fb..5161f13 100644 --- a/redis-pro/Store/FavoriteStore.swift +++ b/redis-pro/Store/FavoriteStore.swift @@ -10,7 +10,7 @@ import ComposableArchitecture struct FavoriteState: Equatable { var globalState: GlobalState? - var tableState: TableState = TableState(columns: [NTableColumn(title: "FAVORITES", key: "name", width: 50, icon: .APP)], datasource: [], selectIndex: -1) + var tableState: TableState = TableState(columns: [NTableColumn(title: "FAVORITES", key: "name", width: 50, icon: .APP)], datasource: [], selectIndex: -1, dragable: true) var loginState: LoginState = LoginState() // init(globalState: GlobalState) { @@ -135,7 +135,12 @@ let favoriteReducer = Reducer.combin state, action, _ in switch action { case .show: - let loadingCount = state.loadingCount - if loadingCount <= 0 { + if state.loadingCount <= 0 { state.loading = true } - state.loadingCount = loadingCount + 1 - + state.loadingCount += 1 return .none case .hide: - let loadingCount = state.loadingCount - state.loadingCount = min(loadingCount - 1, 0) - - if loadingCount <= 0 { + state.loadingCount -= 1 + if state.loadingCount <= 0 { state.loading = false + state.loadingCount = 0 } return .none diff --git a/redis-pro/Store/KeyStore.swift b/redis-pro/Store/KeyStore.swift index c4ad82c..e01c8b4 100644 --- a/redis-pro/Store/KeyStore.swift +++ b/redis-pro/Store/KeyStore.swift @@ -41,7 +41,7 @@ struct KeyState: Equatable { enum KeyAction:BindableAction, Equatable { case initial case refresh - case updateKey(String) + case setKey(String) case getTtl case submit case saveTtl @@ -70,7 +70,7 @@ let keyReducer = Reducer.combine( .success(.getTtl) } - case let .updateKey(key): + case let .setKey(key): state.key = key return .none case .getTtl: diff --git a/redis-pro/Store/LoginStore.swift b/redis-pro/Store/LoginStore.swift index efd35eb..badc947 100644 --- a/redis-pro/Store/LoginStore.swift +++ b/redis-pro/Store/LoginStore.swift @@ -15,6 +15,7 @@ struct LoginState: Equatable { @BindableState var host: String = "127.0.0.1" @BindableState var port: Int = 6379 @BindableState var database: Int = 0 + @BindableState var user: String = "default" @BindableState var password: String = "" @BindableState var connectionType:String = "tcp" @@ -39,6 +40,7 @@ struct LoginState: Equatable { redisModel.host = host redisModel.port = port redisModel.database = database + redisModel.user = user redisModel.password = password redisModel.connectionType = connectionType redisModel.sshHost = sshHost @@ -54,6 +56,7 @@ struct LoginState: Equatable { self.host = n.host self.port = n.port self.database = n.database + self.user = n.user self.password = n.password self.connectionType = n.connectionType self.sshHost = n.sshHost diff --git a/redis-pro/Store/TableStore.swift b/redis-pro/Store/TableStore.swift index 9670bf2..acb33b8 100644 --- a/redis-pro/Store/TableStore.swift +++ b/redis-pro/Store/TableStore.swift @@ -17,6 +17,7 @@ struct TableState: Equatable { // 一定要设置-1, 其它值会在view 刷新时, 陷入无限循环 var selectIndex:Int = -1 var defaultSelectIndex:Int = -1 + var dragable: Bool = false } enum TableAction:Equatable { @@ -26,6 +27,7 @@ enum TableAction:Equatable { case contextMenu(String, Int) case refresh case reset + case dragComplete(Int, Int) } struct TableEnvironment { } @@ -58,5 +60,14 @@ let tableReducer = Reducer { state.selectIndex = -1 state.datasource = [] return .none + + case let .dragComplete(from, to): + state.selectIndex = to + + let f = state.datasource[from] + state.datasource[from] = state.datasource[to] + state.datasource[to] = f + + return .none } }.debug() diff --git a/redis-pro/Store/ValueStore.swift b/redis-pro/Store/ValueStore.swift index 95a7f07..e942ccf 100644 --- a/redis-pro/Store/ValueStore.swift +++ b/redis-pro/Store/ValueStore.swift @@ -29,6 +29,7 @@ enum ValueAction:BindableAction, Equatable { case initial case refresh case none + case setKeyModel((RedisKeyModel)) case keyChange(RedisKeyModel) case submitSuccess(Bool) case keyAction(KeyAction) @@ -91,6 +92,21 @@ let valueReducer = Reducer.combine( case .none: return .none + case let .setKeyModel(redisKeyModel): + state.keyState.redisKeyModel = redisKeyModel + + if redisKeyModel.type == RedisKeyTypeEnum.STRING.rawValue { + state.stringValueState.redisKeyModel = redisKeyModel + } else if redisKeyModel.type == RedisKeyTypeEnum.HASH.rawValue { + state.hashValueState.redisKeyModel = redisKeyModel + } else if redisKeyModel.type == RedisKeyTypeEnum.LIST.rawValue { + state.listValueState.redisKeyModel = redisKeyModel + } else if redisKeyModel.type == RedisKeyTypeEnum.SET.rawValue { + state.setValueState.redisKeyModel = redisKeyModel + } else if redisKeyModel.type == RedisKeyTypeEnum.ZSET.rawValue { + state.zsetValueState.redisKeyModel = redisKeyModel + } + return .none // key 变化统计走此action 分发 case let .keyChange(redisKeyModel): state.keyState.redisKeyModel = redisKeyModel @@ -130,7 +146,13 @@ let valueReducer = Reducer.combine( return .result { .success(.keyAction(.refresh)) } + + case let .keyAction(.setKey(key)): + let redisKeyModel = state.keyState.redisKeyModel + return .result { + .success(.setKeyModel(redisKeyModel)) + } case .keyAction(.setType): let redisKeyModel = state.keyState.redisKeyModel return .result { diff --git a/redis-pro/Views/Components/Table/NTable.swift b/redis-pro/Views/Components/Table/NTable.swift index d9a41d1..0084beb 100644 --- a/redis-pro/Views/Components/Table/NTable.swift +++ b/redis-pro/Views/Components/Table/NTable.swift @@ -12,12 +12,6 @@ import Combine import ComposableArchitecture struct NTableView: NSViewControllerRepresentable { -// var columns:[NTableColumn] = [NTableColumn]() -// @Binding var datasource:[AnyHashable] -// @Binding var selectIndex:Int -// var onChange: ((Int, AnyHashable) -> Void)? -// var onDelete: ((Int, AnyHashable) -> Void)? -// var onDouble: ((Int, AnyHashable) -> Void)? let store: Store @@ -32,17 +26,8 @@ struct NTableView: NSViewControllerRepresentable { func makeNSViewController(context: Context) -> NSViewController { let controller = NTableController(store) -// controller.onChangeAction = self.onChange -// controller.onDeleteAction = self.onDelete -// controller.onDoubleAction = self.onDouble -// controller.columns = columns - -// controller.tableView.delegate = context.coordinator - -// controller.datasource = datasource -// controller.setUp(action: self.onClick, deleteAction: self.deleteAction, renameAction: self.renameAction) -// controller.tableView.delegate = context.coordinator -// controller.tableView.dataSource = context.coordinator + // controller.tableView.delegate = context.coordinator + // controller.tableView.dataSource = context.coordinator logger.debug("ntable make nsview controller....") return controller @@ -50,23 +35,7 @@ struct NTableView: NSViewControllerRepresentable { func updateNSViewController(_ nsViewController: NSViewController, context: Context) { -// guard let controller = nsViewController as? NTableController else {return} -// controller.setDatasource(datasource) -// controller.tableView.delegate = context.coordinator -// controller.tableView.dataSource = context.coordinator - logger.debug("ntable update nsview controller") - - //TODO 刷新次数太多,考虑优化 -// controller.refresh(self.datasource) - -// if self.selectIndex != controller.arrayController.selectionIndex { -// controller.arrayController.setSelectionIndex(self.selectIndex) -// } - -// DispatchQueue.main.async { -// controller.arrayController.setSelectionIndex(self.selectIndex) -// } } class Coordinator: NSObject, NSTableViewDelegate, NSTableViewDataSource { @@ -82,16 +51,19 @@ struct NTableView: NSViewControllerRepresentable { } } -class NTableController: NSViewController, NSTableViewDelegate, NSTableViewDataSource { +class NTableController: NSViewController{ -// var columns:[NTableColumn] = [NTableColumn]() + // var columns:[NTableColumn] = [NTableColumn]() @objc dynamic var datasource:[AnyHashable] = [] var arrayController = NSArrayController() var initialized = false let scrollView = NSScrollView() let tableView = NSTableView() - let viewStore: ViewStore + // drag + let pasteboardType = NSPasteboard.PasteboardType.string + + var viewStore: ViewStore var cancellables: Set = [] var observation: NSKeyValueObservation? @@ -120,7 +92,7 @@ class NTableController: NSViewController, NSTableViewDelegate, NSTableViewDataSo override func loadView() { self.view = NSView() } - + override func viewDidLoad() { super.viewDidLoad() if initialized { @@ -130,26 +102,32 @@ class NTableController: NSViewController, NSTableViewDelegate, NSTableViewDataSo // listen app color scheme observation = NSApp.observe(\.effectiveAppearance) { (app, _) in - app.effectiveAppearance.performAsCurrentDrawingAppearance { - // Invoke your non-view code that needs to be aware of the - // change in appearance. - self.logger.info("app color scheme change, update table view ...") - self.view.appearance = NSApp.appearance - self.tableView.appearance = NSApp.appearance - } - } - + app.effectiveAppearance.performAsCurrentDrawingAppearance { + // Invoke your non-view code that needs to be aware of the + // change in appearance. + self.logger.info("app color scheme change, update table view ...") + self.view.appearance = NSApp.appearance + self.tableView.appearance = NSApp.appearance + } + } + tableView.allowsEmptySelection = false + // 设置可drag + if self.viewStore.dragable { + tableView.registerForDraggedTypes([pasteboardType]) + } + + // bind datasource, select index arrayController.bind(.contentArray, to: self, withKeyPath: "datasource", options: nil) tableView.bind(.content, to: arrayController, withKeyPath: "arrangedObjects", options: nil) tableView.bind(.selectionIndexes, to: arrayController, withKeyPath:"selectionIndexes", options: nil) - + setupView() setupTableView() - // 监听 + // 监听默认选中 self.viewStore.publisher.defaultSelectIndex .sink(receiveValue: { self.logger.debug("table store select index publisher, index: \($0)") @@ -158,6 +136,7 @@ class NTableController: NSViewController, NSTableViewDelegate, NSTableViewDataSo }) .store(in: &self.cancellables) + // 监听数据变化 self.viewStore.publisher.datasource .sink(receiveValue: { self.logger.debug("table store data source publisher, data source length: \($0.count)") @@ -179,20 +158,20 @@ class NTableController: NSViewController, NSTableViewDelegate, NSTableViewDataSo } } -// override func viewDidLayout() { -// if !initialized { -// initialized = true -// } -// } + // override func viewDidLayout() { + // if !initialized { + // initialized = true + // } + // } /** - NSLayoutConstraint(item: 视图, - attribute: 约束属性, - relatedBy: 约束关系, - toItem: 参照视图, - attribute: 参照属性, - multiplier: 乘积, - constant: 约束数值) + NSLayoutConstraint(item: 视图, + attribute: 约束属性, + relatedBy: 约束关系, + toItem: 参照视图, + attribute: 参照属性, + multiplier: 乘积, + constant: 约束数值) */ func setupView() { //使用Auto Layout的方式来布局 @@ -208,10 +187,10 @@ class NTableController: NSViewController, NSTableViewDelegate, NSTableViewDataSo self.view.addConstraint(NSLayoutConstraint(item: self.scrollView, attribute: .bottom, relatedBy: .equal, toItem: self.view, attribute: .bottom, multiplier: 1.0, constant: 0)) tableView.frame = scrollView.bounds tableView.delegate = self + tableView.dataSource = self -// tableView.dataSource = self tableView.usesAlternatingRowBackgroundColors = true -// tableView.headerView = nil + // tableView.headerView = nil scrollView.backgroundColor = NSColor.clear scrollView.drawsBackground = false scrollView.autohidesScrollers = true @@ -232,49 +211,18 @@ class NTableController: NSViewController, NSTableViewDelegate, NSTableViewDataSo col.title = column.title tableView.addTableColumn(col) } - + // 最后一列自适应 tableView.sizeLastColumnToFit() scrollView.documentView = tableView -// scrollView.addSubview(tableView) + // scrollView.addSubview(tableView) scrollView.hasHorizontalScroller = false scrollView.hasVerticalScroller = true } - - - // 构建单元格 - func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? { - guard let tableColumn = tableColumn else { - return nil - } - - - guard let column = self.viewStore.columns.filter({ $0.key == tableColumn.identifier.rawValue}).first else { return nil } - - var tableCellView = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(column.key), owner: self) as? TableCellView - if tableCellView == nil { - tableCellView = TableCellView(tableView, tableColumn: tableColumn, column: column, row: row) - } - - return tableCellView - } - func tableViewSelectionDidChange(_ notification: Notification) { - guard let tableView = notification.object as? NSTableView else {return} - - let selectIndex = tableView.selectedRow - self.logger.info("table coordinator selection did change, selectedRow: \(selectIndex)") - -// guard self.datasource.count > selectIndex && selectIndex > -1 else {return} - -// self.selectIndex = tableView.selectedRow -// self.onChangeAction?(tableView.selectedRow, self.datasource[selectIndex]) - - self.viewStore.send(.selectionChange(selectIndex)) - } // 监听键盘删除事件 override func keyDown(with event: NSEvent) { @@ -283,7 +231,7 @@ class NTableController: NSViewController, NSTableViewDelegate, NSTableViewDataSo let selectIndex = tableView.selectedRow if selectIndex > -1 { -// self.onDeleteAction?(selectIndex, self.datasource[selectIndex]) + // self.onDeleteAction?(selectIndex, self.datasource[selectIndex]) self.viewStore.send(.delete(selectIndex)) } } @@ -315,6 +263,99 @@ class NTableController: NSViewController, NSTableViewDelegate, NSTableViewDataSo logger.info("context menu action, index: \(index)") self.viewStore.send(.contextMenu(menuItem.title, index)) } + +} + +//NSTableViewDelegate +extension NTableController: NSTableViewDelegate { + + // 构建单元格 + func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? { + guard let tableColumn = tableColumn else { + return nil + } + + + guard let column = self.viewStore.columns.filter({ $0.key == tableColumn.identifier.rawValue}).first else { return nil } + + var tableCellView = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(column.key), owner: self) as? TableCellView + if tableCellView == nil { + tableCellView = TableCellView(tableView, tableColumn: tableColumn, column: column, row: row) + } + + return tableCellView + } + + func tableViewSelectionDidChange(_ notification: Notification) { + guard let tableView = notification.object as? NSTableView else {return} + + let selectIndex = tableView.selectedRow + self.logger.info("table coordinator selection did change, selectedRow: \(selectIndex)") + + // guard self.datasource.count > selectIndex && selectIndex > -1 else {return} + + // self.selectIndex = tableView.selectedRow + // self.onChangeAction?(tableView.selectedRow, self.datasource[selectIndex]) + + self.viewStore.send(.selectionChange(selectIndex)) + } + +} + +// NSTableViewDataSource +extension NTableController: NSTableViewDataSource { + + // 获取id + // For the source table view + func tableView(_ tableView: NSTableView, pasteboardWriterForRow row: Int) -> NSPasteboardWriting? { + + let rowAnyObj = self.viewStore.datasource[self.viewStore.selectIndex] + + let value = "\(rowAnyObj.hashValue)" + + let pasteboardItem = NSPasteboardItem() + pasteboardItem.setString(value, forType: pasteboardType) + return pasteboardItem + } + + // For the destination table view + func tableView(_ tableView: NSTableView, validateDrop info: NSDraggingInfo, proposedRow row: Int, proposedDropOperation dropOperation: NSTableView.DropOperation) -> NSDragOperation { + if dropOperation == .above { + return .move + } else { + return [] + } + } + + // For the destination table view + func tableView(_ tableView: NSTableView, acceptDrop info: NSDraggingInfo, row: Int, dropOperation: NSTableView.DropOperation) -> Bool { + guard + let that = info.draggingPasteboard.pasteboardItems?.first, + let theString = that.string(forType: pasteboardType), +// let index = self.viewStore.datasource.first(where: { "\($0.hashValue)" == theString }), + let originalRow = self.viewStore.datasource.firstIndex(where: { item in + return "\(item.hashValue)" == theString + }) + else { return false } + + var newRow = row + // When you drag an item downwards, the "new row" index is actually --1. Remember dragging operation is `.above`. + if originalRow < newRow { + newRow = row - 1 + } + + // Animate the rows +// tableView.beginUpdates() +// tableView.moveRow(at: originalRow, to: newRow) +// tableView.endUpdates() + + // Persist the ordering by saving your data model + // saveAccountsReordered(at: originalRow, to: newRow) + self.viewStore.send(.dragComplete(originalRow, newRow)) + logger.info("drad complete, at: \(originalRow), to: \(newRow)") + + return true + } } //struct NTable_Previews: PreviewProvider { diff --git a/redis-pro/Views/HomeView.swift b/redis-pro/Views/HomeView.swift index 9f623d4..6b9a185 100644 --- a/redis-pro/Views/HomeView.swift +++ b/redis-pro/Views/HomeView.swift @@ -19,7 +19,7 @@ struct HomeView: View { } var body: some View { - WithViewStore(store) {viewStore in + WithViewStore(store.scope(state: \.title)) {viewStore in RedisKeysListView(store) .onAppear { @@ -29,6 +29,8 @@ struct HomeView: View { logger.info("redis pro home view destroy...") viewStore.send(.onClose) } + // 设置window标题 + .navigationTitle(viewStore.state) } } diff --git a/redis-pro/Views/IndexView.swift b/redis-pro/Views/IndexView.swift index 2b56209..fb7a060 100644 --- a/redis-pro/Views/IndexView.swift +++ b/redis-pro/Views/IndexView.swift @@ -32,8 +32,6 @@ struct IndexView: View { VStack { if (viewStore.state) { HomeView(store) - // 设置window标题 - // .navigationTitle(viewStore.title) } else { LoginView(store: store) } diff --git a/redis-pro/Views/Login/LoginForm.swift b/redis-pro/Views/Login/LoginForm.swift index 6891d86..ff52fac 100644 --- a/redis-pro/Views/Login/LoginForm.swift +++ b/redis-pro/Views/Login/LoginForm.swift @@ -77,6 +77,7 @@ struct LoginForm: View { FormItemText(label: "Name", placeholder: "name", value: viewStore.binding(\.$name)) FormItemText(label: "Host", placeholder: "host", value: viewStore.binding(\.$host)) FormItemInt(label: "Port", placeholder: "port", value: viewStore.binding(\.$port)) +// FormItemText(label: "User", placeholder: "default", value: viewStore.binding(\.$user)) FormItemPassword(label: "Password", value: viewStore.binding(\.$password)) FormItemInt(label: "Database", value: viewStore.binding(\.$database)) } @@ -97,6 +98,7 @@ struct LoginForm: View { FormItemText(label: "Name", placeholder: "name", value: viewStore.binding(\.$name)) FormItemText(label: "Host", placeholder: "host", value: viewStore.binding(\.$host)) FormItemInt(label: "Port", placeholder: "port", value: viewStore.binding(\.$port)) +// FormItemText(label: "User", placeholder: "default", value: viewStore.binding(\.$user)) FormItemPassword(label: "Password", value: viewStore.binding(\.$password)) FormItemInt(label: "Database", value: viewStore.binding(\.$database)) } diff --git a/redis-pro/Views/Login/RedisListView.swift b/redis-pro/Views/Login/RedisListView.swift index 7109758..83a97e1 100644 --- a/redis-pro/Views/Login/RedisListView.swift +++ b/redis-pro/Views/Login/RedisListView.swift @@ -42,7 +42,7 @@ struct RedisListView: View { onLoad(viewStore) } LoginForm(store: store.scope(state: \.loginState, action: FavoriteAction.loginAction)) - .frame(minWidth: 500, idealWidth:500, maxWidth: .infinity, minHeight: 400, idealHeight: 400, maxHeight: .infinity) + .frame(minWidth: 600, maxWidth: .infinity, minHeight: 420, maxHeight: .infinity) } } } diff --git a/redis-pro/Views/RedisEditorView/RedisValueHeaderView.swift b/redis-pro/Views/RedisEditorView/RedisValueHeaderView.swift index e1da917..ce5ee87 100644 --- a/redis-pro/Views/RedisEditorView/RedisValueHeaderView.swift +++ b/redis-pro/Views/RedisEditorView/RedisValueHeaderView.swift @@ -27,7 +27,7 @@ struct RedisValueHeaderView: View { WithViewStore(store) {viewStore in HStack(alignment: .center, spacing: 6) { - FormItemText(label: "Key", labelWidth: 40, required: true, value: viewStore.binding(\.$key)).disabled(!viewStore.isNew) + FormItemText(label: "Key", labelWidth: 40, required: true, value: viewStore.binding(get: \.key, send: KeyAction.setKey)).disabled(!viewStore.isNew) RedisKeyTypePicker(label: "Type", value: viewStore.binding(get: \.type, send: KeyAction.setType), disabled: !viewStore.isNew) Spacer()