mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-06 20:10:12 +02:00
fix(share): only copy to clipboard if available and secure
This commit is contained in:
@@ -391,9 +391,11 @@
|
||||
},
|
||||
"shareItem": {
|
||||
"allowDownloading": "allow downloading",
|
||||
"copyToClipboard": "Copy to clipboard: Ctrl+C, Enter",
|
||||
"description": "description",
|
||||
"setExpiration": "set expiration",
|
||||
"success": "share link copied to clipboard (or click here to open)",
|
||||
"successMustClick": "share created successfully. click here to open",
|
||||
"expireInvalid": "expiration must be in the future",
|
||||
"createFailed": "failed to create share (is sharing enabled?)"
|
||||
},
|
||||
|
||||
@@ -74,13 +74,22 @@ export const ShareItemContextModal = ({
|
||||
if (!serverUrl) throw new Error('Server URL not found');
|
||||
const shareUrl = `${serverUrl}/share/${_data.id}`;
|
||||
|
||||
const canUseClipboard = navigator.clipboard && window.isSecureContext;
|
||||
if (canUseClipboard) {
|
||||
navigator.clipboard.writeText(shareUrl);
|
||||
}
|
||||
|
||||
toast.success({
|
||||
autoClose: 5000,
|
||||
autoClose: canUseClipboard ? 5000 : 15000,
|
||||
id: 'share-item-toast',
|
||||
message: t('form.shareItem.success', {
|
||||
message: t(
|
||||
canUseClipboard
|
||||
? 'form.shareItem.success'
|
||||
: 'form.shareItem.successMustClick',
|
||||
{
|
||||
postProcess: 'sentenceCase',
|
||||
}),
|
||||
},
|
||||
),
|
||||
onClick: (a) => {
|
||||
if (!(a.target instanceof HTMLElement)) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user