From fa3585a197f7b3dc332138faece184f8a033ed01 Mon Sep 17 00:00:00 2001 From: mk <2403457699@qq.com> Date: Fri, 10 Jan 2025 13:55:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AF=8F=E6=AC=A1=E5=8F=91=E9=80=81=E5=8E=BB?= =?UTF-8?q?=E6=9F=A5=E7=9C=8Bwebsocket=E6=98=AF=E5=90=A6=E6=AD=A3=E5=B8=B8?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/smartExcel/cpts/excel-view.vue | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/views/modules/base/smartExcel/cpts/excel-view.vue b/src/views/modules/base/smartExcel/cpts/excel-view.vue index 72cb621ab..ebf75d9f1 100644 --- a/src/views/modules/base/smartExcel/cpts/excel-view.vue +++ b/src/views/modules/base/smartExcel/cpts/excel-view.vue @@ -83,12 +83,12 @@ export default { async loadWorkBook() { const data = await this.$http.post(`/actual/base/luckySheet/workbook/load?workbookId=${this.workbookId}`) window.luckysheet.destroy(); - options.data = data.data + options.data = data.data; window.luckysheet.create({ ...options, hook: { cellEditBefore: this.handleCellEditBefore, - // cellUpdateBefore: this.handleCellUpdateBefore, + updated: this.handleCellUpdateBefore, sheetCreateAfter: this.handleSheetCreateAfter, cellUpdated: this.handleCellUpdated, }, @@ -97,10 +97,13 @@ export default { handleSheetCreateAfter(e) { console.log('setsheet', e); }, + isOpen(ws) { + return ws.readyState === ws.OPEN + }, initSocket() { const {id} = this.$store.state.user;//${location.origin} const token = localStorage.getItem("token") - this.socket = new WebSocket(`ws://192.168.1.144/api/actual/base/ws/luckysheet/${this.workbookId}/${id}`,token); + this.socket = new WebSocket(`ws://219.146.91.110:30801/api/actual/base/ws/luckysheet/${this.workbookId}/${id}`,token); this.socket.addEventListener('open', () => { console.log('WebSocket连接已打开'); }); @@ -111,7 +114,11 @@ export default { }); }, sendMessage(message) { - this.socket.send(JSON.stringify(message)); + if (this.isOpen(this.socket)) { + this.socket.send(JSON.stringify(message)); + } else { + console.info('链接已经断开'); + } }, handleClickMenu(i) { this.menuActive = i; @@ -178,8 +185,8 @@ export default { this.selectedCell = "第" + row + "行" + "第" + column + "列"; }, - handleCellUpdateBefore() { - this.selectedCell = ""; + handleCellUpdateBefore(e) { + console.log(e); }, handleTabClick(tab, event) { console.log(tab, event);