feat: add browser extension integration hooks

- Add lmExtensionHandled check to prevent duplicate downloads
- Add lm:refreshVersions event listener for extension-triggered refresh
- Expose downloadManager to window for extension access
This commit is contained in:
Will Miao
2026-02-22 12:00:32 +08:00
parent 807f4e03ee
commit 0b48654ae6
2 changed files with 15 additions and 0 deletions

View File

@@ -1142,6 +1142,11 @@ export function initVersionsTab({
const actionButton = event.target.closest('[data-version-action]');
if (actionButton) {
// Check if browser extension has already handled this action
if (actionButton.dataset.lmExtensionHandled === 'true') {
return;
}
const row = actionButton.closest('.model-version-row');
if (!row) {
return;
@@ -1190,6 +1195,11 @@ export function initVersionsTab({
window.open(targetUrl, '_blank', 'noopener,noreferrer');
});
// Listen for extension-triggered refresh requests
container.addEventListener('lm:refreshVersions', async () => {
await refresh();
});
return {
load: options => loadVersions(options),
refresh,

View File

@@ -744,3 +744,8 @@ export class DownloadManager {
// Create global instance
export const downloadManager = new DownloadManager();
// Expose to window for browser extension integration
if (typeof window !== 'undefined') {
window.downloadManager = downloadManager;
}