mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-07-14 19:10:28 +03:00
feat(core): add isTauri
(#9539)
* feat(core): add `isTauri` * generate api
This commit is contained in:
parent
005fe8ce1e
commit
70c51371e0
6
.changes/api-isTauri.md
Normal file
6
.changes/api-isTauri.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
"@tauri-apps/api": "patch:feat"
|
||||
---
|
||||
|
||||
Add `isTauri` function in `core` module to check whether running inside tauri or not.
|
||||
|
6
.changes/core-isTauri.md
Normal file
6
.changes/core-isTauri.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
"tauri": "patch:feat"
|
||||
---
|
||||
|
||||
Add `window.isTauri` to check whether running inside tauri or not.
|
||||
|
File diff suppressed because one or more lines are too long
@ -165,6 +165,10 @@ impl<R: Runtime> WebviewManager<R> {
|
||||
webview_attributes = webview_attributes
|
||||
.initialization_script(
|
||||
r#"
|
||||
Object.defineProperty(window, 'isTauri', {
|
||||
value: true,
|
||||
});
|
||||
|
||||
if (!window.__TAURI_INTERNALS__) {
|
||||
Object.defineProperty(window, '__TAURI_INTERNALS__', {
|
||||
value: {
|
||||
|
@ -238,6 +238,10 @@ export class Resource {
|
||||
}
|
||||
}
|
||||
|
||||
function isTauri() {
|
||||
return 'isTauri' in window && window.isTauri
|
||||
}
|
||||
|
||||
export type { InvokeArgs, InvokeOptions }
|
||||
|
||||
export {
|
||||
@ -246,5 +250,6 @@ export {
|
||||
PluginListener,
|
||||
addPluginListener,
|
||||
invoke,
|
||||
convertFileSrc
|
||||
convertFileSrc,
|
||||
isTauri
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user