diff --git a/src/lang/index.ts b/src/lang/index.ts
index 53de9f0..a9ea95d 100644
--- a/src/lang/index.ts
+++ b/src/lang/index.ts
@@ -22,10 +22,18 @@ const enUS = {
hostRequired: 'Host is required',
portRequired: 'Port is required',
},
+ operations: {
+ connect: 'Connect',
+ edit: 'Edit',
+ remove: 'Remove',
+ },
},
- form: {
+ dialogOps: {
+ warning: 'Warning',
+ removeNotice: 'Remove the connection permanently?',
confirm: 'Confirm',
cancel: 'Cancel',
+ removeSuccess: 'Connection removed successfully',
},
};
@@ -52,10 +60,18 @@ const zhCN = {
hostRequired: '请输入主机地址',
portRequired: '请输入端口号',
},
+ operations: {
+ connect: '连接',
+ edit: '编辑',
+ remove: '删除',
+ },
},
- form: {
+ dialogOps: {
+ warning: '提示',
+ removeNotice: '确认删除该连接?',
confirm: '确认',
cancel: '取消',
+ removeSuccess: '连接删除成功',
},
};
diff --git a/src/views/connect/components/add-dialog.vue b/src/views/connect/components/add-dialog.vue
index 51241e6..89ec871 100644
--- a/src/views/connect/components/add-dialog.vue
+++ b/src/views/connect/components/add-dialog.vue
@@ -93,14 +93,14 @@
- {{ $t('form.cancel') }}
+ {{ $t('dialogOps.cancel') }}
- {{ $t('form.confirm') }}
+ {{ $t('dialogOps.confirm') }}
diff --git a/src/views/connect/components/connect-list.vue b/src/views/connect/components/connect-list.vue
index fb9284f..d127e0f 100644
--- a/src/views/connect/components/connect-list.vue
+++ b/src/views/connect/components/connect-list.vue
@@ -16,7 +16,7 @@
{{ con.name }}
-
+
{
- return appStore.languageType === 'zhCN';
-});
const options = reactive([
- {
- key: 1,
- label: isZhCN.value ? '连接' : 'Connect',
- },
- {
- key: 2,
- label: isZhCN.value ? '编辑' : 'Edit',
- },
- {
- key: 3,
- label: isZhCN.value ? '删除' : 'Delete',
- },
+ { key: 1, label: lang.t('connection.operations.connect') },
+ { key: 2, label: lang.t('connection.operations.edit') },
+ { key: 3, label: lang.t('connection.operations.remove') },
]);
const connectionStore = useConnectionStore();
-const { fetchConnections } = connectionStore;
+const { fetchConnections, removeConnection } = connectionStore;
const { connections } = storeToRefs(connectionStore);
-
fetchConnections();
-// dropdown select handler
-const handleSelect = (key: number, row: object) => {
+const handleSelect = (key: number, connection: Connection) => {
switch (key) {
case 1:
- connectItem(row);
+ establishConnect(connection);
break;
case 2:
- editCconnect(row);
+ editConnect(connection);
break;
case 3:
- deleteConnect(row);
+ removeConnect(connection);
break;
}
};
// TODO:connect to the item
-const connectItem = (row: object) => {
- console.log(row);
+const establishConnect = (connection: Connection) => {
+ // eslint-disable-next-line no-console
+ console.log(connection);
};
// edit connect info
-const editCconnect = (row: object) => {
- emits('edit-connect', row);
+const editConnect = (connection: Connection) => {
+ emits('edit-connect', connection);
};
-// TODO:delete connect
-const deleteConnect = (row: object) => {
+const removeConnect = (connection: Connection) => {
dialog.warning({
- title: isZhCN ? '错误' : 'Warning',
- content: isZhCN ? '确定删除此连接?' : 'Are you sure to delete this connection?',
- positiveText: isZhCN ? '确定' : 'Sure',
- negativeText: isZhCN ? '取消' : 'Cancel',
+ title: lang.t('dialogOps.warning'),
+ content: lang.t('dialogOps.removeNotice'),
+ positiveText: lang.t('dialogOps.confirm'),
+ negativeText: lang.t('dialogOps.cancel'),
onPositiveClick: () => {
- message.success('我就知道');
+ removeConnection(connection);
+ message.success(lang.t('dialogOps.removeSuccess'));
},
});
};
@@ -111,9 +98,11 @@ const deleteConnect = (row: object) => {
flex: 1;
height: 0;
padding-bottom: 10px;
+
.scroll-container {
padding: 0 10px;
}
+
.list-item {
width: 100%;
height: 32px;
@@ -121,6 +110,7 @@ const deleteConnect = (row: object) => {
display: flex;
align-items: center;
cursor: pointer;
+
.icon {
height: 100%;
width: 22px;
@@ -129,6 +119,7 @@ const deleteConnect = (row: object) => {
justify-content: center;
color: var(--dange-color);
}
+
.name {
flex: 1;
width: 0;
@@ -137,7 +128,8 @@ const deleteConnect = (row: object) => {
text-overflow: ellipsis;
white-space: nowrap;
}
- .opration {
+
+ .operation {
height: 100%;
width: 20px;
display: none;
@@ -145,19 +137,23 @@ const deleteConnect = (row: object) => {
justify-content: center;
}
}
+
.list-item + .list-item {
margin-top: 5px;
}
+
.list-item:hover {
background-color: var(--connect-list-hover-bg);
- .opration {
+
+ .operation {
display: flex;
}
}
+
.list-item.active {
.icon,
.name,
- .opration {
+ .operation {
color: var(--theme-color);
}
}