mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 23:25:43 -03:00
Update LoraModal to enhance preset value configuration and file path retrieval
- Adjusted preset value min, max, and step properties for improved functionality based on selected options. - Refactored file path retrieval to ensure consistency by targeting the specific modal context, enhancing code clarity and maintainability.
This commit is contained in:
@@ -430,9 +430,9 @@ function setupEditableFields() {
|
|||||||
const selected = this.value;
|
const selected = this.value;
|
||||||
if (selected) {
|
if (selected) {
|
||||||
presetValue.style.display = 'inline-block';
|
presetValue.style.display = 'inline-block';
|
||||||
presetValue.min = selected.includes('strength') ? 0 : 1;
|
presetValue.min = selected.includes('strength') ? -10 : 0;
|
||||||
presetValue.max = selected.includes('strength') ? 1 : 12;
|
presetValue.max = selected.includes('strength') ? 10 : 10;
|
||||||
presetValue.step = selected.includes('strength') ? 0.5 : 1;
|
presetValue.step = 0.5;
|
||||||
if (selected === 'clip_skip') {
|
if (selected === 'clip_skip') {
|
||||||
presetValue.type = 'number';
|
presetValue.type = 'number';
|
||||||
presetValue.step = 1;
|
presetValue.step = 1;
|
||||||
@@ -450,10 +450,10 @@ function setupEditableFields() {
|
|||||||
|
|
||||||
if (!key || !value) return;
|
if (!key || !value) return;
|
||||||
|
|
||||||
const filePath = document.querySelector('.modal-content')
|
const filePath = document.querySelector('#loraModal .modal-content')
|
||||||
.querySelector('.file-path').textContent +
|
.querySelector('.file-path').textContent +
|
||||||
document.querySelector('.modal-content')
|
document.querySelector('#loraModal .modal-content')
|
||||||
.querySelector('#file-name').textContent + '.safetensors';
|
.querySelector('#file-name').textContent + '.safetensors';
|
||||||
|
|
||||||
const loraCard = document.querySelector(`.lora-card[data-filepath="${filePath}"]`);
|
const loraCard = document.querySelector(`.lora-card[data-filepath="${filePath}"]`);
|
||||||
const currentPresets = parsePresets(loraCard.dataset.usage_tips);
|
const currentPresets = parsePresets(loraCard.dataset.usage_tips);
|
||||||
@@ -483,9 +483,9 @@ function setupEditableFields() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const filePath = document.querySelector('.modal-content')
|
const filePath = document.querySelector('#loraModal .modal-content')
|
||||||
.querySelector('.file-path').textContent +
|
.querySelector('.file-path').textContent +
|
||||||
document.querySelector('.modal-content')
|
document.querySelector('#loraModal .modal-content')
|
||||||
.querySelector('#file-name').textContent + '.safetensors';
|
.querySelector('#file-name').textContent + '.safetensors';
|
||||||
await saveNotes(filePath);
|
await saveNotes(filePath);
|
||||||
}
|
}
|
||||||
@@ -807,9 +807,9 @@ function formatPresetKey(key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.removePreset = async function(key) {
|
window.removePreset = async function(key) {
|
||||||
const filePath = document.querySelector('.modal-content')
|
const filePath = document.querySelector('#loraModal .modal-content')
|
||||||
.querySelector('.file-path').textContent +
|
.querySelector('.file-path').textContent +
|
||||||
document.querySelector('.modal-content')
|
document.querySelector('#loraModal .modal-content')
|
||||||
.querySelector('#file-name').textContent + '.safetensors';
|
.querySelector('#file-name').textContent + '.safetensors';
|
||||||
const loraCard = document.querySelector(`.lora-card[data-filepath="${filePath}"]`);
|
const loraCard = document.querySelector(`.lora-card[data-filepath="${filePath}"]`);
|
||||||
const currentPresets = parsePresets(loraCard.dataset.usage_tips);
|
const currentPresets = parsePresets(loraCard.dataset.usage_tips);
|
||||||
@@ -1184,9 +1184,9 @@ function setupModelNameEditing() {
|
|||||||
|
|
||||||
if (this.textContent.trim() === '') {
|
if (this.textContent.trim() === '') {
|
||||||
// Restore original model name if empty
|
// Restore original model name if empty
|
||||||
const filePath = document.querySelector('.modal-content')
|
const filePath = document.querySelector('#loraModal .modal-content')
|
||||||
.querySelector('.file-path').textContent +
|
.querySelector('.file-path').textContent +
|
||||||
document.querySelector('.modal-content')
|
document.querySelector('#loraModal .modal-content')
|
||||||
.querySelector('#file-name').textContent + '.safetensors';
|
.querySelector('#file-name').textContent + '.safetensors';
|
||||||
const loraCard = document.querySelector(`.lora-card[data-filepath="${filePath}"]`);
|
const loraCard = document.querySelector(`.lora-card[data-filepath="${filePath}"]`);
|
||||||
if (loraCard) {
|
if (loraCard) {
|
||||||
@@ -1199,9 +1199,9 @@ function setupModelNameEditing() {
|
|||||||
modelNameContent.addEventListener('keydown', function(e) {
|
modelNameContent.addEventListener('keydown', function(e) {
|
||||||
if (e.key === 'Enter') {
|
if (e.key === 'Enter') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const filePath = document.querySelector('.modal-content')
|
const filePath = document.querySelector('#loraModal .modal-content')
|
||||||
.querySelector('.file-path').textContent +
|
.querySelector('.file-path').textContent +
|
||||||
document.querySelector('.modal-content')
|
document.querySelector('#loraModal .modal-content')
|
||||||
.querySelector('#file-name').textContent + '.safetensors';
|
.querySelector('#file-name').textContent + '.safetensors';
|
||||||
saveModelName(filePath);
|
saveModelName(filePath);
|
||||||
this.blur();
|
this.blur();
|
||||||
|
|||||||
Reference in New Issue
Block a user