mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-01 10:01:07 +02:00
fix(core): toggle devtools via global shortcut (#7937)
* fix(core): toggle devtools via global shortcut * Update .changes/fix-toggle-devtools.md
This commit is contained in:
committed by
GitHub
parent
a3277a245c
commit
3671edbcff
5
.changes/fix-toggle-devtools.md
Normal file
5
.changes/fix-toggle-devtools.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri": patch:bug
|
||||
---
|
||||
|
||||
Fix devtools not toggling on `ctrl+shift+i` or `cmd+alt+i` shortcuts.
|
||||
@@ -3,10 +3,12 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
(function () {
|
||||
const osName = __TEMPLATE_os_name__
|
||||
|
||||
function toggleDevtoolsHotkey() {
|
||||
const isHotkey = navigator.appVersion.includes("Mac")
|
||||
? (event) => event.metaKey && event.altKey && event.key === "I"
|
||||
: (event) => event.ctrlKey && event.shiftKey && event.key === "I";
|
||||
const isHotkey = osName === 'macos' ?
|
||||
(event) => event.metaKey && event.altKey && event.code === "KeyI" :
|
||||
(event) => event.ctrlKey && event.shiftKey && event.code === "KeyI";
|
||||
|
||||
document.addEventListener("keydown", (event) => {
|
||||
if (isHotkey(event)) {
|
||||
|
||||
@@ -802,6 +802,12 @@ impl<R: Runtime> WindowManager<R> {
|
||||
protocol_scheme: &'a str,
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[default_template("../scripts/toggle-devtools.js")]
|
||||
struct ToggleDevtoolsScript<'a> {
|
||||
os_name: &'a str,
|
||||
}
|
||||
|
||||
let bundle_script = if with_global_tauri {
|
||||
include_str!("../scripts/bundle.global.js")
|
||||
} else {
|
||||
@@ -815,9 +821,13 @@ impl<R: Runtime> WindowManager<R> {
|
||||
};
|
||||
|
||||
#[cfg(any(debug_assertions, feature = "devtools"))]
|
||||
let hotkeys = include_str!("../scripts/toggle-devtools.js");
|
||||
let hotkeys = ToggleDevtoolsScript {
|
||||
os_name: std::env::consts::OS,
|
||||
}
|
||||
.render_default(&Default::default())?
|
||||
.into_string();
|
||||
#[cfg(not(any(debug_assertions, feature = "devtools")))]
|
||||
let hotkeys = "";
|
||||
let hotkeys = String::default();
|
||||
|
||||
InitJavascript {
|
||||
pattern_script,
|
||||
@@ -846,7 +856,7 @@ impl<R: Runtime> WindowManager<R> {
|
||||
event_initialization_script: &self.event_initialization_script(),
|
||||
plugin_initialization_script,
|
||||
freeze_prototype,
|
||||
hotkeys,
|
||||
hotkeys: &hotkeys,
|
||||
}
|
||||
.render_default(&Default::default())
|
||||
.map(|s| s.into_string())
|
||||
|
||||
21
examples/api/src-tauri/Cargo.lock
generated
21
examples/api/src-tauri/Cargo.lock
generated
@@ -1954,9 +1954,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.19"
|
||||
version = "0.4.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4"
|
||||
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
|
||||
|
||||
[[package]]
|
||||
name = "loom"
|
||||
@@ -3529,7 +3529,7 @@ checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5"
|
||||
|
||||
[[package]]
|
||||
name = "tauri"
|
||||
version = "1.4.1"
|
||||
version = "1.5.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.21.2",
|
||||
@@ -3591,10 +3591,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tauri-build"
|
||||
version = "1.4.0"
|
||||
version = "1.5.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cargo_toml",
|
||||
"dirs-next",
|
||||
"heck 0.4.1",
|
||||
"json-patch",
|
||||
"quote",
|
||||
@@ -3604,11 +3605,12 @@ dependencies = [
|
||||
"tauri-codegen",
|
||||
"tauri-utils",
|
||||
"tauri-winres",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-codegen"
|
||||
version = "1.4.0"
|
||||
version = "1.4.1"
|
||||
dependencies = [
|
||||
"base64 0.21.2",
|
||||
"brotli",
|
||||
@@ -3632,7 +3634,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tauri-macros"
|
||||
version = "1.4.0"
|
||||
version = "1.4.1"
|
||||
dependencies = [
|
||||
"heck 0.4.1",
|
||||
"proc-macro2",
|
||||
@@ -3644,7 +3646,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tauri-runtime"
|
||||
version = "0.14.0"
|
||||
version = "0.14.1"
|
||||
dependencies = [
|
||||
"gtk",
|
||||
"http",
|
||||
@@ -3663,7 +3665,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tauri-runtime-wry"
|
||||
version = "0.14.0"
|
||||
version = "0.14.1"
|
||||
dependencies = [
|
||||
"cocoa",
|
||||
"gtk",
|
||||
@@ -3681,7 +3683,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tauri-utils"
|
||||
version = "1.4.0"
|
||||
version = "1.5.0"
|
||||
dependencies = [
|
||||
"aes-gcm",
|
||||
"brotli",
|
||||
@@ -3694,6 +3696,7 @@ dependencies = [
|
||||
"infer 0.12.0",
|
||||
"json-patch",
|
||||
"kuchikiki",
|
||||
"log",
|
||||
"memchr",
|
||||
"phf 0.10.1",
|
||||
"proc-macro2",
|
||||
|
||||
Reference in New Issue
Block a user