ソースを参照

feat(core): add `isTauri` (#9539)

* feat(core): add `isTauri`

* generate api
Amr Bashir 1 年間 前
コミット
70c51371e0

+ 6 - 0
.changes/api-isTauri.md

@@ -0,0 +1,6 @@
+---
+"@tauri-apps/api": "patch:feat"
+---
+
+Add `isTauri` function in `core` module to check whether running inside tauri or not.
+

+ 6 - 0
.changes/core-isTauri.md

@@ -0,0 +1,6 @@
+---
+"tauri": "patch:feat"
+---
+
+Add `window.isTauri` to check whether running inside tauri or not.
+

ファイルの差分が大きいため隠しています
+ 0 - 0
core/tauri/scripts/bundle.global.js


+ 4 - 0
core/tauri/src/manager/webview.rs

@@ -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: {

+ 6 - 1
tooling/api/src/core.ts

@@ -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
 }

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません