Compare commits
No commits in common. "74a6b9b0e17ba69d5cd9a73f690691e94d6d4d8e" and "e1f022908ceb9fda5b68abbbb8b255eca4c6bcb8" have entirely different histories.
74a6b9b0e1
...
e1f022908c
|
@ -122,6 +122,7 @@ func (c *connectionService) buildOption(config types.ConnectionConfig) (*redis.O
|
||||||
}
|
}
|
||||||
|
|
||||||
option := &redis.Options{
|
option := &redis.Options{
|
||||||
|
Addr: fmt.Sprintf("%s:%d", config.Addr, config.Port),
|
||||||
Username: config.Username,
|
Username: config.Username,
|
||||||
Password: config.Password,
|
Password: config.Password,
|
||||||
DialTimeout: time.Duration(config.ConnTimeout) * time.Second,
|
DialTimeout: time.Duration(config.ConnTimeout) * time.Second,
|
||||||
|
@ -129,21 +130,6 @@ func (c *connectionService) buildOption(config types.ConnectionConfig) (*redis.O
|
||||||
WriteTimeout: time.Duration(config.ExecTimeout) * time.Second,
|
WriteTimeout: time.Duration(config.ExecTimeout) * time.Second,
|
||||||
TLSConfig: tlsConfig,
|
TLSConfig: tlsConfig,
|
||||||
}
|
}
|
||||||
if config.Network == "unix" {
|
|
||||||
option.Network = "unix"
|
|
||||||
if len(config.Sock) <= 0 {
|
|
||||||
option.Addr = "/tmp/redis.sock"
|
|
||||||
} else {
|
|
||||||
option.Addr = config.Sock
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
option.Network = "tcp"
|
|
||||||
if len(config.Addr) <= 0 {
|
|
||||||
option.Addr = fmt.Sprintf("127.0.0.1:%d", config.Port)
|
|
||||||
} else {
|
|
||||||
option.Addr = fmt.Sprintf("%s:%d", config.Addr, config.Port)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if config.LastDB > 0 {
|
if config.LastDB > 0 {
|
||||||
option.DB = config.LastDB
|
option.DB = config.LastDB
|
||||||
}
|
}
|
||||||
|
@ -536,28 +522,18 @@ func (c *connectionService) ParseConnectURL(url string) (resp types.JSResp) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var network, addr string
|
|
||||||
var port int
|
|
||||||
if urlOpt.Network == "unix" {
|
|
||||||
network = urlOpt.Network
|
|
||||||
addr = urlOpt.Addr
|
|
||||||
} else {
|
|
||||||
network = "tcp"
|
|
||||||
addrPart := strings.Split(urlOpt.Addr, ":")
|
addrPart := strings.Split(urlOpt.Addr, ":")
|
||||||
addr = addrPart[0]
|
addr := addrPart[0]
|
||||||
port = 6379
|
port := 6379
|
||||||
if len(addrPart) > 1 {
|
if len(addrPart) > 1 {
|
||||||
port, _ = strconv.Atoi(addrPart[1])
|
port, _ = strconv.Atoi(addrPart[1])
|
||||||
}
|
}
|
||||||
}
|
|
||||||
var sslServerName string
|
var sslServerName string
|
||||||
if urlOpt.TLSConfig != nil {
|
if urlOpt.TLSConfig != nil {
|
||||||
sslServerName = urlOpt.TLSConfig.ServerName
|
sslServerName = urlOpt.TLSConfig.ServerName
|
||||||
}
|
}
|
||||||
resp.Success = true
|
resp.Success = true
|
||||||
resp.Data = struct {
|
resp.Data = struct {
|
||||||
Network string `json:"network"`
|
|
||||||
Sock string `json:"sock"`
|
|
||||||
Addr string `json:"addr"`
|
Addr string `json:"addr"`
|
||||||
Port int `json:"port"`
|
Port int `json:"port"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
|
@ -566,7 +542,6 @@ func (c *connectionService) ParseConnectURL(url string) (resp types.JSResp) {
|
||||||
ExecTimeout int64 `json:"execTimeout"`
|
ExecTimeout int64 `json:"execTimeout"`
|
||||||
SSLServerName string `json:"sslServerName,omitempty"`
|
SSLServerName string `json:"sslServerName,omitempty"`
|
||||||
}{
|
}{
|
||||||
Network: network,
|
|
||||||
Addr: addr,
|
Addr: addr,
|
||||||
Port: port,
|
Port: port,
|
||||||
Username: urlOpt.Username,
|
Username: urlOpt.Username,
|
||||||
|
|
|
@ -27,7 +27,6 @@ func (c *ConnectionsStorage) defaultConnections() types.Connections {
|
||||||
func (c *ConnectionsStorage) defaultConnectionItem() types.ConnectionConfig {
|
func (c *ConnectionsStorage) defaultConnectionItem() types.ConnectionConfig {
|
||||||
return types.ConnectionConfig{
|
return types.ConnectionConfig{
|
||||||
Name: "",
|
Name: "",
|
||||||
Network: "tcp",
|
|
||||||
Addr: "127.0.0.1",
|
Addr: "127.0.0.1",
|
||||||
Port: 6379,
|
Port: 6379,
|
||||||
Username: "",
|
Username: "",
|
||||||
|
|
|
@ -6,8 +6,6 @@ type ConnectionConfig struct {
|
||||||
Name string `json:"name" yaml:"name"`
|
Name string `json:"name" yaml:"name"`
|
||||||
Group string `json:"group,omitempty" yaml:"-"`
|
Group string `json:"group,omitempty" yaml:"-"`
|
||||||
LastDB int `json:"lastDB" yaml:"last_db"`
|
LastDB int `json:"lastDB" yaml:"last_db"`
|
||||||
Network string `json:"network,omitempty" yaml:"network,omitempty"`
|
|
||||||
Sock string `json:"sock,omitempty" yaml:"sock,omitempty"`
|
|
||||||
Addr string `json:"addr,omitempty" yaml:"addr,omitempty"`
|
Addr string `json:"addr,omitempty" yaml:"addr,omitempty"`
|
||||||
Port int `json:"port,omitempty" yaml:"port,omitempty"`
|
Port int `json:"port,omitempty" yaml:"port,omitempty"`
|
||||||
Username string `json:"username,omitempty" yaml:"username,omitempty"`
|
Username string `json:"username,omitempty" yaml:"username,omitempty"`
|
||||||
|
|
|
@ -278,7 +278,6 @@ const pasteFromClipboard = async () => {
|
||||||
$message.error(i18n.t('dialogue.connection.parse_fail', { reason: e.message }))
|
$message.error(i18n.t('dialogue.connection.parse_fail', { reason: e.message }))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
generalForm.value.network = opt.network || 'tcp'
|
|
||||||
generalForm.value.name = generalForm.value.addr = opt.addr
|
generalForm.value.name = generalForm.value.addr = opt.addr
|
||||||
generalForm.value.port = opt.port
|
generalForm.value.port = opt.port
|
||||||
generalForm.value.username = opt.username
|
generalForm.value.username = opt.username
|
||||||
|
@ -349,20 +348,6 @@ const pasteFromClipboard = async () => {
|
||||||
:render-label="({ label, value }) => (value === '' ? $t(label) : label)" />
|
:render-label="({ label, value }) => (value === '' ? $t(label) : label)" />
|
||||||
</n-form-item-gi>
|
</n-form-item-gi>
|
||||||
<n-form-item-gi :label="$t('dialogue.connection.addr')" :span="24" path="addr" required>
|
<n-form-item-gi :label="$t('dialogue.connection.addr')" :span="24" path="addr" required>
|
||||||
<n-input-group>
|
|
||||||
<n-select
|
|
||||||
v-model:value="generalForm.network"
|
|
||||||
:options="[
|
|
||||||
{ value: 'tcp', label: 'TCP' },
|
|
||||||
{ value: 'unix', label: 'UNIX' },
|
|
||||||
]"
|
|
||||||
style="max-width: 100px" />
|
|
||||||
<template v-if="generalForm.network === 'unix'">
|
|
||||||
<n-input
|
|
||||||
v-model:value="generalForm.sock"
|
|
||||||
:placeholder="$t('dialogue.connection.sock_tip')" />
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<n-input
|
<n-input
|
||||||
v-model:value="generalForm.addr"
|
v-model:value="generalForm.addr"
|
||||||
:placeholder="$t('dialogue.connection.addr_tip')" />
|
:placeholder="$t('dialogue.connection.addr_tip')" />
|
||||||
|
@ -372,10 +357,7 @@ const pasteFromClipboard = async () => {
|
||||||
:max="65535"
|
:max="65535"
|
||||||
:min="1"
|
:min="1"
|
||||||
:show-button="false"
|
:show-button="false"
|
||||||
placeholder="6379"
|
|
||||||
style="width: 200px" />
|
style="width: 200px" />
|
||||||
</template>
|
|
||||||
</n-input-group>
|
|
||||||
</n-form-item-gi>
|
</n-form-item-gi>
|
||||||
<n-form-item-gi :label="$t('dialogue.connection.pwd')" :span="12" path="password">
|
<n-form-item-gi :label="$t('dialogue.connection.pwd')" :span="12" path="password">
|
||||||
<n-input
|
<n-input
|
||||||
|
|
|
@ -193,7 +193,6 @@
|
||||||
"pwd": "Password",
|
"pwd": "Password",
|
||||||
"name_tip": "Connection name",
|
"name_tip": "Connection name",
|
||||||
"addr_tip": "Redis server host",
|
"addr_tip": "Redis server host",
|
||||||
"sock_tip": "Redis server unix socket file",
|
|
||||||
"usr_tip": "(Optional) Authentication username",
|
"usr_tip": "(Optional) Authentication username",
|
||||||
"pwd_tip": "(Optional) Authentication password (Redis > 6.0)",
|
"pwd_tip": "(Optional) Authentication password (Redis > 6.0)",
|
||||||
"test": "Test Connection",
|
"test": "Test Connection",
|
||||||
|
|
|
@ -193,7 +193,6 @@
|
||||||
"pwd": "密码",
|
"pwd": "密码",
|
||||||
"name_tip": "连接名",
|
"name_tip": "连接名",
|
||||||
"addr_tip": "Redis服务地址",
|
"addr_tip": "Redis服务地址",
|
||||||
"sock_tip": "Redis套接字文件",
|
|
||||||
"usr_tip": "(可选)Redis服务授权用户名",
|
"usr_tip": "(可选)Redis服务授权用户名",
|
||||||
"pwd_tip": "(可选)Redis服务授权密码 (Redis > 6.0)",
|
"pwd_tip": "(可选)Redis服务授权密码 (Redis > 6.0)",
|
||||||
"test": "测试连接",
|
"test": "测试连接",
|
||||||
|
|
|
@ -153,8 +153,6 @@ const useConnectionStore = defineStore('connections', {
|
||||||
return {
|
return {
|
||||||
group: '',
|
group: '',
|
||||||
name: name || '',
|
name: name || '',
|
||||||
network: 'tcp',
|
|
||||||
sock: '/tmp/redis.sock',
|
|
||||||
addr: '127.0.0.1',
|
addr: '127.0.0.1',
|
||||||
port: 6379,
|
port: 6379,
|
||||||
username: '',
|
username: '',
|
||||||
|
|
|
@ -124,29 +124,13 @@ const useDialogStore = defineStore('dialog', {
|
||||||
|
|
||||||
async openDuplicateDialog(name) {
|
async openDuplicateDialog(name) {
|
||||||
const connStore = useConnectionStore()
|
const connStore = useConnectionStore()
|
||||||
this.connParam = {}
|
const profile = await connStore.getConnectionProfile(name)
|
||||||
let profile
|
|
||||||
let suffix = 1
|
|
||||||
do {
|
|
||||||
let profileName = name
|
|
||||||
if (suffix > 1) {
|
|
||||||
profileName += suffix
|
|
||||||
}
|
|
||||||
profile = await connStore.getConnectionProfile(profileName)
|
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
suffix += 1
|
profile.name += '2'
|
||||||
if (profileName === name) {
|
|
||||||
this.connParam = profile
|
this.connParam = profile
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.connParam = connStore.mergeConnectionProfile(
|
this.connParam = connStore.newDefaultConnection(name)
|
||||||
connStore.newDefaultConnection(profileName),
|
|
||||||
this.connParam,
|
|
||||||
)
|
|
||||||
this.connParam.name = profileName
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
} while (true)
|
|
||||||
this.connType = ConnDialogType.NEW
|
this.connType = ConnDialogType.NEW
|
||||||
this.connDialogVisible = true
|
this.connDialogVisible = true
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue