///
The frontend of `sd-webui-infinite-image-browsing` is a modern web application built primarily with Vue.js. It provides a rich, interactive user interface for browsing, searching, and managing image,
31 views
~31 views from guests
Guest views are estimated from total page views. These include anonymous visitors and users who weren't logged in when they viewed the page.
The frontend of sd-webui-infinite-image-browsing is a modern web application built primarily with Vue.js. It provides a rich, interactive user interface for browsing, searching, and managing image, video, and audio files, integrating seamlessly with Stable Diffusion WebUI (SD-WebUI) and supporting standalone operation.
The application utilizes several Pinia stores to manage different aspects of its state:
useGlobalStore: This is the central store managing global application settings and UI state.
conf) fetched from the /global_setting API.tabList) and current active tab/pane.defaultSortingMethod, darkModeControl, longPressOpenContextMenu, etc.).recent).getShortPath for displaying simplified file paths.useTagStore: Manages all tag-related data and logic.
tagMap).fetchImageTags).colorCache) and provides a getColor utility.useTiktokStore: Dedicated to the "TikTok-style browsing" feature.
mediaList) and the currentIndex being viewed.next, prev, goToIndex).useWorkspeaceSnapshot: Enables users to save and restore UI layouts.
snapshots).createSnapshot from the current UI state and addSnapshot to persist it.useBatchDownloadStore: Manages the selection and processing of files for batch download.
selectedFiles for download.addFiles method to add new files, ensuring uniqueness.useImgSliStore: Manages the state for the image comparison (ImgSli) feature.
left and right images being compared.fileDragging), as this also triggers the comparison panel.The frontend communicates with the Python FastAPI backend through a centralized axios instance (axiosInst). This client is configured with a base URL (dynamically set based on deployment mode) and includes interceptors for:
401 responses, prompting the user for a secret key (if configured on the server) and setting an IIB_S cookie for subsequent requests. It reloads the page after successful authentication.isAxiosError) and displays Ant Design Vue message.error notifications to the user, providing details from the backend's error response.Key API interactions include:
getGlobalSetting fetches initial application configuration.getTargetFolderFiles for listing directory contents, deleteFiles, moveFiles, copyFiles, mkdirs for file system management.getImageGenerationInfo, getImageGenerationInfoBatch to retrieve EXIF data.toImageThumbnailUrl, toStreamVideoUrl, toVideoCoverUrl, toStreamAudioUrl generate URLs for media assets, leveraging backend-generated caches.updateImageData, rebuildImageIndex, getImagesByTags, getImagesBySubstr, addCustomTag, toggleCustomTagToImg, renameFile, addExtraPath, aliasExtraPath for managing the SQLite database, tags, and search indices (referencing [Database Schema and Core API Endpoints]).buildIibOutputEmbeddings, startClusterIibOutputJob, getClusterIibOutputJobStatus, searchIibOutputByPrompt, getClusterTagGraph, aiChat for the experimental natural language features.AButton), input fields (AInput, AInputNumber), modals (AModal), dropdowns (ADropdown), tabs (ATabs), alerts (AAlert), spin indicators (ASpin), and various layout components (ARow, ACol, ASpace).FileItem.vue: The core component for displaying individual files (images, videos, directories) in the grid or list views. It handles rendering thumbnails, showing basic info, responding to clicks (for preview), drag-and-drop events, and right-click context menus. It also integrates ChangeIndicator for visual diffs.RecycleScroller.vue (from vue-virtual-scroller): Used in FileItem.vue to efficiently render large lists of files by only rendering visible items, significantly improving performance.MultiSelectKeep.vue: A utility component for managing multi-selection state, offering "Select All", "Reverse Select", "Clear All Selected", and "Keep Multi-selected" functionalities.ContextMenu.vue: Provides the dynamic right-click menu options for file items, integrating with tag management and "Send To" actions.ChangeIndicator.vue: Displays visual cues (small colored boxes) on image items to indicate changes in generation parameters (prompt, seed, steps, etc.) compared to adjacent images, aiding in visual comparison.BaseFileListInfo.vue: Displays summary information about the current file list (total items, selected items).HistoryRecord.vue: Used for displaying and interacting with search history records (fuzzy search, tag search).numInput.vue: A custom input component combining AInputNumber with an ASlider for numerical input.fullScreenContextMenu.vue: The floating panel that appears in full-screen preview mode, allowing access to image metadata, tags, and file operations.eventEmitter)The frontend uses a custom event emitter (typedEventEmitter from vue3-ts-util, aliased as We in some files, and exposed globally as globalEvents) for loosely coupled communication between various components and stores. This is particularly useful for triggering actions or notifying changes across different parts of the application without direct prop drilling or complex direct store dependencies.
Examples of global events:
loadNextDir: Triggered to load additional files in "Walk Mode."refresh: Notifies components to re-fetch and update their data, often after file system changes or database updates.removeFiles, addFiles: Broadcasts changes to the file list, used by UI components to update their display (e.g., in batch download or after move operations).searchIndexExpired: Signals that the backend image index is outdated and needs to be refreshed.closeTabPane: Used to programmatically close specific tabs.viewableAreaFilesChange: Notifies when the set of files visible in the scroller changes, allowing for optimization like batch-fetching tags or directory covers for only the visible items.selectAll: Triggered by keyboard shortcuts or UI actions to select all items.The application is designed to function as an extension within SD-WebUI, running as an iframe.
javascript/index.js file (generated from vue/index.tpl.js during the build process) is responsible for injecting the Vue.js application as an iframe into a designated div element (#infinite_image_browsing_container_wrapper) within the SD-WebUI Gradio interface.shouldMaximize, onUiTabChange) to detect when its tab is active in SD-WebUI and dynamically adjusts the iframe's size and position to maximize its footprint within the Gradio layout, providing a more immersive experience.gradioApp(): A utility function (gradioApp() in src/util/index.ts) allows the iframe to access the parent Gradio application's DOM, enabling interactions like switching tabs (switch2targetTab) or querying specific elements (e.g., for ControlNet panels).BroadcastChannel (imgTransferBus): This API is used for cross-origin communication between the iframe and the parent SD-WebUI window. It facilitates "Send To" functionalities:
send_to_control_net: Sends an image URL to a ControlNet panel in SD-WebUI's txt2img or img2img tab, simulating a paste event.send_to_outpaint: Sends an image (converted to Data URL) and prompt information to the openOutpaint extension.click_hidden_button: Simulates clicks on hidden Gradio buttons (e.g., iib_hidden_img_update_trigger, iib_hidden_tab_txt2img) in scripts/iib_setup.py to leverage SD-WebUI's built-in parameter pasting mechanisms. This is crucial for transferring generation info back to SD-WebUI.This architecture ensures a powerful and responsive user experience, whether operating as a standalone desktop application or deeply integrated within the SD-WebUI ecosystem.