mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-01 13:59:54 +00:00
Model Library sidebar: allow searching metadata (#1148)
* Model Library sidebar: allow searching metadata title, description, etc * don't use vue stuff inside of vue because vue doesn't support vue very cool * remove old import * and that one
This commit is contained in:
committed by
GitHub
parent
99c948f578
commit
ff1ca268a4
@@ -83,7 +83,7 @@ const root: ComputedRef<TreeNode> = computed(() => {
|
||||
if (searchQuery.value) {
|
||||
const search = searchQuery.value.toLocaleLowerCase()
|
||||
modelList = modelList.filter((model: ComfyModelDef) => {
|
||||
return model.file_name.toLocaleLowerCase().includes(search)
|
||||
return model.searchable.includes(search)
|
||||
})
|
||||
}
|
||||
const tree: TreeNode = buildTree(modelList, (model: ComfyModelDef) => {
|
||||
|
||||
@@ -48,6 +48,8 @@ export class ComfyModelDef {
|
||||
is_load_requested: boolean = false
|
||||
/** If true, this is a fake model object used as a placeholder for something (eg a loading icon) */
|
||||
is_fake_object: boolean = false
|
||||
/** A string full of auto-computed lowercase-only searchable text for this model */
|
||||
searchable: string = ''
|
||||
|
||||
constructor(name: string, directory: string) {
|
||||
this.file_name = name
|
||||
@@ -60,6 +62,20 @@ export class ComfyModelDef {
|
||||
}
|
||||
this.title = this.simplified_file_name
|
||||
this.directory = directory
|
||||
this.updateSearchable()
|
||||
}
|
||||
|
||||
updateSearchable() {
|
||||
this.searchable = [
|
||||
this.file_name,
|
||||
this.title,
|
||||
this.author,
|
||||
this.description,
|
||||
this.trigger_phrase,
|
||||
this.tags.join(', ')
|
||||
]
|
||||
.join('\n')
|
||||
.toLowerCase()
|
||||
}
|
||||
|
||||
/** Loads the model metadata from the server, filling in this object if data is available */
|
||||
@@ -110,6 +126,7 @@ export class ComfyModelDef {
|
||||
_findInMetadata(metadata, 'modelspec.tags', 'tags') || ''
|
||||
this.tags = tagsCommaSeparated.split(',').map((tag) => tag.trim())
|
||||
this.has_loaded_metadata = true
|
||||
this.updateSearchable()
|
||||
} catch (error) {
|
||||
console.error('Error loading model metadata', this.file_name, this, error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user