Plugin API
繁體中文
繁體中文
  • 入門
    • 簡介
    • 你的第一個插件
    • 檔案結構概述
    • 插件類型
      • 視窗
      • 背景服務
      • 格式擴充
      • 檢查器
    • 除錯插件
  • 部署
    • 準備插件
    • 打包插件
    • 發佈插件
    • 更新插件
    • 開發者政策
    • 插件圖示樣板
  • 開發指南
    • manifest.json 完整設定
    • 取得數據
    • 修改數據
    • 存取本機檔案
    • 發出網路請求
    • 使用 Node.js 原生 API
    • 使用第三方模快
    • 多國語言(i18n)
    • 無邊框視窗
  • API 參考
    • event(事件)
    • item(項目)
    • folder(資料夾)
    • tag(標籤)
    • tagGroup(標籤群組)
    • library(資源庫)
    • window(視窗)
    • app(應用)
    • os(作業系統)
    • screen(螢幕)
    • notification(通知)
    • contextMenu(右鍵選單)
    • dialog(對話框)
    • clipboard(剪貼板)
    • drag(拖曳檔案)
    • shell(殼)
    • log(日誌)
  • 额外组件
    • FFmpeg
Powered by GitBook
On this page
  • showOpenDialog(options)
  • showSaveDialog(options)
  • showMessageBox(options)
  • showErrorBox(title, content)
  1. API 參考

dialog(對話框)

跳出系統對話框功能,包含開啓、儲存檔案、提示、警報等。

PreviouscontextMenu(右鍵選單)Nextclipboard(剪貼板)

Last updated 11 months ago

下面是一個選擇多個檔案的對話框範例:

let result = await eagle.dialog.showOpenDialog({ 
    properties: ['openFile', 'multiSelections'] 
});

方法

showOpenDialog(options)

顯示開啓檔案對話框。

  • options Object

    • title string (可選) - 對話框視窗的標題

    • defaultPath string (可選) - 對話框的預設展示路徑

    • buttonLabel string (可選) - 「確認」按鈕的自定標籤, 當為空時, 將使用預設標籤。

    • filters [] (可選)

      • name string

      • extensions string[]

    • properties string[] (可選) - 包含對話框相關屬性。 支援以下屬性值:

      • openFile - 允許選擇檔案

      • openDirectory - 允許選擇資料夾

      • multiSelections- 允許多選。

      • showHiddenFiles- 顯示對話框中的隱藏檔案。

      • createDirectory macOS - 允許你透過對話框的形式新增新的目錄。

      • promptToCreate Windows- 如果輸入的檔案路徑在對話框中不存在, 則提示新增。 這並不是真的在路徑上新增一個檔案,而是允許返回一些不存在的地址交由應用程式去創

    • message string (可選) macOS - 顯示在輸入框上方的消息。

  • 返回 Promise<result: Object>

    • resultObject

      • canceled boolean - 對話框是否被取消

      • filePaths string[] - 使用者選擇的檔案路徑的數組. 如果對話框被取消,這將是一個空的數組。

{
  filters: [
    { name: 'Images', extensions: ['jpg', 'png', 'gif'] },
    { name: 'Movies', extensions: ['mkv', 'avi', 'mp4'] },
    { name: 'Custom File Type', extensions: ['as'] },
    { name: 'All Files', extensions: ['*'] }
  ]
}
let result = await eagle.dialog.showOpenDialog({
    properties: ['openFile', 'openDirectory']
});

showSaveDialog(options)

顯示儲存檔案對話框。

  • options Object

    • title string (可選) - 對話框視窗的標題

    • defaultPath string (可選) - 對話框的預設展示路徑

    • buttonLabel string (可選) - 「確認」按鈕的自定標籤, 當為空時, 將使用預設標籤。

      • name string

      • extensions string[]

    • properties string[] (可選) - 包含對話框相關屬性。 支援以下屬性值:

      • openDirectory - 允許選擇資料夾

      • showHiddenFiles- 顯示對話框中的隱藏檔案。

      • createDirectory macOS - 允許你透過對話框的形式新增新的目錄。

  • 返回 Promise<result: Object>

    • resultObject

      • canceled boolean - 對話框是否被取消

      • filePath string - 如果對話框被取消,該值為 undefined。

{
  filters: [
    { name: 'Images', extensions: ['jpg', 'png', 'gif'] },
    { name: 'Movies', extensions: ['mkv', 'avi', 'mp4'] },
    { name: 'Custom File Type', extensions: ['as'] },
    { name: 'All Files', extensions: ['*'] }
  ]
}
let result = await eagle.dialog.showSaveDialog({
    properties: ['openDirectory']
});

showMessageBox(options)

顯示訊息對話框。

  • optionsObject

    • message string - 對話框主要內容

    • title string (可選) - 對話框標題

    • detail string (可選) - 額外資訊

    • buttons strings[] (可選) - 按鈕文字數組

    • type string (可選) - 可以為 none、 info、 error、question 或者 warning

  • 返回 Promise<result: Object>

    • resultObject

      • response Interger - 點擊按鈕的索引

let result = await eagle.dialog.showMessageBox({
    title: "Messagebox title",
    message: "Message from the Plugin process",
    detail: "Ultra message here",
    buttons: ["確定", "取消"],
    type: "info"
});

console.log(result);		// {response: 0}

showErrorBox(title, content)

顯示錯誤訊息的對話框。

  • title string - 顯示在錯誤框中的標題

  • content string - 顯示在錯誤框中的文字內容

  • 返回 Promise<void>

await eagle.dialog.showErrorBox("Error box title", "Error message from the Plugin process");

備註:此功能與 Electron API 的 功能類似。

filters [] (可選)

備註:此功能與 Electron API 的 功能類似。

此功能與 Electron API 的 功能類似。

備註:此功能與 Electron API 的 功能類似。

FileFilter
dialog.showOpenDialog
FileFilter
dialog.showSaveDialog
dialog.showSaveDialog
dialog.showSaveDialog