refac
This commit is contained in:
1 parent
3e56261c5e
commit
4331029926
1 file changed
+44
-18
@@ -361,6 +361,18 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const ITEM_HEIGHT = 42;
|
||||||
|
const OVERSCAN = 10;
|
||||||
|
|
||||||
|
let listScrollTop = 0;
|
||||||
|
let listContainer;
|
||||||
|
|
||||||
|
$: visibleStart = Math.max(0, Math.floor(listScrollTop / ITEM_HEIGHT) - OVERSCAN);
|
||||||
|
$: visibleEnd = Math.min(
|
||||||
|
filteredItems.length,
|
||||||
|
Math.ceil((listScrollTop + 256) / ITEM_HEIGHT) + OVERSCAN
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<DropdownMenu.Root
|
<DropdownMenu.Root
|
||||||
@@ -544,29 +556,43 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="px-2.5 max-h-64 overflow-y-auto group relative">
|
<div class="px-2.5 group relative">
|
||||||
{#each filteredItems as item, index}
|
{#if filteredItems.length === 0}
|
||||||
<ModelItem
|
|
||||||
{selectedModelIdx}
|
|
||||||
{item}
|
|
||||||
{index}
|
|
||||||
{value}
|
|
||||||
{pinModelHandler}
|
|
||||||
{unloadModelHandler}
|
|
||||||
onClick={() => {
|
|
||||||
value = item.value;
|
|
||||||
selectedModelIdx = index;
|
|
||||||
|
|
||||||
show = false;
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
{:else}
|
|
||||||
<div class="">
|
<div class="">
|
||||||
<div class="block px-3 py-2 text-sm text-gray-700 dark:text-gray-100">
|
<div class="block px-3 py-2 text-sm text-gray-700 dark:text-gray-100">
|
||||||
{$i18n.t('No results found')}
|
{$i18n.t('No results found')}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{:else}
|
||||||
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||||
|
<div
|
||||||
|
class="max-h-64 overflow-y-auto"
|
||||||
|
bind:this={listContainer}
|
||||||
|
on:scroll={() => {
|
||||||
|
listScrollTop = listContainer.scrollTop;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div style="height: {visibleStart * ITEM_HEIGHT}px;" />
|
||||||
|
{#each filteredItems.slice(visibleStart, visibleEnd) as item, i (item.value)}
|
||||||
|
{@const index = visibleStart + i}
|
||||||
|
<ModelItem
|
||||||
|
{selectedModelIdx}
|
||||||
|
{item}
|
||||||
|
{index}
|
||||||
|
{value}
|
||||||
|
{pinModelHandler}
|
||||||
|
{unloadModelHandler}
|
||||||
|
onClick={() => {
|
||||||
|
value = item.value;
|
||||||
|
selectedModelIdx = index;
|
||||||
|
|
||||||
|
show = false;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{/each}
|
||||||
|
<div style="height: {(filteredItems.length - visibleEnd) * ITEM_HEIGHT}px;" />
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if !(searchValue.trim() in $MODEL_DOWNLOAD_POOL) && searchValue && ollamaVersion && $user?.role === 'admin'}
|
{#if !(searchValue.trim() in $MODEL_DOWNLOAD_POOL) && searchValue && ollamaVersion && $user?.role === 'admin'}
|
||||||
<Tooltip
|
<Tooltip
|
||||||
|
|||||||
Reference in new issue
Block a user