mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-09-21 11:11:26 -03:00
69a62d739c
- The Other nav entry is hidden while the feature is off (nav-item--hidden, toggled client-side after enabling) and now uses the fa-shapes icon. - Shared utils/otherModels.js helpers (enable through the settings API, open the settings Library section) are reused by the disabled page, the announcement banner and the download modal. - BannerService registers a one-time dismissible "other-models-announcement" banner while the feature is off; SettingsManager drops the banner and updates the nav when the master switch flips. - A disabled download routing answer now surfaces a showActionToast with an "Enable Other Models" action. - Settings UI: master toggle + five sub_type checkboxes whose default-root selects are disabled when unchecked; i18n keys added to en.json and synced (other locales keep TODO placeholders).
53 lines
1.8 KiB
JavaScript
53 lines
1.8 KiB
JavaScript
/**
|
|
* Shared helpers for the opt-in Other Models feature.
|
|
*
|
|
* Used by the disabled page, the announcement banner and the download modal so
|
|
* that enabling the feature always goes through the same settings API call and
|
|
* lands on the same settings section.
|
|
*/
|
|
|
|
/**
|
|
* Turn on Other Models management and reload so the server-rendered nav and
|
|
* the scanner state pick up the change.
|
|
*/
|
|
export async function enableOtherModels() {
|
|
const response = await fetch('/api/lm/settings', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ enable_other_models: true }),
|
|
});
|
|
const data = await response.json().catch(() => ({}));
|
|
if (!response.ok || data.success === false) {
|
|
throw new Error(data.error || `HTTP ${response.status}`);
|
|
}
|
|
window.location.reload();
|
|
}
|
|
|
|
/**
|
|
* Open the settings modal on the Library section and scroll the Other Models
|
|
* toggle into view. Mirrors DoctorManager's open-settings-syntax-format flow.
|
|
*/
|
|
export function openOtherModelsSettings() {
|
|
const modalManager = window.modalManager;
|
|
if (modalManager && typeof modalManager.showModal === 'function') {
|
|
modalManager.showModal('settingsModal');
|
|
}
|
|
|
|
window.setTimeout(() => {
|
|
document.querySelectorAll('.settings-section').forEach((section) => {
|
|
section.classList.remove('active');
|
|
});
|
|
document.getElementById('section-library')?.classList.add('active');
|
|
|
|
document.querySelectorAll('.settings-nav-item').forEach((item) => {
|
|
item.classList.remove('active');
|
|
});
|
|
document.querySelector('.settings-nav-item[data-section="library"]')?.classList.add('active');
|
|
|
|
document.getElementById('enableOtherModels')?.scrollIntoView({
|
|
behavior: 'smooth',
|
|
block: 'center',
|
|
});
|
|
}, 100);
|
|
}
|