mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-03 07:50:25 +08:00
fix: redis集群修复
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
<span v-if="data.type == NodeType.Redis">
|
<span v-if="data.type == NodeType.Redis">
|
||||||
<el-popover placement="right-start" title="redis实例信息" trigger="hover" :width="210">
|
<el-popover placement="right-start" title="redis实例信息" trigger="hover" :width="210">
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<SvgIcon name="iconfont icon-op-redis" :size="18"/>
|
<SvgIcon name="iconfont icon-op-redis" :size="18" />
|
||||||
</template>
|
</template>
|
||||||
<template #default>
|
<template #default>
|
||||||
<el-form class="instances-pop-form" label-width="50px" :size="'small'">
|
<el-form class="instances-pop-form" label-width="50px" :size="'small'">
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
</el-popover>
|
</el-popover>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<SvgIcon v-if="data.type == NodeType.Db" name="Coin" color="#67c23a"/>
|
<SvgIcon v-if="data.type == NodeType.Db" name="Coin" color="#67c23a" />
|
||||||
</template>
|
</template>
|
||||||
</tag-tree>
|
</tag-tree>
|
||||||
</el-col>
|
</el-col>
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-table v-loading="state.loading" :data="state.keys" stripe :highlight-current-row="true"
|
<el-table v-loading="state.loading" :data="state.keys" :height="tableHeight" stripe :highlight-current-row="true"
|
||||||
style="cursor: pointer">
|
style="cursor: pointer">
|
||||||
<el-table-column show-overflow-tooltip prop="key" label="key"></el-table-column>
|
<el-table-column show-overflow-tooltip prop="key" label="key"></el-table-column>
|
||||||
<el-table-column prop="type" label="type" width="80">
|
<el-table-column prop="type" label="type" width="80">
|
||||||
@@ -79,10 +79,10 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作">
|
<el-table-column label="操作">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button @click="getValue(scope.row)" type="success" icon="search" plain
|
<el-button @click="getValue(scope.row)" type="success" icon="search" plain size="small">查看
|
||||||
size="small">查看
|
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button v-auth="'redis:data:del'" @click="del(scope.row.key)" type="danger" icon="delete" plain size="small">删除
|
<el-button v-auth="'redis:data:del'" @click="del(scope.row.key)" type="danger" icon="delete"
|
||||||
|
plain size="small">删除
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -133,8 +133,8 @@ class NodeType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
instanceMenuMaxHeight: '600',
|
|
||||||
loading: false,
|
loading: false,
|
||||||
|
tableHeight: 600,
|
||||||
tags: [],
|
tags: [],
|
||||||
redisList: [] as any,
|
redisList: [] as any,
|
||||||
dbList: [],
|
dbList: [],
|
||||||
@@ -176,6 +176,7 @@ const state = reactive({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
tableHeight,
|
||||||
scanParam,
|
scanParam,
|
||||||
dataEdit,
|
dataEdit,
|
||||||
hashValueDialog,
|
hashValueDialog,
|
||||||
@@ -190,7 +191,7 @@ onMounted(async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const setHeight = () => {
|
const setHeight = () => {
|
||||||
state.instanceMenuMaxHeight = window.innerHeight - 115 + 'px';
|
state.tableHeight = window.innerHeight - 159;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -259,13 +260,18 @@ const nodeClick = (data: any) => {
|
|||||||
*/
|
*/
|
||||||
const getDbs = async (redisInfo: any) => {
|
const getDbs = async (redisInfo: any) => {
|
||||||
let dbs: TagTreeNode[] = redisInfo.db.split(',').map((x: string) => {
|
let dbs: TagTreeNode[] = redisInfo.db.split(',').map((x: string) => {
|
||||||
return new TagTreeNode(x, x, NodeType.Db).withIsLeaf(true).withParams({
|
return new TagTreeNode(x, `db${x}`, NodeType.Db).withIsLeaf(true).withParams({
|
||||||
id: redisInfo.id,
|
id: redisInfo.id,
|
||||||
db: x,
|
db: x,
|
||||||
name: `db${x}`,
|
name: `db${x}`,
|
||||||
keys: 0,
|
keys: 0,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (redisInfo.mode == 'cluster') {
|
||||||
|
return dbs;
|
||||||
|
}
|
||||||
|
|
||||||
const res = await redisApi.redisInfo.request({ id: redisInfo.id, host: redisInfo.host, section: "Keyspace" });
|
const res = await redisApi.redisInfo.request({ id: redisInfo.id, host: redisInfo.host, section: "Keyspace" });
|
||||||
for (let db in res.Keyspace) {
|
for (let db in res.Keyspace) {
|
||||||
for (let d of dbs) {
|
for (let d of dbs) {
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ go 1.20
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gin-gonic/gin v1.9.0
|
github.com/gin-gonic/gin v1.9.0
|
||||||
github.com/go-redis/redis/v8 v8.11.5
|
|
||||||
github.com/go-sql-driver/mysql v1.7.0
|
github.com/go-sql-driver/mysql v1.7.0
|
||||||
github.com/golang-jwt/jwt/v4 v4.5.0
|
github.com/golang-jwt/jwt/v4 v4.5.0
|
||||||
github.com/gorilla/websocket v1.5.0
|
github.com/gorilla/websocket v1.5.0
|
||||||
github.com/lib/pq v1.10.7
|
github.com/lib/pq v1.10.7
|
||||||
github.com/mojocn/base64Captcha v1.3.5 // 验证码
|
github.com/mojocn/base64Captcha v1.3.5 // 验证码
|
||||||
github.com/pkg/sftp v1.13.5
|
github.com/pkg/sftp v1.13.5
|
||||||
|
github.com/redis/go-redis/v9 v9.0.2
|
||||||
github.com/robfig/cron/v3 v3.0.1 // 定时任务
|
github.com/robfig/cron/v3 v3.0.1 // 定时任务
|
||||||
github.com/sirupsen/logrus v1.9.0
|
github.com/sirupsen/logrus v1.9.0
|
||||||
github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2
|
github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2
|
||||||
@@ -24,7 +24,7 @@ require (
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/bytedance/sonic v1.8.0 // indirect
|
github.com/bytedance/sonic v1.8.0 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
|
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||||
@@ -59,6 +59,5 @@ require (
|
|||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
|
||||||
golang.org/x/sys v0.6.0 // indirect
|
golang.org/x/sys v0.6.0 // indirect
|
||||||
golang.org/x/text v0.8.0 // indirect
|
golang.org/x/text v0.8.0 // indirect
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
|
||||||
google.golang.org/protobuf v1.28.1 // indirect
|
google.golang.org/protobuf v1.28.1 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -87,6 +87,9 @@ func (d *dbAppImpl) Save(dbEntity *entity.Db) {
|
|||||||
|
|
||||||
// 查找是否存在该库
|
// 查找是否存在该库
|
||||||
oldDb := &entity.Db{Host: dbEntity.Host, Port: dbEntity.Port, Username: dbEntity.Username}
|
oldDb := &entity.Db{Host: dbEntity.Host, Port: dbEntity.Port, Username: dbEntity.Username}
|
||||||
|
if dbEntity.SshTunnelMachineId > 0 {
|
||||||
|
oldDb.SshTunnelMachineId = dbEntity.SshTunnelMachineId
|
||||||
|
}
|
||||||
err := d.GetDbBy(oldDb)
|
err := d.GetDbBy(oldDb)
|
||||||
|
|
||||||
if dbEntity.Id == 0 {
|
if dbEntity.Id == 0 {
|
||||||
|
|||||||
@@ -62,6 +62,9 @@ func (m *machineAppImpl) Count(condition *entity.MachineQuery) int64 {
|
|||||||
|
|
||||||
func (m *machineAppImpl) Save(me *entity.Machine) {
|
func (m *machineAppImpl) Save(me *entity.Machine) {
|
||||||
oldMachine := &entity.Machine{Ip: me.Ip, Port: me.Port, Username: me.Username}
|
oldMachine := &entity.Machine{Ip: me.Ip, Port: me.Port, Username: me.Username}
|
||||||
|
if me.SshTunnelMachineId > 0 {
|
||||||
|
oldMachine.SshTunnelMachineId = me.SshTunnelMachineId
|
||||||
|
}
|
||||||
err := m.GetMachine(oldMachine)
|
err := m.GetMachine(oldMachine)
|
||||||
|
|
||||||
me.PwdEncrypt()
|
me.PwdEncrypt()
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/redis/go-redis/v9"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Redis struct {
|
type Redis struct {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/redis/go-redis/v9"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Redis interface {
|
type Redis interface {
|
||||||
@@ -81,6 +81,9 @@ func (r *redisAppImpl) Save(re *entity.Redis) {
|
|||||||
|
|
||||||
// 查找是否存在该库
|
// 查找是否存在该库
|
||||||
oldRedis := &entity.Redis{Host: re.Host}
|
oldRedis := &entity.Redis{Host: re.Host}
|
||||||
|
if re.SshTunnelMachineId > 0 {
|
||||||
|
oldRedis.SshTunnelMachineId = re.SshTunnelMachineId
|
||||||
|
}
|
||||||
err := r.GetRedisBy(oldRedis)
|
err := r.GetRedisBy(oldRedis)
|
||||||
|
|
||||||
if re.Id == 0 {
|
if re.Id == 0 {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/redis/go-redis/v9"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cli *redis.Client
|
var cli *redis.Client
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"mayfly-go/pkg/global"
|
"mayfly-go/pkg/global"
|
||||||
"mayfly-go/pkg/rediscli"
|
"mayfly-go/pkg/rediscli"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/redis/go-redis/v9"
|
||||||
)
|
)
|
||||||
|
|
||||||
func initRedis() {
|
func initRedis() {
|
||||||
|
|||||||
Reference in New Issue
Block a user