<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                [TOC] > [接口總覽](https://tauri.app/v1/api/js/) ## 總覽 * [app](https://tauri.app/v1/api/js/app) 獲取版本信息 * [cli](https://tauri.app/v1/api/js/cli) 獲取參數 * [clipboard](https://tauri.app/v1/api/js/clipboard) 剪切板 * [dialog](https://tauri.app/v1/api/js/dialog) 確認框,文件框等 * [event](https://tauri.app/v1/api/js/event) * [fs](https://tauri.app/v1/api/js/fs) * [globalShortcut](https://tauri.app/v1/api/js/globalShortcut) 全局快捷鍵 * [http](https://tauri.app/v1/api/js/http) 網絡請求 * [mocks](https://tauri.app/v1/api/js/mocks) * [notification](https://tauri.app/v1/api/js/notification) 系統通知 * [os](https://tauri.app/v1/api/js/os) * [path](https://tauri.app/v1/api/js/path) * [process](https://tauri.app/v1/api/js/process) * [shell](https://tauri.app/v1/api/js/shell) * [tauri](https://tauri.app/v1/api/js/tauri) * [updater](https://tauri.app/v1/api/js/updater) * [window](https://tauri.app/v1/api/js/window) ## cli 示例 ``` import { getMatches } from '@tauri-apps/api/cli'; const matches = await getMatches(); if (matches.subcommand?.name === 'run') { // `./your-app run $ARGS` was executed const args = matches.subcommand?.matches.args if ('debug' in args) { // `./your-app run --debug` was executed } } else { const args = matches.args // `./your-app $ARGS` was executed } ``` ## clipboard 示例 ``` import { readText } from '@tauri-apps/api/clipboard'; const clipboardText = await readText(); ``` ## dialog 示例1 ``` import { confirm } from '@tauri-apps/api/dialog'; const confirmed = await confirm('Are you sure?', 'Tauri'); ``` 示例2: ``` import { open } from '@tauri-apps/api/dialog'; // Open a selection dialog for image files const selected = await open({ multiple: true, filters: [{ name: 'Image', extensions: ['png', 'jpeg'] }] }); if (Array.isArray(selected)) { // user selected multiple files } else if (selected === null) { // user cancelled the selection } else { // user selected a single file } ``` ## path 系統各個 常用path 路徑 各個路徑的實際值 ``` appCacheDir C:\Users\CPJ\AppData\Local\com.cpj.dev\ appConfigDir C:\Users\CPJ\AppData\Roaming\com.cpj.dev\ appDataDir C:\Users\CPJ\AppData\Roaming\com.cpj.dev\ appLocalDataDir C:\Users\CPJ\AppData\Local\com.cpj.dev\ appLogDir C:\Users\CPJ\AppData\Roaming\com.cpj.dev\logs\ audioDir C:\Users\CPJ\Music\ templateDir C:\Users\CPJ\AppData\Roaming\Microsoft\Windows\Templates\ desktopDir C:\Users\CPJ\Desktop\ documentDir 系統文件目錄 downloadDir 系統下載目錄 homeDir C:\Users\CPJ\ localDataDir C:\Users\CPJ\AppData\Local\ publicDir C:\Users\Public\ ``` 其他函數 ``` resolveResource 解析文件的絕對路徑 resourceDir 當前程序的目錄 extname 獲取文件后綴 isAbsolute join ``` 示例 ``` import { appLocalDataDir } from '@tauri-apps/api/path'; const appLocalDataDirPath = await appLocalDataDir(); ``` ## fs ``` copyFile createDir exists readBinaryFile readDir readTextFile removeDir removeFile renameFile writeBinaryFile writeTextFile ``` ## globalShortcut 示例1: ``` import { register } from '@tauri-apps/api/globalShortcut'; await register('CommandOrControl+Shift+C', () => { console.log('Shortcut triggered'); }); ``` ## notification 示例 ``` import { isPermissionGranted, requestPermission, sendNotification } from '@tauri-apps/api/notification'; let permissionGranted = await isPermissionGranted(); if (!permissionGranted) { const permission = await requestPermission(); permissionGranted = permission === 'granted'; } if (permissionGranted) { sendNotification('Tauri is awesome!'); sendNotification({ title: 'TAURI', body: 'Tauri is awesome!' }); } ``` ## os ``` arch 獲取當前架構 platform 獲取當前平臺 tempdir 獲取系統的臨時目錄 type 系統類型 linux,Darwin,Windows_NT version 系統版本 ``` ## shell 執行外部指令 tauri.conf.json ``` "tauri": { "allowlist": { "all": true, "shell": { "all": true, "open": true, "scope": [ { "name": "run-git-commit", "cmd": "node", "args": ["--help"] } ] } }, ... "externalBin": [ "bin/node" ], ``` vue ``` import { Command } from '@tauri-apps/api/shell' async function greet() { let childProcess = await new Command('run-git-commit').execute(); console.log(childProcess); } ``` ## window ### Window events ### WebviewWindow 再打開窗口 ``` // loading embedded asset: const webview = new WebviewWindow('theUniqueLabel', { url: 'path/to/page.html' }); // alternatively, load a remote URL: const webview = new WebviewWindow('theUniqueLabel', { url: 'https://github.com/tauri-apps/tauri' }); webview.once('tauri://created', function () { // webview window successfully created }); webview.once('tauri://error', function (e) { // an error happened creating the webview window }); // emit an event to the backend await webview.emit("some event", "data"); // listen to an event from the backend const unlisten = await webview.listen("event name", e => {}); unlisten(); ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看