feat: copy model link

This commit is contained in:
Timothy Jaeryang Baek
2025-05-26 22:29:03 +04:00
parent 2d5b82df8c
commit 9a5febc2d1
4 changed files with 56 additions and 1 deletions
+15 -1
View File
@@ -33,7 +33,7 @@
import ChevronRight from '../icons/ChevronRight.svelte';
import Switch from '../common/Switch.svelte';
import Spinner from '../common/Spinner.svelte';
import { capitalizeFirstLetter } from '$lib/utils';
import { capitalizeFirstLetter, copyToClipboard } from '$lib/utils';
import XMark from '../icons/XMark.svelte';
import EyeSlash from '../icons/EyeSlash.svelte';
import Eye from '../icons/Eye.svelte';
@@ -141,6 +141,17 @@
models = await getWorkspaceModels(localStorage.token);
};
const copyLinkHandler = async (model) => {
const baseUrl = window.location.origin;
const res = await copyToClipboard(`${baseUrl}/?model=${encodeURIComponent(model.id)}`);
if (res) {
toast.success($i18n.t('Copied link to clipboard'));
} else {
toast.error($i18n.t('Failed to copy link'));
}
};
const downloadModels = async (models) => {
let blob = new Blob([JSON.stringify(models)], {
type: 'application/json'
@@ -383,6 +394,9 @@
hideHandler={() => {
hideModelHandler(model);
}}
copyLinkHandler={() => {
copyLinkHandler(model);
}}
deleteHandler={() => {
selectedModel = model;
showModelDeleteConfirm = true;