perf: 优化新窗口链接打开逻辑

This commit is contained in:
kuaifan 2024-11-11 09:50:15 +08:00
parent bd7228a378
commit 812232b945

View File

@ -50,6 +50,7 @@ import MeetingManager from "./pages/manage/components/MeetingManager";
import DropdownMenu from "./components/DropdownMenu"; import DropdownMenu from "./components/DropdownMenu";
import {ctrlPressed} from "./mixins/ctrlPressed"; import {ctrlPressed} from "./mixins/ctrlPressed";
import {mapState} from "vuex"; import {mapState} from "vuex";
import {Store} from "le5le-store";
export default { export default {
mixins: [ctrlPressed], mixins: [ctrlPressed],
@ -272,14 +273,19 @@ export default {
} }
}, },
isUseDefaultBrowser(url) { /**
* 获取链接打开方式
* @param url
* @returns {number} // 0: 1: 2:
*/
getUrlMethodType(url) {
// Ctrl|Command // Ctrl|Command
if (this.isCtrlCommandPressed) { if (this.isCtrlCommandPressed) {
return true; return 1;
} }
// //
if (this.isMeetingUrlStrict(url)) { if (this.isMeetingUrlStrict(url)) {
return true; return 1;
} }
// //
if ($A.getDomain(url) == $A.getDomain($A.mainUrl())) { if ($A.getDomain(url) == $A.getDomain($A.mainUrl())) {
@ -289,15 +295,25 @@ export default {
// api/dialog/msg/download // api/dialog/msg/download
// api/project/task/filedown // api/project/task/filedown
if (/^\/(uploads|api\/dialog\/msg\/download|api\/project\/task\/filedown)/.test(pathname)) { if (/^\/(uploads|api\/dialog\/msg\/download|api\/project\/task\/filedown)/.test(pathname)) {
return true; return 1;
} }
// api/file/content?down=yes // api/file/content?down=yes
if (/^\/api\/file\/content/.test(pathname) && searchParams.get('down') === 'yes') { if (/^\/api\/file\/content/.test(pathname) && searchParams.get('down') === 'yes') {
return true; return 1;
}
// meeting/1234567890/xxxxx
if (/^\/meeting\/\d+\/\S+$/.test(pathname)) {
const meetingId = pathname.split('/')[2];
Store.set('addMeeting', {
type: 'join',
meetingid: meetingId,
meetingdisabled: true,
});
return 2;
} }
} catch (e) { } } catch (e) { }
} }
return false; return 0;
}, },
isMeetingUrlStrict(url) { isMeetingUrlStrict(url) {
@ -343,11 +359,17 @@ export default {
} }
} }
window.__onBeforeOpenWindow = ({url}) => { window.__onBeforeOpenWindow = ({url}) => {
if (this.isUseDefaultBrowser(url)) { const urlType = this.getUrlMethodType(url)
return false; // 使 if (urlType === 2) {
//
return true;
} else if (urlType === 1) {
// 使
return false;
} }
// 使
this.$store.dispatch("openWebTabWindow", url) this.$store.dispatch("openWebTabWindow", url)
return true; // return true
} }
this.$Electron.registerMsgListener('dispatch', args => { this.$Electron.registerMsgListener('dispatch', args => {
if (!$A.isJson(args)) { if (!$A.isJson(args)) {
@ -406,10 +428,16 @@ export default {
} }
// //
window.__onCreateTarget = (url) => { window.__onCreateTarget = (url) => {
if (this.isUseDefaultBrowser(url)) { const urlType = this.getUrlMethodType(url)
if (urlType === 2) {
//
return;
} else if (urlType === 1) {
// 使
$A.eeuiAppOpenWeb(url); $A.eeuiAppOpenWeb(url);
return; return;
} }
// App
this.$store.dispatch('openAppChildPage', { this.$store.dispatch('openAppChildPage', {
pageType: 'app', pageType: 'app',
pageTitle: ' ', pageTitle: ' ',