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