mirror of
https://github.com/open-webui/open-webui
synced 2025-04-21 06:50:44 +00:00
refac: show chat menu in temp chat
This commit is contained in:
parent
fe872aa3fc
commit
854024cdf8
@ -1935,7 +1935,17 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<Navbar
|
<Navbar
|
||||||
{chat}
|
chat={{
|
||||||
|
id: $chatId,
|
||||||
|
chat: {
|
||||||
|
title: $chatTitle,
|
||||||
|
models: selectedModels,
|
||||||
|
system: $settings.system ?? undefined,
|
||||||
|
params: params,
|
||||||
|
history: history,
|
||||||
|
timestamp: Date.now()
|
||||||
|
}
|
||||||
|
}}
|
||||||
title={$chatTitle}
|
title={$chatTitle}
|
||||||
bind:selectedModels
|
bind:selectedModels
|
||||||
shareEnabled={!!history.currentId}
|
shareEnabled={!!history.currentId}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
showArchivedChats,
|
showArchivedChats,
|
||||||
showControls,
|
showControls,
|
||||||
showSidebar,
|
showSidebar,
|
||||||
|
temporaryChatEnabled,
|
||||||
user
|
user
|
||||||
} from '$lib/stores';
|
} from '$lib/stores';
|
||||||
|
|
||||||
@ -23,6 +24,7 @@
|
|||||||
import MenuLines from '../icons/MenuLines.svelte';
|
import MenuLines from '../icons/MenuLines.svelte';
|
||||||
import AdjustmentsHorizontal from '../icons/AdjustmentsHorizontal.svelte';
|
import AdjustmentsHorizontal from '../icons/AdjustmentsHorizontal.svelte';
|
||||||
import Map from '../icons/Map.svelte';
|
import Map from '../icons/Map.svelte';
|
||||||
|
import { stringify } from 'postcss';
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
@ -74,8 +76,7 @@
|
|||||||
|
|
||||||
<div class="self-start flex flex-none items-center text-gray-600 dark:text-gray-400">
|
<div class="self-start flex flex-none items-center text-gray-600 dark:text-gray-400">
|
||||||
<!-- <div class="md:hidden flex self-center w-[1px] h-5 mx-2 bg-gray-300 dark:bg-stone-700" /> -->
|
<!-- <div class="md:hidden flex self-center w-[1px] h-5 mx-2 bg-gray-300 dark:bg-stone-700" /> -->
|
||||||
|
{#if shareEnabled && chat && (chat.id || $temporaryChatEnabled)}
|
||||||
{#if shareEnabled && chat && chat.id}
|
|
||||||
<Menu
|
<Menu
|
||||||
{chat}
|
{chat}
|
||||||
{shareEnabled}
|
{shareEnabled}
|
||||||
|
@ -9,7 +9,13 @@
|
|||||||
import { downloadChatAsPDF } from '$lib/apis/utils';
|
import { downloadChatAsPDF } from '$lib/apis/utils';
|
||||||
import { copyToClipboard, createMessagesList } from '$lib/utils';
|
import { copyToClipboard, createMessagesList } from '$lib/utils';
|
||||||
|
|
||||||
import { showOverview, showControls, showArtifacts, mobile } from '$lib/stores';
|
import {
|
||||||
|
showOverview,
|
||||||
|
showControls,
|
||||||
|
showArtifacts,
|
||||||
|
mobile,
|
||||||
|
temporaryChatEnabled
|
||||||
|
} from '$lib/stores';
|
||||||
import { flyAndScale } from '$lib/utils/transitions';
|
import { flyAndScale } from '$lib/utils/transitions';
|
||||||
|
|
||||||
import Dropdown from '$lib/components/common/Dropdown.svelte';
|
import Dropdown from '$lib/components/common/Dropdown.svelte';
|
||||||
@ -31,9 +37,8 @@
|
|||||||
export let onClose: Function = () => {};
|
export let onClose: Function = () => {};
|
||||||
|
|
||||||
const getChatAsText = async () => {
|
const getChatAsText = async () => {
|
||||||
const _chat = chat.chat;
|
const history = chat.chat.history;
|
||||||
|
const messages = createMessagesList(history, history.currentId);
|
||||||
const messages = createMessagesList(_chat.history, _chat.history.currentId);
|
|
||||||
const chatText = messages.reduce((a, message, i, arr) => {
|
const chatText = messages.reduce((a, message, i, arr) => {
|
||||||
return `${a}### ${message.role.toUpperCase()}\n${message.content}\n\n`;
|
return `${a}### ${message.role.toUpperCase()}\n${message.content}\n\n`;
|
||||||
}, '');
|
}, '');
|
||||||
@ -52,12 +57,9 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const downloadPdf = async () => {
|
const downloadPdf = async () => {
|
||||||
const _chat = chat.chat;
|
const history = chat.chat.history;
|
||||||
const messages = createMessagesList(_chat.history, _chat.history.currentId);
|
const messages = createMessagesList(history, history.currentId);
|
||||||
|
const blob = await downloadChatAsPDF(chat.chat.title, messages);
|
||||||
console.log('download', chat);
|
|
||||||
|
|
||||||
const blob = await downloadChatAsPDF(_chat.title, messages);
|
|
||||||
|
|
||||||
// Create a URL for the blob
|
// Create a URL for the blob
|
||||||
const url = window.URL.createObjectURL(blob);
|
const url = window.URL.createObjectURL(blob);
|
||||||
@ -65,7 +67,7 @@
|
|||||||
// Create a link element to trigger the download
|
// Create a link element to trigger the download
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
a.href = url;
|
a.href = url;
|
||||||
a.download = `chat-${_chat.title}.pdf`;
|
a.download = `chat-${chat.chat.title}.pdf`;
|
||||||
|
|
||||||
// Append the link to the body and click it programmatically
|
// Append the link to the body and click it programmatically
|
||||||
document.body.appendChild(a);
|
document.body.appendChild(a);
|
||||||
@ -189,27 +191,29 @@
|
|||||||
<div class="flex items-center">{$i18n.t('Copy')}</div>
|
<div class="flex items-center">{$i18n.t('Copy')}</div>
|
||||||
</DropdownMenu.Item>
|
</DropdownMenu.Item>
|
||||||
|
|
||||||
<DropdownMenu.Item
|
{#if !$temporaryChatEnabled}
|
||||||
class="flex gap-2 items-center px-3 py-2 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md"
|
<DropdownMenu.Item
|
||||||
id="chat-share-button"
|
class="flex gap-2 items-center px-3 py-2 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md"
|
||||||
on:click={() => {
|
id="chat-share-button"
|
||||||
shareHandler();
|
on:click={() => {
|
||||||
}}
|
shareHandler();
|
||||||
>
|
}}
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
fill="currentColor"
|
|
||||||
class="size-4"
|
|
||||||
>
|
>
|
||||||
<path
|
<svg
|
||||||
fill-rule="evenodd"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
d="M15.75 4.5a3 3 0 1 1 .825 2.066l-8.421 4.679a3.002 3.002 0 0 1 0 1.51l8.421 4.679a3 3 0 1 1-.729 1.31l-8.421-4.678a3 3 0 1 1 0-4.132l8.421-4.679a3 3 0 0 1-.096-.755Z"
|
viewBox="0 0 24 24"
|
||||||
clip-rule="evenodd"
|
fill="currentColor"
|
||||||
/>
|
class="size-4"
|
||||||
</svg>
|
>
|
||||||
<div class="flex items-center">{$i18n.t('Share')}</div>
|
<path
|
||||||
</DropdownMenu.Item>
|
fill-rule="evenodd"
|
||||||
|
d="M15.75 4.5a3 3 0 1 1 .825 2.066l-8.421 4.679a3.002 3.002 0 0 1 0 1.51l8.421 4.679a3 3 0 1 1-.729 1.31l-8.421-4.678a3 3 0 1 1 0-4.132l8.421-4.679a3 3 0 0 1-.096-.755Z"
|
||||||
|
clip-rule="evenodd"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
<div class="flex items-center">{$i18n.t('Share')}</div>
|
||||||
|
</DropdownMenu.Item>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<DropdownMenu.Sub>
|
<DropdownMenu.Sub>
|
||||||
<DropdownMenu.SubTrigger
|
<DropdownMenu.SubTrigger
|
||||||
@ -265,11 +269,13 @@
|
|||||||
</DropdownMenu.SubContent>
|
</DropdownMenu.SubContent>
|
||||||
</DropdownMenu.Sub>
|
</DropdownMenu.Sub>
|
||||||
|
|
||||||
<hr class="border-gray-100 dark:border-gray-800 mt-2.5 mb-1.5" />
|
{#if !$temporaryChatEnabled}
|
||||||
|
<hr class="border-gray-100 dark:border-gray-800 mt-2.5 mb-1.5" />
|
||||||
|
|
||||||
<div class="flex p-1">
|
<div class="flex p-1">
|
||||||
<Tags chatId={chat.id} />
|
<Tags chatId={chat.id} />
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
</DropdownMenu.Content>
|
</DropdownMenu.Content>
|
||||||
</div>
|
</div>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
|
Loading…
Reference in New Issue
Block a user