mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-27 08:25:07 +00:00
feat: 修改chat的数据结构
This commit is contained in:
@@ -6,15 +6,20 @@ import { useToast } from '@/hooks/useToast';
|
||||
*/
|
||||
export const useCopyData = () => {
|
||||
const { toast } = useToast();
|
||||
|
||||
return {
|
||||
copyData: (data: string, title: string = '复制成功') => {
|
||||
copyData: async (data: string, title: string = '复制成功') => {
|
||||
try {
|
||||
const textarea = document.createElement('textarea');
|
||||
textarea.value = data;
|
||||
document.body.appendChild(textarea);
|
||||
textarea.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(textarea);
|
||||
if (navigator.clipboard) {
|
||||
await navigator.clipboard.writeText(data);
|
||||
} else {
|
||||
const textarea = document.createElement('textarea');
|
||||
textarea.value = data;
|
||||
document.body.appendChild(textarea);
|
||||
textarea.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(textarea);
|
||||
}
|
||||
toast({
|
||||
title,
|
||||
status: 'success',
|
||||
|
Reference in New Issue
Block a user