🐛 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

@@ -10,7 +10,8 @@ use tauri_plugin_window_state::{AppHandleExt, StateFlags};
pub fn get_menu() -> Menu { pub fn get_menu() -> Menu {
let close = CustomMenuItem::new("close".to_string(), "Close Window").accelerator("CmdOrCtrl+W"); 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() let first_menu = Menu::new()
.add_native_item(MenuItem::Copy) .add_native_item(MenuItem::Copy)
.add_native_item(MenuItem::Cut) .add_native_item(MenuItem::Cut)

View File

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

View File

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