mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-02 03:55:55 +00:00
fix: potential copy action bug on windows (#1931)
* fix a bag updata * Update page.tsx * Update page.tsx * Append text area to body for selection * Update page.tsx * Update mcp.py
This commit is contained in:
@@ -402,13 +402,33 @@ export default function PluginConfigPage() {
|
||||
};
|
||||
|
||||
const handleCopyDebugInfo = (text: string, type: 'url' | 'key') => {
|
||||
navigator.clipboard.writeText(text);
|
||||
if (type === 'url') {
|
||||
setCopiedDebugUrl(true);
|
||||
setTimeout(() => setCopiedDebugUrl(false), 2000);
|
||||
} else {
|
||||
setCopiedDebugKey(true);
|
||||
setTimeout(() => setCopiedDebugKey(false), 2000);
|
||||
try {
|
||||
navigator.clipboard.writeText(text);
|
||||
if (type === 'url') {
|
||||
setCopiedDebugUrl(true);
|
||||
setTimeout(() => setCopiedDebugUrl(false), 2000);
|
||||
} else {
|
||||
setCopiedDebugKey(true);
|
||||
setTimeout(() => setCopiedDebugKey(false), 2000);
|
||||
}
|
||||
} catch {
|
||||
const textArea = document.createElement('textarea');
|
||||
textArea.value = text;
|
||||
textArea.style.position = 'fixed';
|
||||
textArea.style.left = '-999999px';
|
||||
textArea.style.top = '-999999px';
|
||||
document.body.appendChild(textArea);
|
||||
textArea.select();
|
||||
textArea.setSelectionRange(0, 99999);
|
||||
const success = document.execCommand('copy');
|
||||
document.body.removeChild(textArea);
|
||||
if (success) {
|
||||
setCopiedDebugUrl(true);
|
||||
setTimeout(() => setCopiedDebugUrl(false), 2000);
|
||||
} else {
|
||||
setCopiedDebugKey(true);
|
||||
setTimeout(() => setCopiedDebugKey(false), 2000);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user