添加移除遮罩子菜单

This commit is contained in:
BTMuli
2024-01-02 00:58:58 +08:00
parent 7674407b71
commit e5c3d10991
2 changed files with 15 additions and 1 deletions

View File

@@ -9,7 +9,8 @@ use url::Url;
fn create_utils_menu() -> Menu {
let retry_bridge = CustomMenuItem::new("retry".to_string(), "重试桥接");
let mock_touch = CustomMenuItem::new("mock_touch".to_string(), "模拟触摸");
return Menu::new().add_item(retry_bridge).add_item(mock_touch);
let remove_overlay = CustomMenuItem::new("remove_overlay".to_string(), "移除遮罩");
return Menu::new().add_item(retry_bridge).add_item(mock_touch).add_item(remove_overlay);
}
// 创建米游社客户端菜单
@@ -133,6 +134,16 @@ pub async fn create_mhy_client(handle: AppHandle, func: String, url: String) {
})()"#;
window.eval(&execute_js).ok().unwrap();
}
"remove_overlay" => {
let window = handle.get_window("mhy_client").unwrap();
let execute_js = r#"javascript:(async function(){
const arg = {
method: 'teyvat_remove',
}
await window.__TAURI__.event.emit('post_mhy_client',JSON.stringify(arg));
})()"#;
window.eval(&execute_js).ok().unwrap();
}
_ => {}
});
}

View File

@@ -279,6 +279,9 @@ class TGClient {
case "teyvat_open":
createPost(<string>arg.payload);
break;
case "teyvat_remove":
await this.hideOverlay();
break;
case "teyvat_retry": {
const executeJS = `javascript:(function(){
window.location.reload();