fix: Kopieren auf HTTP nutzt execCommand-Fallback (clipboard API braucht HTTPS)

This commit is contained in:
cynfo3000 2026-03-10 00:07:47 +01:00
parent 5cc3476479
commit 97eefcde5d
2 changed files with 4 additions and 6 deletions

View File

@ -1,6 +1,7 @@
import { useState, useRef, useEffect } from 'react' import { useState, useRef, useEffect } from 'react'
import { X, Play, Loader, Terminal, Copy, Check } from 'lucide-react' import { X, Play, Loader, Terminal, Copy, Check } from 'lucide-react'
import api from '../api/client' import api from '../api/client'
import { copyToClipboard } from '../utils/clipboard'
export default function ScriptModal({ agentId, agentName, onClose }) { export default function ScriptModal({ agentId, agentName, onClose }) {
const [script, setScript] = useState('#!/bin/bash\n\n') const [script, setScript] = useState('#!/bin/bash\n\n')
@ -35,7 +36,7 @@ export default function ScriptModal({ agentId, agentName, onClose }) {
const copyOutput = () => { const copyOutput = () => {
if (output) { if (output) {
navigator.clipboard.writeText(output) copyToClipboard(output)
setCopied(true) setCopied(true)
setTimeout(() => setCopied(false), 2000) setTimeout(() => setCopied(false), 2000)
} }

View File

@ -1,5 +1,6 @@
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import api from '../api/client' import api from '../api/client'
import { copyToClipboard } from '../utils/clipboard'
import { Plus, Trash2, Edit2, X, Check, ChevronDown, ChevronRight, Copy, Key } from 'lucide-react' import { Plus, Trash2, Edit2, X, Check, ChevronDown, ChevronRight, Copy, Key } from 'lucide-react'
const PERM_LABELS = { const PERM_LABELS = {
@ -204,11 +205,7 @@ function CustomerKeyPanel({ customerId }) {
}, [customerId]) }, [customerId])
const copyKey = (key, id) => { const copyKey = (key, id) => {
navigator.clipboard.writeText(key).catch(() => { copyToClipboard(key)
const el = document.createElement('textarea')
el.value = key; document.body.appendChild(el); el.select()
document.execCommand('copy'); document.body.removeChild(el)
})
setCopied(id) setCopied(id)
setTimeout(() => setCopied(null), 2000) setTimeout(() => setCopied(null), 2000)
} }