perf: 优化使用默认浏览器打开链接

This commit is contained in:
kuaifan 2024-11-11 00:06:19 +08:00
parent 047771e6f8
commit 095f461cfd
2 changed files with 95 additions and 4 deletions

View File

@ -48,9 +48,12 @@ import GuidePage from "./components/GuidePage";
import TaskOperation from "./pages/manage/components/TaskOperation";
import MeetingManager from "./pages/manage/components/MeetingManager";
import DropdownMenu from "./components/DropdownMenu";
import {ctrlPressed} from "./mixins/ctrlPressed";
import {mapState} from "vuex";
export default {
mixins: [ctrlPressed],
components: {
MeetingManager,
DropdownMenu,
@ -270,14 +273,26 @@ export default {
},
isUseDefaultBrowser(url) {
if (/web\.zoom\.us/i.test(url)
|| /meeting\.tencent\.com/i.test(url)
|| /meet\.google\.com/i.test(url)) {
// Ctrl|Command
if (this.isCtrlCommandPressed) {
return true;
}
//
if (this.isMeetingUrlStrict(url)) {
return true;
}
//
if ($A.getDomain(url) == $A.getDomain($A.mainUrl())) {
try {
if (/^\/uploads\//i.test(new URL(url).pathname)) {
const {pathname, searchParams} = new URL(url);
// uploads/
// api/dialog/msg/download
// api/project/task/filedown
if (/^\/(uploads|api\/dialog\/msg\/download|api\/project\/task\/filedown)/.test(pathname)) {
return true;
}
// api/file/content?down=yes
if (/^\/api\/file\/content/.test(pathname) && searchParams.get('down') === 'yes') {
return true;
}
} catch (e) { }
@ -285,6 +300,39 @@ export default {
return false;
},
isMeetingUrlStrict(url) {
const meetingDomains = [
//
'web.zoom.us',
'meeting.tencent.com',
'meet.google.com',
'teams.microsoft.com',
'join.skype.com',
'bluejeans.com',
'webex.com',
'voovmeeting.com',
//
'meeting.feishu.cn',
'meeting.dingtalk.com',
'jitsi.baidu.com',
//
'whereby.com',
'meet.jit.si',
'gotomeeting.com',
'8x8.vc',
'lifesize.com',
'starleaf.com',
//
'classroomscreen.com',
'bigbluebutton.org'
];
const lowerUrl = `${url}`.toLowerCase()
return meetingDomains.some(domain => lowerUrl.indexOf(domain) !== -1);
},
electronEvents() {
if (!this.$Electron) {
return;

View File

@ -0,0 +1,43 @@
export const ctrlPressed = {
data() {
return {
isCtrlCommandPressed: false
};
},
created() {
this.handleKeyDown = this.handleKeyDown.bind(this);
this.handleKeyUp = this.handleKeyUp.bind(this);
this.handleBlur = this.handleBlur.bind(this);
},
mounted() {
document.addEventListener('keydown', this.handleKeyDown);
document.addEventListener('keyup', this.handleKeyUp);
window.addEventListener('blur', this.handleBlur);
},
beforeDestroy() {
document.removeEventListener('keydown', this.handleKeyDown);
document.removeEventListener('keyup', this.handleKeyUp);
window.removeEventListener('blur', this.handleBlur);
},
methods: {
handleKeyDown(event) {
if (event.ctrlKey || event.metaKey) {
this.isCtrlCommandPressed = true;
}
},
handleKeyUp(event) {
if (!event.ctrlKey && !event.metaKey) {
this.isCtrlCommandPressed = false;
}
},
handleBlur() {
this.isCtrlCommandPressed = false;
}
}
};