perf: 优化访问链接

This commit is contained in:
kuaifan 2025-04-14 12:06:26 +08:00
parent d4697cb203
commit dcf96e2bf5
4 changed files with 40 additions and 20 deletions

View File

@ -471,7 +471,7 @@ class IndexController extends InvokeController
action: "eeuiAppSendMessage",
data: [
{
action: 'setPageData',
action: 'setPageData', // 设置页面数据
data: {
showProgress: true,
titleFixed: true,
@ -479,7 +479,7 @@ class IndexController extends InvokeController
}
},
{
action: 'createTarget',
action: 'createTarget', // 创建目标(访问新地址)
url: "{$redirectUrl}",
}
]

23
electron/electron.js vendored
View File

@ -442,11 +442,16 @@ function createChildWindow(args) {
// 加载地址
const hash = `${args.hash || args.path}`;
if (/^https?:/i.test(hash)) {
browser.loadURL(hash).then(_ => { }).catch(_ => { })
browser.loadURL(hash)
.then(_ => { })
.catch(_ => { })
} else if (isPreload) {
browser.webContents.executeJavaScript(`if(typeof window.__initializeApp === 'function'){window.__initializeApp('${hash}')}else{throw new Error('no function')}`, true).catch(() => {
utils.loadUrlOrFile(browser, devloadUrl, hash)
});
browser
.webContents
.executeJavaScript(`if(typeof window.__initializeApp === 'function'){window.__initializeApp('${hash}')}else{throw new Error('no function')}`, true)
.catch(() => {
utils.loadUrlOrFile(browser, devloadUrl, hash)
});
} else {
utils.loadUrlOrFile(browser, devloadUrl, hash)
}
@ -567,10 +572,6 @@ function createWebTabWindow(args) {
args = {url: args}
}
if (!allowedUrls.test(args.url)) {
return;
}
// 创建父级窗口
if (!webTabWindow) {
const titleBarOverlay = {
@ -602,6 +603,12 @@ function createWebTabWindow(args) {
},
}, userConf.get('webTabWindow', {})))
const originalClose = webTabWindow.close;
webTabWindow.close = function() {
webTabClosedByShortcut = true;
return originalClose.apply(this, arguments);
};
webTabWindow.on('resize', () => {
resizeWebTab(0)
})

View File

@ -23,11 +23,17 @@ html, body {
color: #333;
}
.app {
display: flex;
align-items: center;
}
.nav {
font-family: var(--tab-font-family);
font-feature-settings: 'clig', 'kern';
flex: 1;
width: 0;
display: flex;
width: 100%;
cursor: default;
background-color: var(--tab-background);
-webkit-app-region: drag;
@ -36,7 +42,7 @@ html, body {
.nav ul {
display: flex;
height: 35px;
margin: 5px 46px 0 0;
margin-top: 5px;
user-select: none;
overflow-x: auto;
overflow-y: hidden;
@ -96,14 +102,13 @@ html, body {
/* 浏览器打开 */
.browser {
position: absolute;
top: 0;
right: 0;
flex-shrink: 0;
display: flex;
align-items: center;
height: 38px;
height: 40px;
padding: 0 14px;
cursor: pointer;
background-color: var(--tab-background);
-webkit-app-region: none;
}
.browser span {

View File

@ -20,7 +20,7 @@
</li>
</ul>
</div>
<div v-if="tabs.length > 0" class="browser" @click="onBrowser">
<div v-if="canBrowser" class="browser" @click="onBrowser">
<span></span>
</div>
</div>
@ -119,15 +119,23 @@
}
},
computed: {
activeItem() {
if (this.tabs.length === 0) {
return null
}
return this.tabs.find(item => item.id === this.activeId)
},
pageTitle() {
const activeItem = this.tabs.find(item => item.id === this.activeId)
return activeItem ? activeItem.title : 'Untitled'
return this.activeItem ? this.activeItem.title : 'Untitled'
},
canBrowser() {
return !(this.activeItem && /^file:/.test(this.activeItem.url))
}
},
watch: {
pageTitle(title) {
document.title = title;
}
},
},
methods: {
onSwitch(item) {