From cb6a2ff6e4901613ea0218d2758b1c368f6ae139 Mon Sep 17 00:00:00 2001 From: jmal Date: Sat, 25 Mar 2023 23:16:14 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=88=B0=E6=95=B0=E6=8D=AE=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/setting/cloudManager.vue | 18 +++++++++++++----- src/websocket/sockJS.js | 3 ++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/views/setting/cloudManager.vue b/src/views/setting/cloudManager.vue index a06f9ee..1ef149d 100644 --- a/src/views/setting/cloudManager.vue +++ b/src/views/setting/cloudManager.vue @@ -41,7 +41,8 @@
网盘同步: + class="el-icon-refresh"> + {{syncPercent}}%
一般用于初始化操作, 将文件数据同步到数据库
重置角色、菜单: @@ -68,6 +69,7 @@ export default { uploadUrl: `${process.env.VUE_APP_BASE_API}/user/setting/upload_logo?jmal-token=${this.$store.state.user.token}&name=${this.$store.state.user.name}`, title: '网盘管理', syncLoading: false, + syncPercent: 100, resetLoading: false, webpEnabled: false, logoFileName: '', @@ -81,8 +83,11 @@ export default { this.getWebsiteSetting() this.getInfo() this.getIsSync() - Bus.$on('msg/synced', () => { - this.syncLoading = false + Bus.$on('msg/synced', (msg) => { + this.syncPercent = msg.body + if (this.syncPercent >= 100) { + this.syncLoading = false + } }) }, destroyed() { @@ -162,8 +167,10 @@ export default { }) }, getIsSync() { - settingApi.isSync().then((res) => { - this.syncLoading = res.data + settingApi.isSync({username: this.$store.state.user.name}).then((res) => { + this.syncLoading = true; + this.syncPercent = res.data + this.syncLoading = this.syncPercent < 100; }) }, sync() { @@ -173,6 +180,7 @@ export default { type: 'warning' }).then(() => { this.syncLoading = true + this.syncPercent = 0 settingApi.sync({username: this.$store.state.user.name}).then(() => { this.$message.success("开始同步...") }) diff --git a/src/websocket/sockJS.js b/src/websocket/sockJS.js index e97a0fb..5a90869 100644 --- a/src/websocket/sockJS.js +++ b/src/websocket/sockJS.js @@ -50,6 +50,7 @@ function connect(username,token){ export function disconnect() { if (ws.isConnected) { ws.stompClient.disconnect(); + ws.isConnected = false } - clearInterval(ws.timer); + clearInterval(ws.timer) }