Skip to content

Commit 22039fe

Browse files
committed
fix: Disable auto download fail in certain browsers
1 parent 07d4e02 commit 22039fe

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

client/src/components/ReceiveItem.vue

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,30 @@ function onTextClick(): void {
3535
3636
const supportsHover = window.matchMedia('(hover: hover)').matches
3737
38-
const downloadLink = ref(null)
38+
const downloadLink = ref<HTMLAnchorElement | null>(null)
39+
40+
// Auto download may be restricted in some environments, such as iOS and DuckDuckGo desktop.
41+
const isRestrictedEnv = () => {
42+
const ua = navigator.userAgent
43+
return (
44+
/(iPhone|iPod|iPad).*AppleWebKit/i.test(ua) ||
45+
/DuckDuckGo\/\d+\.\d+/.test(ua)
46+
)
47+
}
3948
4049
watch(
4150
() => props.success,
4251
success => {
43-
if (success && autoDownload.value && props.type === 'TRANSFER_TYPE_FILE') {
52+
if (
53+
success &&
54+
autoDownload.value &&
55+
props.type === 'TRANSFER_TYPE_FILE' &&
56+
!isRestrictedEnv()
57+
) {
4458
setTimeout(() => {
45-
downloadLink.value.click()
59+
if (downloadLink.value) {
60+
downloadLink.value.click()
61+
}
4662
}, 1000)
4763
}
4864
},

0 commit comments

Comments
 (0)