mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-17 09:51:35 +00:00
refac
This commit is contained in:
parent
706dd223c0
commit
e69392fd2b
4 changed files with 51 additions and 3 deletions
|
|
@ -151,6 +151,7 @@ def session_query(
|
|||
select(
|
||||
Chat.id,
|
||||
func.substr(Chat.title, 1, 200).label('title'),
|
||||
User.id.label('user_id'),
|
||||
User.name.label('user_name'),
|
||||
Folder.name.label('folder_name'),
|
||||
json_text(db, Chat.meta, 'type').label('kind'),
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ export type SessionScope = {
|
|||
export type Session = {
|
||||
id: string;
|
||||
title: string;
|
||||
user_id: string | null;
|
||||
user_name: string | null;
|
||||
folder_name: string | null;
|
||||
kind: string | null;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
<script lang="ts">
|
||||
import { getContext, onMount, onDestroy, tick } from 'svelte';
|
||||
import dayjs from 'dayjs';
|
||||
import { WEBUI_API_BASE_URL } from '$lib/constants';
|
||||
import ProfilePreview from '$lib/components/channel/Messages/Message/ProfilePreview.svelte';
|
||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||
import ChevronLeft from '$lib/components/icons/ChevronLeft.svelte';
|
||||
import ChevronRight from '$lib/components/icons/ChevronRight.svelte';
|
||||
|
|
@ -208,8 +210,28 @@
|
|||
class="min-h-0 overflow-y-auto overscroll-contain scrollbar-hover"
|
||||
data-session-content
|
||||
>
|
||||
<div class="mb-3 flex flex-wrap gap-x-3 gap-y-1 text-[0.6875rem]">
|
||||
{#if session.user_name}<span>{session.user_name}</span>{/if}
|
||||
<div class="mb-3 flex flex-wrap items-center gap-x-3 gap-y-1 text-[0.6875rem]">
|
||||
{#if session.user_id}
|
||||
<ProfilePreview
|
||||
user={{ id: session.user_id, name: session.user_name }}
|
||||
side="bottom"
|
||||
align="start"
|
||||
sideOffset={6}
|
||||
className="gap-1.75"
|
||||
>
|
||||
<img
|
||||
src={`${WEBUI_API_BASE_URL}/users/${session.user_id}/profile/image`}
|
||||
alt=""
|
||||
class="size-4 rounded-full object-cover shrink-0"
|
||||
loading="lazy"
|
||||
on:error={(event) => {
|
||||
const image = event.currentTarget as HTMLImageElement;
|
||||
if (!image.src.endsWith('/user.png')) image.src = '/user.png';
|
||||
}}
|
||||
/>
|
||||
<span class="block max-w-28 truncate">{session.user_name || $i18n.t('User')}</span>
|
||||
</ProfilePreview>
|
||||
{:else}<span>{session.user_name || '-'}</span>{/if}
|
||||
{#if session.started_at}<span
|
||||
>{dayjs
|
||||
.unix(session.started_at)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
<script lang="ts">
|
||||
import { getContext, onMount, onDestroy, tick } from 'svelte';
|
||||
import dayjs from 'dayjs';
|
||||
import { WEBUI_API_BASE_URL } from '$lib/constants';
|
||||
import ProfilePreview from '$lib/components/channel/Messages/Message/ProfilePreview.svelte';
|
||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||
import Modal from '$lib/components/common/Modal.svelte';
|
||||
import Dropdown from '$lib/components/common/Dropdown.svelte';
|
||||
|
|
@ -322,7 +324,29 @@
|
|||
</button>
|
||||
</td>
|
||||
<td class="px-2.5 py-1.5"
|
||||
><span class="block max-w-28 truncate">{session.user_name || '-'}</span></td
|
||||
>{#if session.user_id}
|
||||
<ProfilePreview
|
||||
user={{ id: session.user_id, name: session.user_name }}
|
||||
side="right"
|
||||
align="center"
|
||||
sideOffset={6}
|
||||
className="gap-1.75"
|
||||
>
|
||||
<img
|
||||
src={`${WEBUI_API_BASE_URL}/users/${session.user_id}/profile/image`}
|
||||
alt=""
|
||||
class="size-4 rounded-full object-cover shrink-0"
|
||||
loading="lazy"
|
||||
on:error={(event) => {
|
||||
const image = event.currentTarget as HTMLImageElement;
|
||||
if (!image.src.endsWith('/user.png')) image.src = '/user.png';
|
||||
}}
|
||||
/>
|
||||
<span class="block max-w-28 truncate"
|
||||
>{session.user_name || $i18n.t('User')}</span
|
||||
>
|
||||
</ProfilePreview>
|
||||
{:else}<span>{session.user_name || '-'}</span>{/if}</td
|
||||
>
|
||||
<td
|
||||
class="px-2.5 py-1.5"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue