mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-06 08:18:53 +00:00
fix(ui): standardize 'Copy to clipboard' toast notifications
This commit is contained in:
parent
c40ea7f29d
commit
83526f1d60
7 changed files with 26 additions and 12 deletions
|
|
@ -185,8 +185,9 @@
|
|||
<div class="flex items-center gap-1.5">
|
||||
<button
|
||||
class="copy-code-button bg-none border-none text-xs bg-gray-50 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-800 transition rounded-md px-1.5 py-0.5"
|
||||
on:click={() => {
|
||||
copyToClipboard(contents[selectedContentIdx].content);
|
||||
on:click={async () => {
|
||||
const res = await copyToClipboard(contents[selectedContentIdx].content);
|
||||
if (res) toast.success($i18n.t('Copied to clipboard'));
|
||||
copied = true;
|
||||
|
||||
setTimeout(() => {
|
||||
|
|
|
|||
|
|
@ -91,7 +91,10 @@
|
|||
|
||||
const copyCode = async () => {
|
||||
copied = true;
|
||||
await copyToClipboard(_code);
|
||||
const res = await copyToClipboard(_code);
|
||||
if (res) {
|
||||
toast.success($i18n.t('Copied to clipboard'));
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
copied = false;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<script lang="ts">
|
||||
import { getContext } from 'svelte';
|
||||
import { toast } from 'svelte-sonner';
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
import { copyToClipboard } from '$lib/utils';
|
||||
|
|
@ -26,7 +27,10 @@
|
|||
|
||||
const copyText = async () => {
|
||||
copied = true;
|
||||
await copyToClipboard(token.text, null, $settings?.copyFormatted ?? false);
|
||||
const res = await copyToClipboard(token.text, null, $settings?.copyFormatted ?? false);
|
||||
if (res) {
|
||||
toast.success($i18n.t('Copied to clipboard'));
|
||||
}
|
||||
setTimeout(() => {
|
||||
copied = false;
|
||||
}, 1000);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<script lang="ts">
|
||||
import { decode } from 'html-entities';
|
||||
import { toast } from 'svelte-sonner';
|
||||
import { onMount, getContext } from 'svelte';
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
|
|
@ -242,9 +243,12 @@
|
|||
<Tooltip content={$i18n.t('Copy')}>
|
||||
<button
|
||||
class="p-1 rounded-lg bg-transparent transition"
|
||||
on:click={(e) => {
|
||||
on:click={async (e) => {
|
||||
e.stopPropagation();
|
||||
copyToClipboard(token.raw.trim(), null, $settings?.copyFormatted ?? false);
|
||||
const res = await copyToClipboard(token.raw.trim(), null, $settings?.copyFormatted ?? false);
|
||||
if (res) {
|
||||
toast.success($i18n.t('Copied to clipboard'));
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Clipboard className=" size-3.5" strokeWidth="1.5" />
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@
|
|||
|
||||
const res = await _copyToClipboard(text, null, $settings?.copyFormatted ?? false);
|
||||
if (res) {
|
||||
toast.success($i18n.t('Copying to clipboard was successful!'));
|
||||
toast.success($i18n.t('Copied to clipboard'));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@
|
|||
const copyToClipboard = async (text) => {
|
||||
const res = await _copyToClipboard(text);
|
||||
if (res) {
|
||||
toast.success($i18n.t('Copying to clipboard was successful!'));
|
||||
toast.success($i18n.t('Copied to clipboard'));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -280,8 +280,9 @@
|
|||
<button
|
||||
class="ml-1.5 px-1.5 py-1 dark:hover:bg-gray-850 transition rounded-lg"
|
||||
aria-label={$i18n.t('Copy Token')}
|
||||
on:click={() => {
|
||||
copyToClipboard(localStorage.token);
|
||||
on:click={async () => {
|
||||
const res = await copyToClipboard(localStorage.token);
|
||||
if (res) toast.success($i18n.t('Copied to clipboard'));
|
||||
JWTTokenCopied = true;
|
||||
setTimeout(() => {
|
||||
JWTTokenCopied = false;
|
||||
|
|
@ -339,8 +340,9 @@
|
|||
<button
|
||||
class="ml-1.5 px-1.5 py-1 dark:hover:bg-gray-850 transition rounded-lg"
|
||||
aria-label={$i18n.t('Copy API Key')}
|
||||
on:click={() => {
|
||||
copyToClipboard(APIKey);
|
||||
on:click={async () => {
|
||||
const res = await copyToClipboard(APIKey);
|
||||
if (res) toast.success($i18n.t('Copied to clipboard'));
|
||||
APIKeyCopied = true;
|
||||
setTimeout(() => {
|
||||
APIKeyCopied = false;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue