🐛 Improve user experience.

This commit is contained in:
Tw93
2023-04-09 16:48:46 +08:00
parent 5355fd2260
commit f1a7e68e47
3 changed files with 12 additions and 5 deletions

View File

@@ -45,6 +45,7 @@ document.addEventListener('DOMContentLoaded', () => {
.pake-modal-content label {
display: block;
color: #11182B;
margin-bottom: 12px;
font-weight: bold;
}

View File

@@ -115,15 +115,15 @@ document.addEventListener('DOMContentLoaded', () => {
const hrefUrl = new URL(anchorElement.href);
const absoluteUrl = hrefUrl.href;
// 处理外部链接跳转
// Handling external link redirection.
if (window.location.host !== hrefUrl.host && target === '_blank') {
e.preventDefault();
invoke('open_browser', { url: absoluteUrl });
return;
}
// 处理下载链接让Rust处理
if (/\.[a-zA-Z0-9]+$/i.test(absoluteUrl)) {
// Process download links for Rust to handle.
if (/\.[a-zA-Z0-9]+$/i.test(removeUrlParameters(absoluteUrl))) {
e.preventDefault();
invoke('download_file', {
params: {
@@ -140,7 +140,6 @@ document.addEventListener('DOMContentLoaded', () => {
// Rewrite the window.open function.
const originalWindowOpen = window.open;
window.open = function (url, name, specs) {
console.log('0window.open>>>>>>>', url, name, specs);
// Apple login and google login
if (name === 'AppleAuthentication') {
//do nothing
@@ -168,3 +167,9 @@ function getFilenameFromUrl(url) {
const filename = urlPath.substring(urlPath.lastIndexOf('/') + 1);
return filename;
}
function removeUrlParameters(url) {
const parsedUrl = new URL(url);
parsedUrl.search = '';
return parsedUrl.toString();
}