From 0c65313b35a052dc35988d752a4d946afb2ae691 Mon Sep 17 00:00:00 2001
From: kubbo <390378816@qq.com>
Date: Thu, 16 Feb 2023 11:34:36 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E8=B0=83=E6=95=B4ws=E7=9A=84=E8=B0=83?=
=?UTF-8?q?=E7=94=A8=E6=96=B9=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../oms/apps/develop/AppDeployCustom/list.vue | 69 ++++++++++---------
1 file changed, 38 insertions(+), 31 deletions(-)
diff --git a/project/oms/apps/develop/AppDeployCustom/list.vue b/project/oms/apps/develop/AppDeployCustom/list.vue
index e7793204..a07fb944 100644
--- a/project/oms/apps/develop/AppDeployCustom/list.vue
+++ b/project/oms/apps/develop/AppDeployCustom/list.vue
@@ -6,10 +6,12 @@
添加
-
+
-
+
{
- if (res?.data) {
- const data = JSON.parse(res.data)
- if (data.code == '0') {
- row.count = data.progress
- if (row.count == 100) {
- row.count = 0
- this.$message.success("打包成功!")
- this.refreshRow(row, data.remark)
- }
- } else if (data.code == 1) {
- row.count = 0
- this.$message.error("打包失败!")
- this.refreshRow(row, data.row)
- }
- }
- }
- this.ws[id].onclose = () => {
- row.count = 0
- this.ws[id].close()
- delete this.ws[id]
- }
- } else this.ws[id]?.send(JSON.stringify({id}))
+ if (!this.ws) {
+ this.initWs()
+ }
+ this.ws?.send(JSON.stringify({action: "/custom/getZip", id}))
},
refreshRow(row, v) {
row.error = v.error
@@ -146,9 +127,10 @@ export default {
},
handleCancelUpdate(row) {
let {id} = row
- this.ws[id].send(JSON.stringify({
- cid: id
- }))
+ if (!this.ws) {
+ this.initWs()
+ }
+ this.ws.send(JSON.stringify({action: "/custom/getZip", cid: id}))
},
getRowById(id) {
return this.instance.post("/node/custom/detail", null, {
@@ -165,13 +147,38 @@ export default {
this.$message.success("消息发送成功!")
}
})
+ },
+ initWs() {
+ this.ws = new WebSocket(`ws://192.168.1.87:12525/ws`)
+ this.ws.onmessage = res => {
+ if (res?.data) {
+ const data = JSON.parse(res.data),
+ row = this.tableData.find(e => e.id == data?.row.id)
+ if (data.code == '0') {
+ row.count = data.progress
+ if (row.count == 100) {
+ row.count = 0
+ this.$message.success("打包成功!")
+ this.refreshRow(row, data.row)
+ }
+ } else if (data.code == 1) {
+ row.count = 0
+ this.$message.error("打包失败!")
+ this.refreshRow(row, data.row)
+ }
+ }
+ }
+ this.ws.onclose = () => {
+ this.tableData.map(e => e.count = 0)
+ this.ws.close()
+ }
}
},
created() {
this.getTableData()
},
beforeDestroy() {
- Object.values(this.ws).map(t => t.close())
+ this.ws?.close()
}
}
From b2fde1c4193c6a063a444d461a3216f61c227cf4 Mon Sep 17 00:00:00 2001
From: kubbo <390378816@qq.com>
Date: Thu, 16 Feb 2023 12:29:26 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E8=B0=83=E6=95=B4ws=E7=9A=84=E8=B0=83?=
=?UTF-8?q?=E7=94=A8=E6=96=B9=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
project/oms/apps/develop/AppDeployCustom/list.vue | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/project/oms/apps/develop/AppDeployCustom/list.vue b/project/oms/apps/develop/AppDeployCustom/list.vue
index a07fb944..eeb1259c 100644
--- a/project/oms/apps/develop/AppDeployCustom/list.vue
+++ b/project/oms/apps/develop/AppDeployCustom/list.vue
@@ -59,7 +59,7 @@ export default {
{prop: "dist", label: "更新路径"},
{slot: 'process'},
],
- ws: {}
+ ws: null
}
},
methods: {