From aac4b6ccfe5fe0b62f3cf7446f0c4470eb95c9f1 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Sun, 1 Dec 2019 13:45:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E6=89=80=E6=9C=89=E5=A4=96=E9=83=A8?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E4=BB=8E=E9=BB=98=E8=AE=A4=E6=B5=8F=E8=A7=88?= =?UTF-8?q?=E5=99=A8=E6=89=93=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/App.vue | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/renderer/App.vue b/src/renderer/App.vue index f70ea133..25183ce5 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -23,7 +23,7 @@ import { mapMutations, mapGetters, mapActions } from 'vuex' import { rendererOn, rendererSend } from '../common/ipc' import { isLinux } from '../common/utils' import music from './utils/music' -import { throttle } from './utils' +import { throttle, openUrl } from './utils' window.ELECTRON_DISABLE_SECURITY_WARNINGS = process.env.ELECTRON_DISABLE_SECURITY_WARNINGS dnscache({ enable: true, @@ -109,6 +109,7 @@ export default { ...mapMutations('download', ['updateDownloadList']), ...mapMutations(['setSetting']), init() { + document.body.addEventListener('click', this.handleBodyClick, true) if (this.isProd && !isLinux) { document.body.addEventListener('mouseenter', this.dieableIgnoreMouseEvents) document.body.addEventListener('mouseleave', this.enableIgnoreMouseEvents) @@ -228,6 +229,12 @@ export default { clearTimeout(this.updateTimeout) this.updateTimeout = null }, + handleBodyClick(event) { + if (event.target.tagName != 'A') return + if (event.target.host == window.location.host) return + event.preventDefault() + if (/^https?:\/\//.test(event.target.href)) openUrl(event.target.href) + }, }, beforeDestroy() { this.clearUpdateTimeout() @@ -235,6 +242,7 @@ export default { document.body.removeEventListener('mouseenter', this.dieableIgnoreMouseEvents) document.body.removeEventListener('mouseleave', this.enableIgnoreMouseEvents) } + document.body.removeEventListener('click', this.handleBodyClick) }, }