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
  • 方法
  • isDarkColors()
  • getPath(name)
  • getFileIcon(path[, options])
  • createThumbnailFromPath(path, maxSize)
  • 屬性
  • version
  • build
  • locale
  • arch
  • platform
  • env
  • execPath
  • pid
  • isWindows
  • isMac
  • runningUnderARM64Translation
  • theme
  1. API 參考

app(應用)

獲取 Eagle 應用程式版本、架構、語系等屬性。

下面範例為 app 的常用屬性:

console.log(eagle.app.version);				// Eagle 版本
console.log(eagle.app.build);				// Eagle Build 號
console.log(eagle.app.locale);				// 應用介面語系,en/zh_CN/zh_TW/ja_JP
console.log(eagle.app.arch);				// x86 | x64
console.log(eagle.app.platform);			// darwin | win32
console.log(eagle.app.isWindows);			// true | false, 作業系統是否為 Windows
console.log(eagle.app.isMac);				// true | false, 作業系統是否為 Mac
console.log(eagle.app.runningUnderARM64Translation);	// 是否運行在 rosetta 轉譯模式

方法

isDarkColors()

確認當前系統是否處於深色(Dark)模式。

  • 返回 boolean - 當前系統是否正在處於 Dark 模式。

eagle.app.isDarkColors();		// true | false

getPath(name)

您可以透過名稱請求以下路徑

  • name string - 您可以透過名稱請求以下路徑

    • home - 使用者的 home 資料夾(主目錄)

    • appData - 每個使用者的應用程式數據目錄,預設情況下指向:

    • userData - 儲存你應用程式設定檔案的資料夾,預設是 appData 資料夾附加應用的名稱 按照習慣使用者儲存的數據檔案應該寫在此目錄,同時不建議在這寫大檔案,因為某些環境會備份此目錄到雲端儲存。

    • temp - 臨時資料夾

    • exe - 當前的可執行檔案

    • desktop - 當前使用者的桌面資料夾

    • documents - 使用者文檔目錄的路徑

    • downloads - 使用者下載目錄的路徑

    • music - 使用者音樂目錄的路徑

    • pictures - 使用者圖片目錄的路徑

    • videos - 使用者影片目錄的路徑

    • recent - 使用者最近檔案的目錄 (僅限 Windows)。

  • 返回 Promise<path: string> - path 查詢路徑結果。

await eagle.app.getPath('appData');	// 'C:\Users\User\AppData\Roaming'
await eagle.app.getPath('pictures');	// 'C:\Users\User\Pictures'
await eagle.app.getPath('desktop');	// 'C:\Users\User\Desktop'

getFileIcon(path[, options])

取得指定路徑檔案關聯的圖示。

  • path string - 欲取得圖示之檔案路徑

  • options Object(可選)

    • size string

    • small - 16x16

    • normal - 32x32

    • large - Windows 為 32x32, macOS 不支援。

  • 返回 Promise<img: NativeImage>

let img = await eagle.app.getFileIcon('path_to_file', { size: 'small' });

// 取得圖片資訊
let base64 = img.toDataURL();
let size = img.getSize();	// {'width': 16, height: 16}

// 儲存到電腦
let buffer = img.toPNG();
require('fs').writeFileSync('output_path/example.png', buffer);

createThumbnailFromPath(path, maxSize)

取得指定路徑檔案關聯的圖示。

  • path string - 欲取得縮圖之檔案路徑

  • maxSize Size - 返回縮圖的最大寬度和高度(正數)。 在 Windows 平台下將忽略 maxSize.height 並根據 maxSize.width 縮放高度

  • 返回 Promise<img: NativeImage>

let img = await eagle.app.createThumbnailFromPath('path_to_file', { 
    height: 200, 
    width: 200 
});

// 取得圖片資訊
let base64 = img.toDataURL();
let size = img.getSize();	// {'width': 200, height: 150}

// 儲存到電腦
let buffer = img.toPNG();
require('fs').writeFileSync('output_path/example.png', buffer);

屬性

version

string 屬性,獲取當前 Eagle 應用程式版本。

build

number 屬性,獲取當前 Eagle 應用程式 Build Number。

locale

string 屬性,獲取當前 Eagle 應用程式介面語系。

  • en - 英文

  • zh_CN - 簡體中文

  • zh_TW - 繁體中文

  • ja_JP - 日文

  • ko_KR - 韓文

  • es_ES - 西班牙文

  • de_DE - 德文

  • ru_RU - 俄文

arch

string 屬性,返回作業系統 CPU 架構。

  • x64

  • arm64

  • x86

platform

string 屬性,返回一個標識作業系統平台的字串。

  • darwin - macOS 作業系統

  • win32 - Windows 作業系統

env

Object 屬性,返回環境變數的對象。

console.log(eagle.app.env);

{
  APPDATA: "C:\\Users\\User\\AppData\\Roaming",
  HOMEDRIVE: "C:",
	HOMEPATH: "\\Users\\User",
  LANG: "zh_TW.UTF-8",
  TEMP: "C:\\Users\\User\\AppData\\Local\\Temp"
}
console.log(eagle.app.env['TEMP']);

"C:\\Users\\User\\AppData\\Local\\Temp"

execPath

string 屬性,當前應用程式執行路徑。

console.log(eagle.app.execPath);

"C:\\Program Files\\Eagle\\Eagle.exe"

pid

number 屬性,當前插件程式 id。

isWindows

boolean 屬性,是否當前為 Window 作業系統。

isMac

boolean 屬性,是否當前為 Mac 作業系統。

runningUnderARM64Translation

theme

string 屬性, - 當前主題配色的名稱,如 LIGHT、LIGHTGRAY、GRAY、DARK、BLUE、PURPLE。

Previouswindow(視窗)Nextos(作業系統)

Last updated 10 months ago

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

img - 一個 NativeImage 類型的應用圖示。

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

img - 檔案的縮圖預覽圖片。

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

boolean 屬性,為 true 時表明當前應用正在使用 ARM64 運行環境 (比如 macOS 或者 Windows ).

提示:此功能與 Electron API 的 功能類似,您可以使用此屬性來提示使用者下載應用程式的 arm64 版本,當使用者錯誤地在轉譯環境下運行 x64 版本。

app.getPath
NativeImage
app.getAppIcon
NativeImage
nativeImage.createThumbnailFromPath(path, maxSize)
Rosetta Translator Environment
WOW
app.runningUnderARM64Translation