fix(packs): serialize same-pack upload/delete; clipboard fallback on http dashboard
- per (domain, type) lock held from the Nextcloud PUT/DELETE through the packs.json write,
so two concurrent replaces can't leave the file and its SHA1 out of sync
- navigator.clipboard is missing on http://<LAN-IP>; fall back to execCommand('copy')
and tell the user to copy by hand if that fails too
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -26,6 +26,25 @@ function propsSnippet(pack) {
|
||||
].join('\n')
|
||||
}
|
||||
|
||||
// 대시보드는 http://<내부IP> 라 보안 컨텍스트가 아니어서 navigator.clipboard 가 없다.
|
||||
// 그럴 땐 임시 textarea + execCommand('copy') 로 복사한다.
|
||||
async function copyToClipboard(text) {
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
try { await navigator.clipboard.writeText(text); return true } catch { /* 아래로 */ }
|
||||
}
|
||||
const ta = document.createElement('textarea')
|
||||
ta.value = text
|
||||
ta.setAttribute('readonly', '')
|
||||
ta.style.position = 'fixed'
|
||||
ta.style.opacity = '0'
|
||||
document.body.appendChild(ta)
|
||||
ta.select()
|
||||
let ok = false
|
||||
try { ok = document.execCommand('copy') } catch { ok = false }
|
||||
document.body.removeChild(ta)
|
||||
return ok
|
||||
}
|
||||
|
||||
// fetch 는 업로드 진행률을 못 주므로 XHR 사용
|
||||
function uploadPack(domain, kind, file, onProgress) {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -89,7 +108,10 @@ export default function Packs() {
|
||||
}
|
||||
|
||||
async function copy(key, text) {
|
||||
await navigator.clipboard.writeText(text)
|
||||
if (!(await copyToClipboard(text))) {
|
||||
setError('복사하지 못했습니다. 위 칸의 내용을 직접 선택해서 복사해 주세요.')
|
||||
return
|
||||
}
|
||||
setCopied(key)
|
||||
setTimeout(() => setCopied(null), 1500)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user