mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-17 09:56:06 +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') => {
|
const handleCopyDebugInfo = (text: string, type: 'url' | 'key') => {
|
||||||
navigator.clipboard.writeText(text);
|
try {
|
||||||
if (type === 'url') {
|
navigator.clipboard.writeText(text);
|
||||||
setCopiedDebugUrl(true);
|
if (type === 'url') {
|
||||||
setTimeout(() => setCopiedDebugUrl(false), 2000);
|
setCopiedDebugUrl(true);
|
||||||
} else {
|
setTimeout(() => setCopiedDebugUrl(false), 2000);
|
||||||
setCopiedDebugKey(true);
|
} else {
|
||||||
setTimeout(() => setCopiedDebugKey(false), 2000);
|
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