forked from open-webui/open-webui
Merge branch 'open-webui:dev' into dev
This commit is contained in:
commit
7a5a3c45e0
10 changed files with 43 additions and 59 deletions
|
@ -12,6 +12,7 @@
|
||||||
import Placeholder from './Messages/Placeholder.svelte';
|
import Placeholder from './Messages/Placeholder.svelte';
|
||||||
import Spinner from '../common/Spinner.svelte';
|
import Spinner from '../common/Spinner.svelte';
|
||||||
import { imageGenerations } from '$lib/apis/images';
|
import { imageGenerations } from '$lib/apis/images';
|
||||||
|
import { copyToClipboard } from '$lib/utils';
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
|
@ -42,40 +43,11 @@
|
||||||
element.scrollTop = element.scrollHeight;
|
element.scrollTop = element.scrollHeight;
|
||||||
};
|
};
|
||||||
|
|
||||||
const copyToClipboard = (text) => {
|
const copyToClipboardWithToast = async (text) => {
|
||||||
if (!navigator.clipboard) {
|
const res = await copyToClipboard(text);
|
||||||
var textArea = document.createElement('textarea');
|
if (res) {
|
||||||
textArea.value = text;
|
toast.success($i18n.t('Copying to clipboard was successful!'));
|
||||||
|
|
||||||
// Avoid scrolling to bottom
|
|
||||||
textArea.style.top = '0';
|
|
||||||
textArea.style.left = '0';
|
|
||||||
textArea.style.position = 'fixed';
|
|
||||||
|
|
||||||
document.body.appendChild(textArea);
|
|
||||||
textArea.focus();
|
|
||||||
textArea.select();
|
|
||||||
|
|
||||||
try {
|
|
||||||
var successful = document.execCommand('copy');
|
|
||||||
var msg = successful ? 'successful' : 'unsuccessful';
|
|
||||||
console.log('Fallback: Copying text command was ' + msg);
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Fallback: Oops, unable to copy', err);
|
|
||||||
}
|
|
||||||
|
|
||||||
document.body.removeChild(textArea);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
navigator.clipboard.writeText(text).then(
|
|
||||||
function () {
|
|
||||||
console.log('Async: Copying to clipboard was successful!');
|
|
||||||
toast.success($i18n.t('Copying to clipboard was successful!'));
|
|
||||||
},
|
|
||||||
function (err) {
|
|
||||||
console.error('Async: Could not copy text: ', err);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const confirmEditMessage = async (messageId, content) => {
|
const confirmEditMessage = async (messageId, content) => {
|
||||||
|
@ -330,7 +302,7 @@
|
||||||
{confirmEditMessage}
|
{confirmEditMessage}
|
||||||
{showPreviousMessage}
|
{showPreviousMessage}
|
||||||
{showNextMessage}
|
{showNextMessage}
|
||||||
{copyToClipboard}
|
copyToClipboard={copyToClipboardWithToast}
|
||||||
/>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<ResponseMessage
|
<ResponseMessage
|
||||||
|
@ -344,7 +316,7 @@
|
||||||
{showPreviousMessage}
|
{showPreviousMessage}
|
||||||
{showNextMessage}
|
{showNextMessage}
|
||||||
{rateMessage}
|
{rateMessage}
|
||||||
{copyToClipboard}
|
copyToClipboard={copyToClipboardWithToast}
|
||||||
{continueGeneration}
|
{continueGeneration}
|
||||||
{regenerateResponse}
|
{regenerateResponse}
|
||||||
on:save={async (e) => {
|
on:save={async (e) => {
|
||||||
|
|
|
@ -10,17 +10,18 @@
|
||||||
import Link from '../icons/Link.svelte';
|
import Link from '../icons/Link.svelte';
|
||||||
|
|
||||||
let chat = null;
|
let chat = null;
|
||||||
|
let shareUrl = null;
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
const shareLocalChat = async () => {
|
const shareLocalChat = async () => {
|
||||||
const _chat = chat;
|
const _chat = chat;
|
||||||
|
|
||||||
const sharedChat = await shareChatById(localStorage.token, $chatId);
|
const sharedChat = await shareChatById(localStorage.token, $chatId);
|
||||||
const chatShareUrl = `${window.location.origin}/s/${sharedChat.id}`;
|
shareUrl = `${window.location.origin}/s/${sharedChat.id}`;
|
||||||
|
console.log(shareUrl);
|
||||||
toast.success($i18n.t('Copied shared chat URL to clipboard!'));
|
|
||||||
copyToClipboard(chatShareUrl);
|
|
||||||
chat = await getChatById(localStorage.token, $chatId);
|
chat = await getChatById(localStorage.token, $chatId);
|
||||||
|
|
||||||
|
return shareUrl;
|
||||||
};
|
};
|
||||||
|
|
||||||
const shareChat = async () => {
|
const shareChat = async () => {
|
||||||
|
@ -131,8 +132,12 @@
|
||||||
<button
|
<button
|
||||||
class=" self-center flex items-center gap-1 px-3.5 py-2 rounded-xl text-sm font-medium bg-emerald-600 hover:bg-emerald-500 text-white"
|
class=" self-center flex items-center gap-1 px-3.5 py-2 rounded-xl text-sm font-medium bg-emerald-600 hover:bg-emerald-500 text-white"
|
||||||
type="button"
|
type="button"
|
||||||
on:click={() => {
|
on:pointerdown={() => {
|
||||||
shareLocalChat();
|
shareLocalChat();
|
||||||
|
}}
|
||||||
|
on:click={async () => {
|
||||||
|
copyToClipboard(shareUrl);
|
||||||
|
toast.success($i18n.t('Copied shared chat URL to clipboard!'));
|
||||||
show = false;
|
show = false;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"'s', 'm', 'h', 'd', 'w' or '-1' for no expiration.": "'с', 'м', 'ч', 'д', 'с' или '-1' за неограничен срок.",
|
"'s', 'm', 'h', 'd', 'w' or '-1' for no expiration.": "'s', 'm', 'h', 'd', 'w' или '-1' за неограничен срок.",
|
||||||
"(Beta)": "(Бета)",
|
"(Beta)": "(Бета)",
|
||||||
"(e.g. `sh webui.sh --api`)": "(например `sh webui.sh --api`)",
|
"(e.g. `sh webui.sh --api`)": "(например `sh webui.sh --api`)",
|
||||||
"(latest)": "(последна)",
|
"(latest)": "(последна)",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"'s', 'm', 'h', 'd', 'w' or '-1' for no expiration.": "'秒', '分', '時間', '日', '週' または '-1' で無期限。",
|
"'s', 'm', 'h', 'd', 'w' or '-1' for no expiration.": "'s', 'm', 'h', 'd', 'w' または '-1' で無期限。",
|
||||||
"(Beta)": "(ベータ版)",
|
"(Beta)": "(ベータ版)",
|
||||||
"(e.g. sh webui.sh --api)": "(例: sh webui.sh --api)",
|
"(e.g. sh webui.sh --api)": "(例: sh webui.sh --api)",
|
||||||
"(latest)": "(最新)",
|
"(latest)": "(最新)",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"'s', 'm', 'h', 'd', 'w' or '-1' for no expiration.": "'초', '분', '시간', '일', '주' 또는 만료 없음 '-1'",
|
"'s', 'm', 'h', 'd', 'w' or '-1' for no expiration.": "'s', 'm', 'h', 'd', 'w' 또는 만료 없음 '-1'",
|
||||||
"(Beta)": "(Beta)",
|
"(Beta)": "(Beta)",
|
||||||
"(e.g. `sh webui.sh --api`)": "(예: `sh webui.sh --api`)",
|
"(e.g. `sh webui.sh --api`)": "(예: `sh webui.sh --api`)",
|
||||||
"(latest)": "(latest)",
|
"(latest)": "(latest)",
|
||||||
|
|
|
@ -86,9 +86,9 @@
|
||||||
"Customize Ollama models for a specific purpose": "Dostosuj modele Ollama do określonego celu",
|
"Customize Ollama models for a specific purpose": "Dostosuj modele Ollama do określonego celu",
|
||||||
"Dark": "Ciemny",
|
"Dark": "Ciemny",
|
||||||
"Database": "Baza danych",
|
"Database": "Baza danych",
|
||||||
"DD/MM/YYYY HH:mm": "DD/MM/RRRR GG:MM",
|
"DD/MM/YYYY HH:mm": "DD/MM/YYYY HH:mm",
|
||||||
"Default": "Domyślny",
|
"Default": "Domyślny",
|
||||||
"Default (Automatic1111)": "Domyślny (Automatyczny1111)",
|
"Default (Automatic1111)": "Domyślny (Automatic1111)",
|
||||||
"Default (Web API)": "Domyślny (Interfejs API)",
|
"Default (Web API)": "Domyślny (Interfejs API)",
|
||||||
"Default model updated": "Domyślny model zaktualizowany",
|
"Default model updated": "Domyślny model zaktualizowany",
|
||||||
"Default Prompt Suggestions": "Domyślne sugestie promptów",
|
"Default Prompt Suggestions": "Domyślne sugestie promptów",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"'s', 'm', 'h', 'd', 'w' or '-1' for no expiration.": "'s', 'm', 'h', 'd', 's' ou '-1' para não expirar.",
|
"'s', 'm', 'h', 'd', 'w' or '-1' for no expiration.": "'s', 'm', 'h', 'd', 'w' ou '-1' para não expirar.",
|
||||||
"(Beta)": "(Beta)",
|
"(Beta)": "(Beta)",
|
||||||
"(e.g. `sh webui.sh --api`)": "(por exemplo, `sh webui.sh --api`)",
|
"(e.g. `sh webui.sh --api`)": "(por exemplo, `sh webui.sh --api`)",
|
||||||
"(latest)": "(mais recente)",
|
"(latest)": "(mais recente)",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"'s', 'm', 'h', 'd', 'w' or '-1' for no expiration.": "'s', 'm', 'h', 'd', 's' ou '-1' para nenhuma expiração.",
|
"'s', 'm', 'h', 'd', 'w' or '-1' for no expiration.": "'s', 'm', 'h', 'd', 'w' ou '-1' para nenhuma expiração.",
|
||||||
"(Beta)": "(Beta)",
|
"(Beta)": "(Beta)",
|
||||||
"(e.g. `sh webui.sh --api`)": "(por exemplo, `sh webui.sh --api`)",
|
"(e.g. `sh webui.sh --api`)": "(por exemplo, `sh webui.sh --api`)",
|
||||||
"(latest)": "(mais recente)",
|
"(latest)": "(mais recente)",
|
||||||
|
@ -86,7 +86,7 @@
|
||||||
"Customize Ollama models for a specific purpose": "Personalize os modelos Ollama para um propósito específico",
|
"Customize Ollama models for a specific purpose": "Personalize os modelos Ollama para um propósito específico",
|
||||||
"Dark": "Escuro",
|
"Dark": "Escuro",
|
||||||
"Database": "Banco de dados",
|
"Database": "Banco de dados",
|
||||||
"DD/MM/YYYY HH:mm": "DD/MM/AAAA HH:mm",
|
"DD/MM/YYYY HH:mm": "DD/MM/YYYY HH:mm",
|
||||||
"Default": "Padrão",
|
"Default": "Padrão",
|
||||||
"Default (Automatic1111)": "Padrão (Automatic1111)",
|
"Default (Automatic1111)": "Padrão (Automatic1111)",
|
||||||
"Default (Web API)": "Padrão (API Web)",
|
"Default (Web API)": "Padrão (API Web)",
|
||||||
|
@ -190,7 +190,7 @@
|
||||||
"Mirostat": "Mirostat",
|
"Mirostat": "Mirostat",
|
||||||
"Mirostat Eta": "Mirostat Eta",
|
"Mirostat Eta": "Mirostat Eta",
|
||||||
"Mirostat Tau": "Mirostat Tau",
|
"Mirostat Tau": "Mirostat Tau",
|
||||||
"MMMM DD, YYYY": "MMMM DD, AAAA",
|
"MMMM DD, YYYY": "DD/MM/YYYY",
|
||||||
"Model '{{modelName}}' has been successfully downloaded.": "O modelo '{{modelName}}' foi baixado com sucesso.",
|
"Model '{{modelName}}' has been successfully downloaded.": "O modelo '{{modelName}}' foi baixado com sucesso.",
|
||||||
"Model '{{modelTag}}' is already in queue for downloading.": "O modelo '{{modelTag}}' já está na fila para download.",
|
"Model '{{modelTag}}' is already in queue for downloading.": "O modelo '{{modelTag}}' já está na fila para download.",
|
||||||
"Model {{modelId}} not found": "Modelo {{modelId}} não encontrado",
|
"Model {{modelId}} not found": "Modelo {{modelId}} não encontrado",
|
||||||
|
|
|
@ -88,7 +88,7 @@
|
||||||
"Database": "База данных",
|
"Database": "База данных",
|
||||||
"DD/MM/YYYY HH:mm": "DD/MM/YYYY HH:mm",
|
"DD/MM/YYYY HH:mm": "DD/MM/YYYY HH:mm",
|
||||||
"Default": "По умолчанию",
|
"Default": "По умолчанию",
|
||||||
"Default (Automatic1111)": "По умолчанию (Автоматический1111)",
|
"Default (Automatic1111)": "По умолчанию (Automatic1111)",
|
||||||
"Default (Web API)": "По умолчанию (Web API)",
|
"Default (Web API)": "По умолчанию (Web API)",
|
||||||
"Default model updated": "Модель по умолчанию обновлена",
|
"Default model updated": "Модель по умолчанию обновлена",
|
||||||
"Default Prompt Suggestions": "Предложения промтов по умолчанию",
|
"Default Prompt Suggestions": "Предложения промтов по умолчанию",
|
||||||
|
|
|
@ -187,7 +187,8 @@ export const generateInitialsImage = (name) => {
|
||||||
return canvas.toDataURL();
|
return canvas.toDataURL();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const copyToClipboard = (text) => {
|
export const copyToClipboard = async (text) => {
|
||||||
|
let result = false;
|
||||||
if (!navigator.clipboard) {
|
if (!navigator.clipboard) {
|
||||||
const textArea = document.createElement('textarea');
|
const textArea = document.createElement('textarea');
|
||||||
textArea.value = text;
|
textArea.value = text;
|
||||||
|
@ -205,21 +206,27 @@ export const copyToClipboard = (text) => {
|
||||||
const successful = document.execCommand('copy');
|
const successful = document.execCommand('copy');
|
||||||
const msg = successful ? 'successful' : 'unsuccessful';
|
const msg = successful ? 'successful' : 'unsuccessful';
|
||||||
console.log('Fallback: Copying text command was ' + msg);
|
console.log('Fallback: Copying text command was ' + msg);
|
||||||
|
result = true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Fallback: Oops, unable to copy', err);
|
console.error('Fallback: Oops, unable to copy', err);
|
||||||
}
|
}
|
||||||
|
|
||||||
document.body.removeChild(textArea);
|
document.body.removeChild(textArea);
|
||||||
return;
|
return result;
|
||||||
}
|
}
|
||||||
navigator.clipboard.writeText(text).then(
|
|
||||||
function () {
|
result = await navigator.clipboard
|
||||||
|
.writeText(text)
|
||||||
|
.then(() => {
|
||||||
console.log('Async: Copying to clipboard was successful!');
|
console.log('Async: Copying to clipboard was successful!');
|
||||||
},
|
return true;
|
||||||
function (err) {
|
})
|
||||||
console.error('Async: Could not copy text: ', err);
|
.catch((error) => {
|
||||||
}
|
console.error('Async: Could not copy text: ', error);
|
||||||
);
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const compareVersion = (latest, current) => {
|
export const compareVersion = (latest, current) => {
|
||||||
|
|
Loading…
Reference in a new issue