Skip to content

Commit 90edc38

Browse files
author
zhoudian
committed
修复切换db的问题
1 parent 6eb2ae4 commit 90edc38

File tree

2 files changed

+4146
-3751
lines changed

2 files changed

+4146
-3751
lines changed

src/pages/HostContent/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,13 @@ class HostContent extends Component {
8989
let dbname = firstSplitString[0];
9090
let secondSplitString = firstSplitString[1].split(",");
9191
let thirdSplitString = secondSplitString[0].split("=");
92+
let dbIndex = i;
93+
if (dbname.startsWith("db")) {
94+
dbIndex = parseInt(dbname.substring(2));
95+
}
9296
dbTabs.push({
9397
key: "" + i,
98+
dbIndex: dbIndex,
9499
title: dbname,
95100
total: thirdSplitString[1],
96101
});
@@ -109,8 +114,9 @@ class HostContent extends Component {
109114
activeKey: activeKey,
110115
redisKey: { key: "", type: "" },
111116
});
117+
let dbIndex = this.state.dbTabs[activeKey].dbIndex;
112118
let redis = this.props.node.redis;
113-
redis.select(activeKey, (err, res) => {
119+
redis.select(dbIndex, (err, res) => {
114120
if (err) {
115121
message.error("" + err);
116122
Log.error(
@@ -178,7 +184,7 @@ class HostContent extends Component {
178184
HOST_KEY_SHOW_TYPE.TREE ? (
179185
<HostKeyTree
180186
node={this.props.node}
181-
db={tab.key}
187+
db={tab.dbIndex}
182188
updateHostKey={this.updateHostKey.bind(
183189
this
184190
)}
@@ -194,7 +200,7 @@ class HostContent extends Component {
194200
HOST_KEY_SHOW_TYPE.TABLE ? (
195201
<HostKey
196202
node={this.props.node}
197-
db={tab.key}
203+
db={tab.dbIndex}
198204
updateHostKey={this.updateHostKey.bind(
199205
this
200206
)}

0 commit comments

Comments
 (0)