mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-09-20 18:51:26 -03:00
feat(sidebar): show empty folders and create folders from the sidebar (#999)
Empty folders (tracked in the scan-recorded all_folders list, same source
the move/download destination picker uses) can now be surfaced in the
folder sidebar via a view-options toggle, dimmed when their subtree holds
no models. Folders can be created directly from the sidebar through a new
POST /api/lm/{prefix}/create-folder endpoint with library-root
containment checks; the scanner records the new directory incrementally
so the tree reflects it without a rescan.
The sidebar header moves its view toggles (tree/list, recursive, empty
folders) into a "..." menu to fit the new create-folder button.
This commit is contained in:
@@ -1295,9 +1295,13 @@ export class BaseModelApiClient {
|
||||
}
|
||||
}
|
||||
|
||||
async fetchModelFolders() {
|
||||
async fetchModelFolders(options = {}) {
|
||||
try {
|
||||
const response = await fetch(this.apiConfig.endpoints.folders);
|
||||
const { includeEmpty = false } = options || {};
|
||||
const url = includeEmpty
|
||||
? `${this.apiConfig.endpoints.folders}?include_empty=1`
|
||||
: this.apiConfig.endpoints.folders;
|
||||
const response = await fetch(url);
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch ${this.apiConfig.config.displayName} folders`);
|
||||
}
|
||||
@@ -1308,6 +1312,24 @@ export class BaseModelApiClient {
|
||||
}
|
||||
}
|
||||
|
||||
async createFolder(folderPath) {
|
||||
const response = await fetch(this.apiConfig.endpoints.createFolder, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ folder_path: folderPath })
|
||||
});
|
||||
|
||||
const result = await response.json().catch(() => ({}));
|
||||
|
||||
if (!response.ok || result.success === false) {
|
||||
throw new Error(result.error || `Failed to create folder`);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async fetchUnifiedFolderTree(options = {}) {
|
||||
try {
|
||||
const { includeEmpty = false } = options;
|
||||
|
||||
Reference in New Issue
Block a user