mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-16 11:57:51 +01:00
refac
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { decodeString } from '$lib/utils';
|
||||||
|
|
||||||
export let id;
|
export let id;
|
||||||
|
|
||||||
export let title: string = 'N/A';
|
export let title: string = 'N/A';
|
||||||
@@ -15,6 +17,14 @@
|
|||||||
return domain;
|
return domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getDisplayTitle = (title: string) => {
|
||||||
|
if (!title) return 'N/A';
|
||||||
|
if (title.length > 30) {
|
||||||
|
return title.slice(0, 15) + '...' + title.slice(-10);
|
||||||
|
}
|
||||||
|
return title;
|
||||||
|
};
|
||||||
|
|
||||||
// Helper function to check if text is a URL and return the domain
|
// Helper function to check if text is a URL and return the domain
|
||||||
function formattedTitle(title: string): string {
|
function formattedTitle(title: string): string {
|
||||||
if (title.startsWith('http')) {
|
if (title.startsWith('http')) {
|
||||||
@@ -23,14 +33,6 @@
|
|||||||
|
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
const getDisplayTitle = (title: string) => {
|
|
||||||
if (!title) return 'N/A';
|
|
||||||
if (title.length > 30) {
|
|
||||||
return title.slice(0, 15) + '...' + title.slice(-10);
|
|
||||||
}
|
|
||||||
return title;
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if title !== 'N/A'}
|
{#if title !== 'N/A'}
|
||||||
@@ -41,7 +43,7 @@
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span class="line-clamp-1">
|
<span class="line-clamp-1">
|
||||||
{getDisplayTitle(formattedTitle(decodeURIComponent(title)))}
|
{getDisplayTitle(formattedTitle(decodeString(title)))}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { LinkPreview } from 'bits-ui';
|
import { LinkPreview } from 'bits-ui';
|
||||||
|
import { decodeString } from '$lib/utils';
|
||||||
import Source from './Source.svelte';
|
import Source from './Source.svelte';
|
||||||
|
|
||||||
export let id;
|
export let id;
|
||||||
@@ -50,7 +51,7 @@
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span class="line-clamp-1">
|
<span class="line-clamp-1">
|
||||||
{getDisplayTitle(formattedTitle(decodeURIComponent(sourceIds[token.ids[0] - 1])))}
|
{getDisplayTitle(formattedTitle(decodeString(sourceIds[token.ids[0] - 1])))}
|
||||||
<span class="dark:text-white/50 text-black/50">+{(token?.ids ?? []).length - 1}</span>
|
<span class="dark:text-white/50 text-black/50">+{(token?.ids ?? []).length - 1}</span>
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user