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{
|
||||
Addr: fmt.Sprintf("%s:%d", config.Addr, config.Port),
|
||||
Username: config.Username,
|
||||
Password: config.Password,
|
||||
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,
|
||||
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 {
|
||||
option.DB = config.LastDB
|
||||
}
|
||||
|
@ -536,19 +522,11 @@ func (c *connectionService) ParseConnectURL(url string) (resp types.JSResp) {
|
|||
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, ":")
|
||||
addr = addrPart[0]
|
||||
port = 6379
|
||||
if len(addrPart) > 1 {
|
||||
port, _ = strconv.Atoi(addrPart[1])
|
||||
}
|
||||
addrPart := strings.Split(urlOpt.Addr, ":")
|
||||
addr := addrPart[0]
|
||||
port := 6379
|
||||
if len(addrPart) > 1 {
|
||||
port, _ = strconv.Atoi(addrPart[1])
|
||||
}
|
||||
var sslServerName string
|
||||
if urlOpt.TLSConfig != nil {
|
||||
|
@ -556,8 +534,6 @@ func (c *connectionService) ParseConnectURL(url string) (resp types.JSResp) {
|
|||
}
|
||||
resp.Success = true
|
||||
resp.Data = struct {
|
||||
Network string `json:"network"`
|
||||
Sock string `json:"sock"`
|
||||
Addr string `json:"addr"`
|
||||
Port int `json:"port"`
|
||||
Username string `json:"username"`
|
||||
|
@ -566,7 +542,6 @@ func (c *connectionService) ParseConnectURL(url string) (resp types.JSResp) {
|
|||
ExecTimeout int64 `json:"execTimeout"`
|
||||
SSLServerName string `json:"sslServerName,omitempty"`
|
||||
}{
|
||||
Network: network,
|
||||
Addr: addr,
|
||||
Port: port,
|
||||
Username: urlOpt.Username,
|
||||
|
|
|
@ -27,7 +27,6 @@ func (c *ConnectionsStorage) defaultConnections() types.Connections {
|
|||
func (c *ConnectionsStorage) defaultConnectionItem() types.ConnectionConfig {
|
||||
return types.ConnectionConfig{
|
||||
Name: "",
|
||||
Network: "tcp",
|
||||
Addr: "127.0.0.1",
|
||||
Port: 6379,
|
||||
Username: "",
|
||||
|
|
|
@ -6,8 +6,6 @@ type ConnectionConfig struct {
|
|||
Name string `json:"name" yaml:"name"`
|
||||
Group string `json:"group,omitempty" yaml:"-"`
|
||||
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"`
|
||||
Port int `json:"port,omitempty" yaml:"port,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 }))
|
||||
return
|
||||
}
|
||||
generalForm.value.network = opt.network || 'tcp'
|
||||
generalForm.value.name = generalForm.value.addr = opt.addr
|
||||
generalForm.value.port = opt.port
|
||||
generalForm.value.username = opt.username
|
||||
|
@ -349,33 +348,16 @@ const pasteFromClipboard = async () => {
|
|||
:render-label="({ label, value }) => (value === '' ? $t(label) : label)" />
|
||||
</n-form-item-gi>
|
||||
<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
|
||||
v-model:value="generalForm.addr"
|
||||
:placeholder="$t('dialogue.connection.addr_tip')" />
|
||||
<n-text style="width: 40px; text-align: center">:</n-text>
|
||||
<n-input-number
|
||||
v-model:value="generalForm.port"
|
||||
:max="65535"
|
||||
:min="1"
|
||||
:show-button="false"
|
||||
placeholder="6379"
|
||||
style="width: 200px" />
|
||||
</template>
|
||||
</n-input-group>
|
||||
<n-input
|
||||
v-model:value="generalForm.addr"
|
||||
:placeholder="$t('dialogue.connection.addr_tip')" />
|
||||
<n-text style="width: 40px; text-align: center">:</n-text>
|
||||
<n-input-number
|
||||
v-model:value="generalForm.port"
|
||||
:max="65535"
|
||||
:min="1"
|
||||
:show-button="false"
|
||||
style="width: 200px" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :label="$t('dialogue.connection.pwd')" :span="12" path="password">
|
||||
<n-input
|
||||
|
|
|
@ -193,7 +193,6 @@
|
|||
"pwd": "Password",
|
||||
"name_tip": "Connection name",
|
||||
"addr_tip": "Redis server host",
|
||||
"sock_tip": "Redis server unix socket file",
|
||||
"usr_tip": "(Optional) Authentication username",
|
||||
"pwd_tip": "(Optional) Authentication password (Redis > 6.0)",
|
||||
"test": "Test Connection",
|
||||
|
|
|
@ -193,7 +193,6 @@
|
|||
"pwd": "密码",
|
||||
"name_tip": "连接名",
|
||||
"addr_tip": "Redis服务地址",
|
||||
"sock_tip": "Redis套接字文件",
|
||||
"usr_tip": "(可选)Redis服务授权用户名",
|
||||
"pwd_tip": "(可选)Redis服务授权密码 (Redis > 6.0)",
|
||||
"test": "测试连接",
|
||||
|
|
|
@ -153,8 +153,6 @@ const useConnectionStore = defineStore('connections', {
|
|||
return {
|
||||
group: '',
|
||||
name: name || '',
|
||||
network: 'tcp',
|
||||
sock: '/tmp/redis.sock',
|
||||
addr: '127.0.0.1',
|
||||
port: 6379,
|
||||
username: '',
|
||||
|
|
|
@ -124,29 +124,13 @@ const useDialogStore = defineStore('dialog', {
|
|||
|
||||
async openDuplicateDialog(name) {
|
||||
const connStore = useConnectionStore()
|
||||
this.connParam = {}
|
||||
let profile
|
||||
let suffix = 1
|
||||
do {
|
||||
let profileName = name
|
||||
if (suffix > 1) {
|
||||
profileName += suffix
|
||||
}
|
||||
profile = await connStore.getConnectionProfile(profileName)
|
||||
if (profile != null) {
|
||||
suffix += 1
|
||||
if (profileName === name) {
|
||||
this.connParam = profile
|
||||
}
|
||||
} else {
|
||||
this.connParam = connStore.mergeConnectionProfile(
|
||||
connStore.newDefaultConnection(profileName),
|
||||
this.connParam,
|
||||
)
|
||||
this.connParam.name = profileName
|
||||
break
|
||||
}
|
||||
} while (true)
|
||||
const profile = await connStore.getConnectionProfile(name)
|
||||
if (profile != null) {
|
||||
profile.name += '2'
|
||||
this.connParam = profile
|
||||
} else {
|
||||
this.connParam = connStore.newDefaultConnection(name)
|
||||
}
|
||||
this.connType = ConnDialogType.NEW
|
||||
this.connDialogVisible = true
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue