Skip to content

Commit

Permalink
Merge pull request #45 from cmushroom/dev
Browse files Browse the repository at this point in the history
2.1.0
  • Loading branch information
chengpan168 authored Jun 26, 2022
2 parents 46326e9 + 7f89353 commit 5f738f6
Show file tree
Hide file tree
Showing 18 changed files with 248 additions and 191 deletions.
6 changes: 3 additions & 3 deletions .version
Original file line number Diff line number Diff line change
@@ -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!"
}
8 changes: 4 additions & 4 deletions redis-pro.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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 = "";
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,129 +7,97 @@
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "6962DEF9-0B63-48A4-8ACD-30A312F6FCF1"
shouldBeEnabled = "Yes"
uuid = "610FCD96-2A2C-404D-8E30-3949F98E4FD2"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "redis-pro/Store/SetValueStore.swift"
filePath = "redis-pro/Store/StringValueStore.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "150"
endingLineNumber = "150"
startingLineNumber = "70"
endingLineNumber = "70"
landmarkName = "unknown"
landmarkType = "0">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "A5BD4C99-CE74-4A6E-8AEB-FAD9E29F23A0"
shouldBeEnabled = "Yes"
uuid = "CB4A3BF5-84F0-4861-A6F9-F41050242A46"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "redis-pro/Store/SetValueStore.swift"
filePath = "redis-pro/Store/AppStore.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "156"
endingLineNumber = "156"
startingLineNumber = "123"
endingLineNumber = "123"
landmarkName = "unknown"
landmarkType = "0">
<Locations>
<Location
uuid = "A5BD4C99-CE74-4A6E-8AEB-FAD9E29F23A0 - c5a512fa10522204"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "(1) await resume partial function for closure #6 @Sendable () async -&gt; redis_pro.SetValueAction in closure #3 (inout redis_pro.SetValueState, redis_pro.SetValueAction, redis_pro.SetValueEnvironment) -&gt; ComposableArchitecture.Effect&lt;redis_pro.SetValueAction, Swift.Never&gt; in variable initialization expression of redis_pro.setValueReducer : ComposableArchitecture.Reducer&lt;redis_pro.SetValueState, redis_pro.SetValueAction, redis_pro.SetValueEnvironment&gt;"
moduleName = "redis-pro"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/chengpan/work/dream/redis-pro/redis-pro/Store/SetValueStore.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "156"
endingLineNumber = "156"
offsetFromSymbolStart = "175">
</Location>
<Location
uuid = "A5BD4C99-CE74-4A6E-8AEB-FAD9E29F23A0 - 1fd1b3299209602b"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "(2) await resume partial function for closure #6 @Sendable () async -&gt; redis_pro.SetValueAction in closure #3 (inout redis_pro.SetValueState, redis_pro.SetValueAction, redis_pro.SetValueEnvironment) -&gt; ComposableArchitecture.Effect&lt;redis_pro.SetValueAction, Swift.Never&gt; in variable initialization expression of redis_pro.setValueReducer : ComposableArchitecture.Reducer&lt;redis_pro.SetValueState, redis_pro.SetValueAction, redis_pro.SetValueEnvironment&gt;"
moduleName = "redis-pro"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/chengpan/work/dream/redis-pro/redis-pro/Store/SetValueStore.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "156"
endingLineNumber = "156"
offsetFromSymbolStart = "195">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "19724BF9-DFC8-4625-AA90-AF3595A1E450"
shouldBeEnabled = "Yes"
uuid = "983436FB-5B00-4DC1-B929-0FD6A69AE09B"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "redis-pro/Store/SetValueStore.swift"
filePath = "redis-pro/Views/Components/Table/NTable.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "163"
endingLineNumber = "163"
landmarkName = "unknown"
landmarkType = "0">
startingLineNumber = "316"
endingLineNumber = "316"
landmarkName = "tableView(_:pasteboardWriterForRow:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "6325D621-DC43-4180-9AC4-876CA4A6B282"
shouldBeEnabled = "Yes"
uuid = "D71B5807-CBF5-4528-8DF8-9489993BE534"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "redis-pro/Store/ValueStore.swift"
filePath = "redis-pro/Views/Components/Table/NTable.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "127"
endingLineNumber = "127"
landmarkName = "unknown"
landmarkType = "0">
startingLineNumber = "334"
endingLineNumber = "334"
landmarkName = "tableView(_:acceptDrop:row:dropOperation:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "D6D52007-2C34-4C4A-8194-89D7C0900782"
shouldBeEnabled = "Yes"
uuid = "E721C4FA-4ECF-4FB8-8912-BE9EB08B5142"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "redis-pro/Store/KeyStore.swift"
filePath = "redis-pro/Views/Components/Table/NTable.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "77"
endingLineNumber = "77"
landmarkName = "unknown"
landmarkType = "0">
startingLineNumber = "341"
endingLineNumber = "341"
landmarkName = "tableView(_:acceptDrop:row:dropOperation:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "FE2956AB-4DEB-44C8-977F-37FA9EA83C00"
shouldBeEnabled = "Yes"
uuid = "F96A3103-3387-4310-B335-10D015B02D5A"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "redis-pro/Store/KeyStore.swift"
filePath = "redis-pro/Views/Components/Table/NTable.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "99"
endingLineNumber = "99"
landmarkName = "unknown"
landmarkType = "0">
startingLineNumber = "312"
endingLineNumber = "312"
landmarkName = "tableView(_:pasteboardWriterForRow:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
Expand Down
7 changes: 7 additions & 0 deletions redis-pro/Common/UserDefaults/RedisDefaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion redis-pro/Model/RedisModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions redis-pro/Store/FavoriteStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -135,7 +135,12 @@ let favoriteReducer = Reducer<FavoriteState, FavoriteAction, FavoriteEnvironment
}
.receive(on: env.mainQueue)
.eraseToEffect()
// return .none


case let .tableAction(.dragComplete(from, to)):
let _ = RedisDefaults.save(state.tableState.datasource as! [RedisModel])
return .none

case let .tableAction(.double(index)):
return .result {
.success(.connect(index))
Expand Down
13 changes: 5 additions & 8 deletions redis-pro/Store/GlobalStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,17 @@ let globalReducer = Reducer<GlobalState, GlobalAction, GlobalEnvironment>.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
Expand Down
4 changes: 2 additions & 2 deletions redis-pro/Store/KeyStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -70,7 +70,7 @@ let keyReducer = Reducer<KeyState, KeyAction, KeyEnvironment>.combine(
.success(.getTtl)
}

case let .updateKey(key):
case let .setKey(key):
state.key = key
return .none
case .getTtl:
Expand Down
3 changes: 3 additions & 0 deletions redis-pro/Store/LoginStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
Expand All @@ -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
Expand Down
11 changes: 11 additions & 0 deletions redis-pro/Store/TableStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ struct TableState: Equatable {
// 一定要设置-1, 其它值会在view 刷新时, 陷入无限循环
var selectIndex:Int = -1
var defaultSelectIndex:Int = -1
var dragable: Bool = false
}

enum TableAction:Equatable {
Expand All @@ -26,6 +27,7 @@ enum TableAction:Equatable {
case contextMenu(String, Int)
case refresh
case reset
case dragComplete(Int, Int)
}

struct TableEnvironment { }
Expand Down Expand Up @@ -58,5 +60,14 @@ let tableReducer = Reducer<TableState, TableAction, TableEnvironment> {
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()
Loading

0 comments on commit 5f738f6

Please sign in to comment.