+
+
@@ -43,10 +49,15 @@
@@ -78,6 +115,7 @@ export default class ConnectionsList extends Vue {
cursor: pointer;
position: relative;
transition: background .3s ease;
+ user-select: none;
&.active {
background-color: var(--color-bg-item);
}
diff --git a/src/views/connections/types.ts b/src/views/connections/types.ts
index 005f4418a..f88126ed0 100644
--- a/src/views/connections/types.ts
+++ b/src/views/connections/types.ts
@@ -89,3 +89,8 @@ export interface SSLContent {
cert: string | string[] | Buffer | Buffer[] | undefined,
key: string | string[] | Buffer | Buffer[] | undefined,
}
+
+export interface ContextmenuModel {
+ top: number,
+ left: number,
+}
diff --git a/yarn.lock b/yarn.lock
index 447aa9fe5..826c6cd1d 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -10238,6 +10238,11 @@ vue-cli-plugin-electron-builder@^1.4.4:
webpack-chain "^5.0.0"
yargs "^14.0.0"
+vue-click-outside@^1.1.0:
+ version "1.1.0"
+ resolved "https://registry.npm.taobao.org/vue-click-outside/download/vue-click-outside-1.1.0.tgz#48b7680b518923e701643cccb3e165854aad99eb"
+ integrity sha1-SLdoC1GJI+cBZDzMs+FlhUqtmes=
+
vue-clipboard2@^0.3.1:
version "0.3.1"
resolved "https://registry.npm.taobao.org/vue-clipboard2/download/vue-clipboard2-0.3.1.tgz#6e551fb7bd384889b28b0da3b12289ed6bca4894"
From 09d29994f722a07501add9b892ce963dfdb61947 Mon Sep 17 00:00:00 2001
From: ysfscream <894402575@qq.com>
Date: Mon, 3 Aug 2020 16:05:52 +0800
Subject: [PATCH 12/20] feat(conection): add delete connection contextmenu
---
src/components/Contextmenu.vue | 4 +--
src/views/connections/ConnectionsDetail.vue | 37 ++++++++++++---------
src/views/connections/ConnectionsList.vue | 6 +++-
src/views/connections/index.vue | 14 ++++++--
4 files changed, 39 insertions(+), 22 deletions(-)
diff --git a/src/components/Contextmenu.vue b/src/components/Contextmenu.vue
index 247e95806..6f7a1e498 100644
--- a/src/components/Contextmenu.vue
+++ b/src/components/Contextmenu.vue
@@ -3,8 +3,8 @@
diff --git a/src/views/connections/ConnectionsDetail.vue b/src/views/connections/ConnectionsDetail.vue
index 60b23a394..482f2c5c0 100644
--- a/src/views/connections/ConnectionsDetail.vue
+++ b/src/views/connections/ConnectionsDetail.vue
@@ -248,6 +248,27 @@ export default class ConnectionsDetail extends Vue {
}
}
+ public removeConnection(currentConnection?: ConnectionModel) {
+ let { id, name } = this.record
+ if (currentConnection) {
+ id = currentConnection.id
+ name = currentConnection.name
+ }
+ const confirmDelete: string = this.$t('common.confirmDelete', { name }) as string
+ this.$confirm(confirmDelete, this.$t('common.warning') as string, {
+ type: 'warning',
+ }).then(async () => {
+ const res: ConnectionModel | null = await deleteConnection(id as string)
+ if (res) {
+ this.$emit('delete')
+ this.$message.success(this.$t('common.deleteSuccess') as string)
+ this.removeActiveConnection({ id: res.id as string })
+ }
+ }).catch((error) => {
+ // ignore(error)
+ })
+ }
+
get bodyTop(): Top {
return {
open: '254px',
@@ -433,22 +454,6 @@ export default class ConnectionsDetail extends Vue {
this.getMessages()
}
- private removeConnection() {
- const confirmDelete: string = this.$t('common.confirmDelete', { name: this.record.name }) as string
- this.$confirm(confirmDelete, this.$t('common.warning') as string, {
- type: 'warning',
- }).then(async () => {
- const res: ConnectionModel | null = await deleteConnection(this.record.id as string)
- if (res) {
- this.$emit('delete')
- this.$message.success(this.$t('common.deleteSuccess') as string)
- this.removeActiveConnection({ id: res.id as string })
- }
- }).catch((error) => {
- // ignore(error)
- })
- }
-
private createClient(): MqttClient {
const options: IClientOptions = getClientOptions(this.record)
return mqtt.connect(this.connectUrl, options)
diff --git a/src/views/connections/ConnectionsList.vue b/src/views/connections/ConnectionsList.vue
index 390122f1c..7f8250d65 100644
--- a/src/views/connections/ConnectionsList.vue
+++ b/src/views/connections/ConnectionsList.vue
@@ -38,7 +38,7 @@