From e4b38e4121fe0afe5487a4086ea93a4eb3bbcee6 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Fri, 9 Sep 2022 14:43:21 +0800 Subject: [PATCH] no message --- app/Http/Controllers/Api/UsersController.php | 25 -------------------- resources/assets/js/App.vue | 24 +++++++++++-------- 2 files changed, 14 insertions(+), 35 deletions(-) diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index 915ee7740..ca0f84d88 100755 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -831,31 +831,6 @@ class UsersController extends AbstractController } } - /** - * @api {get} api/users/ws/exist 15. websocket是否存在 - * - * @apiDescription 查询websocket连接是否存在 - * @apiVersion 1.0.0 - * @apiGroup users - * @apiName ws__exist - * - * @apiSuccess {Number} ret 返回状态码(1存在、0不存在) - * @apiSuccess {String} msg 返回信息(错误描述) - * @apiSuccess {Object} data 返回数据(同"获取我的信息"接口) - */ - public function ws__exist() - { - $fd = Request::header('fd'); - if (empty($fd)) { - return Base::retError('empty'); - } - if (WebSocket::whereFd($fd)->exists()) { - return Base::retSuccess('success'); - } else { - return Base::retError('not exist'); - } - } - /** * @api {get} api/users/meeting/open 16. 【会议】创建会议、加入会议 * diff --git a/resources/assets/js/App.vue b/resources/assets/js/App.vue index da6080ff3..d2abc60dd 100755 --- a/resources/assets/js/App.vue +++ b/resources/assets/js/App.vue @@ -76,7 +76,7 @@ export default { }, computed: { - ...mapState(['ws', 'themeMode']), + ...mapState(['ws', 'windowActive', 'themeMode']), isSoftware() { return this.$Electron || this.$isEEUiApp; @@ -138,6 +138,19 @@ export default { immediate: true }, + windowActive(active) { + if (active) { + this.__windowTimer && clearTimeout(this.__windowTimer) + this.__windowTimer = setTimeout(_ => { + this.$store.dispatch("websocketSend", { + type: 'handshake', + }).catch(_ => { + this.$store.dispatch("websocketConnection"); + }) + }, 600) + } + }, + themeMode() { this.synchThemeLanguage(); }, @@ -243,15 +256,6 @@ export default { this.$store.state.windowActive = true; if (num > 0) { this.$store.dispatch("getBasicData", 600) - if (this.ws === null) { - this.$store.dispatch("websocketConnection"); - } else { - this.$store.dispatch("call", { - url: 'users/ws/exist', - }).catch(_ => { - this.$store.dispatch("websocketConnection"); - }); - } } } },