folder
The eagle.folder API allows you to easily create new folders or access existing ones in the current application.
// Get the currently selected folder in the Eagle application
let folder = (await eagle.folder.getSelected())[0];
// Modify properties
folder.name = 'New Folder Name';
folder.description = 'New description...';
// Save changes
await folder.save();🦄 Best Practice: To ensure data safety, please use the save() method provided by the API for data access and modification. Avoid directly modifying the metadata.json or any files under the Eagle resource library.
Methods
create(options)
Create a folder.
optionsObjectnamestring - Folder namedescriptionstring (optional) - Folder descriptionparentstring (optional) - Parent folder ID; with this parameter, it is equivalent tocreateSubfolder(parentId, options)
Returns
Promise<folder: Folder>- Successfully createdfolder
createSubfolder(parentId, options)
Create a subfolder.
parentIdstring - Parent folder IDoptionsObjectnamestring - Folder namedescriptionstring (optional) - Folder description
Returns
Promise<folder: Folder>- Successfully createdfolder
get(options)
Get folders with specified conditions.
optionsObject - Query conditionsidstring (optional) - Folder ididsstring[] (optional) - Array of folder idsisSelectedboolean (optional) - Currently selected foldersisRecentboolean (optional) - Recently accessed folders
Returns
Promise<folders: Folder[]>- Query resultfolders
getAll()
Get all folders.
Returns
Promise<folders: Folder[]>- Query resultfolders
getById(folderId)
Get the folder corresponding to folderId.
folderIdstring - Folder idReturns
Promise<folder: Folder>- Query resultfolder
getByIds(folderIds)
Get an array of folders corresponding to folderIds.
folderIdsstring[] - Array of folder idsReturns
Promise<folders: Folder[]>- Query resultfolders
getSelected()
Get the currently selected folders in the application.
Returns
Promise<folders: Folder[]>-folders
getRecents()
Get the recently used folders.
Returns
Promise<folders: Folder[]>-folders
open(folderId)
Eagle will open the folder corresponding to folderId.
Returns
Promise<void>
Class: Folder
An Object type returned by the Folder API get, provides modification and save functions.
🦄 Best Practice: To ensure data security, please use the save() method provided by the Folder instance for data access and modification, and avoid directly modifying the metadata.json or any files under the Eagle repository.
Instance Methods
save()
Save all modifications.
Returns
Promise<void>
open()
Eagle will open this folder.
Returns
Promise<void>
Instance Properties
The Folder instance includes the following properties:
id string
id stringRead-only, folder id.
name string
name stringFolder name.
description string
description stringFolder description/introduction.
icon string
icon stringRead-only, folder icon.
iconColor string
iconColor stringFolder icon color.
createdAt Integer
createdAt IntegerRead-only, folder creation time (timestamp).
parent string
parent stringParent folder ID.
children Folder[]
children Folder[]Read-only, an array of child folders.
Static Properties
IconColor Object
IconColor ObjectProvides predefined folder icon color constants for setting the folder's iconColor property.
Usage Examples:
🦄 Best Practice: It's recommended to use eagle.folder.IconColor constants instead of string values directly for better code hints and type safety.
Last updated