mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-01 03:48:24 +00:00
4.8.10 test (#2539)
* fix: i18n * fix: null value * fix: workflow refresh variables * perf: copy data * doc * perf: run app code * perf: variable store * update doc * perf: pay ui * fix: log header ui * fix: log header ui
This commit is contained in:
@@ -2,6 +2,7 @@ import { useTranslation } from 'next-i18next';
|
||||
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||
import { useCallback } from 'react';
|
||||
import { hasHttps } from '@fastgpt/web/common/system/utils';
|
||||
import { isProduction } from '@fastgpt/service/common/system/constants';
|
||||
|
||||
/**
|
||||
* copy text data
|
||||
@@ -17,20 +18,31 @@ export const useCopyData = () => {
|
||||
duration = 1000
|
||||
) => {
|
||||
try {
|
||||
if (hasHttps() && navigator.clipboard) {
|
||||
if (hasHttps() && !isProduction && navigator.clipboard) {
|
||||
await navigator.clipboard.writeText(data);
|
||||
} else {
|
||||
throw new Error('');
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
// console.log(error);
|
||||
|
||||
const textarea = document.createElement('textarea');
|
||||
textarea.value = data;
|
||||
textarea.style.position = 'absolute';
|
||||
textarea.style.opacity = '0';
|
||||
document.body.appendChild(textarea);
|
||||
|
||||
textarea.select();
|
||||
document.execCommand('copy');
|
||||
document.body?.removeChild(textarea);
|
||||
const res = document.execCommand('copy');
|
||||
document.body.removeChild(textarea);
|
||||
|
||||
if (!res) {
|
||||
return toast({
|
||||
title: t('common:common.Copy_failed'),
|
||||
status: 'error',
|
||||
duration
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (title) {
|
||||
|
Reference in New Issue
Block a user