Tauri invoke 方法本质上是调用的window.__TAURI_IPC__ import { invoke } from '@tauri-apps/api'; await invoke('command') 本质上就是调用的 window下的 __TAURI_IPC__方法 /** * Sends a message to the backend. * @example * ```typescript * import { invoke } from '@tauri-apps/api/tauri'; * await invoke('login', { user: 'tauri', password: 'poiwe3h4r5ip3yrhtew9ty' }); * ``` * * @param cmd The command name. * @param args The optional arguments to pass to the command. * @return A promise resolving or rejecting to the backend response. * * @since 1.0.0 */ async function invoke(cmd, args = {}) { return new Promise((resolve, reject) => { const callback = transformCallback((e) => { resolve(e); Reflect.deleteProperty(window, `_${error}`); }, true); const error = transformCallback((e) => { reject(e); Reflect.deleteProperty(window, `_${callback}`); }, true); window.__TAURI_IPC__({ cmd, callback, error, ...args }); }); }