refactor: centralize resetAndReload functionality in baseModelApi

This commit is contained in:
Will Miao
2025-07-25 17:48:02 +08:00
parent 7f205cdcc8
commit a3d6e62035
13 changed files with 21 additions and 56 deletions

View File

@@ -1,7 +1,6 @@
import { state, getCurrentPageState } from '../state/index.js';
import { resetAndReload } from '../api/loraApi.js';
import { getCurrentPageState } from '../state/index.js';
import { getStorageItem, setStorageItem } from './storageHelpers.js';
import { NODE_TYPES, NODE_TYPE_ICONS, DEFAULT_NODE_COLOR } from './constants.js';
import { NODE_TYPE_ICONS, DEFAULT_NODE_COLOR } from './constants.js';
/**
* Utility function to copy text to clipboard with fallback for older browsers
@@ -168,25 +167,6 @@ function updateThemeToggleIcons(theme) {
themeToggle.classList.add(`theme-${theme}`);
}
export function toggleFolder(tag) {
const tagElement = (tag instanceof HTMLElement) ? tag : this;
const folder = tagElement.dataset.folder;
const wasActive = tagElement.classList.contains('active');
document.querySelectorAll('.folder-tags .tag').forEach(t => {
t.classList.remove('active');
});
if (!wasActive) {
tagElement.classList.add('active');
state.activeFolder = folder;
} else {
state.activeFolder = null;
}
resetAndReload();
}
function filterByFolder(folderPath) {
document.querySelectorAll('.lora-card').forEach(card => {
card.style.display = card.dataset.folder === folderPath ? '' : 'none';