瀏覽代碼

fix: no longer unpacking and flattening payload, closes #7673 (#7677)

Simon Hyll 1 年之前
父節點
當前提交
e98393e499
共有 4 個文件被更改,包括 8 次插入5 次删除
  1. 5 0
      .changes/fix-ipc-payload.md
  2. 2 2
      core/tauri/scripts/core.js
  3. 1 1
      core/tauri/scripts/ipc-protocol.js
  4. 0 2
      core/tauri/src/ipc/protocol.rs

+ 5 - 0
.changes/fix-ipc-payload.md

@@ -0,0 +1,5 @@
+---
+"tauri": 'patch:bug'
+---
+
+No longer unpacking and flattening the `payload` over the IPC so that commands with arguments called `cmd`, `callback`, `error`, `options` or `payload` aren't breaking the IPC.

+ 2 - 2
core/tauri/scripts/core.js

@@ -59,11 +59,11 @@
 
   window.__TAURI_INVOKE__ = function invoke(cmd, payload = {}, options) {
     return new Promise(function (resolve, reject) {
-      var callback = window.__TAURI__.transformCallback(function (r) {
+      const callback = window.__TAURI__.transformCallback(function (r) {
         resolve(r)
         delete window[`_${error}`]
       }, true)
-      var error = window.__TAURI__.transformCallback(function (e) {
+      const error = window.__TAURI__.transformCallback(function (e) {
         reject(e)
         delete window[`_${callback}`]
       }, true)

+ 1 - 1
core/tauri/scripts/ipc-protocol.js

@@ -44,7 +44,7 @@
         })
       } else {
         // otherwise use the postMessage interface
-        const { data } = processIpcMessage({ cmd, callback, error, options, ...payload })
+        const { data } = processIpcMessage({ cmd, callback, error, options, payload })
         window.ipc.postMessage(data)
       }
     }

+ 0 - 2
core/tauri/src/ipc/protocol.rs

@@ -127,7 +127,6 @@ fn handle_ipc_message<R: Runtime>(message: String, manager: &WindowManager<R>, l
       cmd: String,
       callback: CallbackFn,
       error: CallbackFn,
-      #[serde(flatten)]
       payload: serde_json::Value,
       options: Option<RequestOptions>,
     }
@@ -142,7 +141,6 @@ fn handle_ipc_message<R: Runtime>(message: String, manager: &WindowManager<R>, l
         cmd: String,
         callback: CallbackFn,
         error: CallbackFn,
-        #[serde(flatten)]
         payload: crate::utils::pattern::isolation::RawIsolationPayload<'a>,
         options: Option<RequestOptions>,
       }