From f1a7e68e470c42fe45191caee167e6a2a07f6f39 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Sun, 9 Apr 2023 16:48:46 +0800 Subject: [PATCH] :bug: Improve user experience. --- src-tauri/src/app/menu.rs | 3 ++- src-tauri/src/inject/component.js | 1 + src-tauri/src/inject/event.js | 13 +++++++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src-tauri/src/app/menu.rs b/src-tauri/src/app/menu.rs index a418b39..86819b3 100644 --- a/src-tauri/src/app/menu.rs +++ b/src-tauri/src/app/menu.rs @@ -10,7 +10,8 @@ use tauri_plugin_window_state::{AppHandleExt, StateFlags}; pub fn get_menu() -> Menu { let close = CustomMenuItem::new("close".to_string(), "Close Window").accelerator("CmdOrCtrl+W"); - let goto_url_item = CustomMenuItem::new("goto_url".to_string(), "Go to URL...").accelerator("CmdOrCtrl+Shift+L"); + let goto_url_item = CustomMenuItem::new("goto_url".to_string(), "Go to URL...") + .accelerator("CmdOrCtrl+Shift+L"); let first_menu = Menu::new() .add_native_item(MenuItem::Copy) .add_native_item(MenuItem::Cut) diff --git a/src-tauri/src/inject/component.js b/src-tauri/src/inject/component.js index ddf74de..42234eb 100644 --- a/src-tauri/src/inject/component.js +++ b/src-tauri/src/inject/component.js @@ -45,6 +45,7 @@ document.addEventListener('DOMContentLoaded', () => { .pake-modal-content label { display: block; + color: #11182B; margin-bottom: 12px; font-weight: bold; } diff --git a/src-tauri/src/inject/event.js b/src-tauri/src/inject/event.js index ba13bf0..dfe308e 100644 --- a/src-tauri/src/inject/event.js +++ b/src-tauri/src/inject/event.js @@ -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(); +}