fix download

This commit is contained in:
Pete Matsyburka committed 2026-09-23 11:00:17 +03:00
1 parent 5ea55c733f
commit 5d3369d556
1 file changed
+10 -1
+10 -1
View File
@@ -56,7 +56,7 @@
</span> </span>
</button> </button>
<button <button
v-if="!isWebView && withDownloadButton" v-if="(!isWebView || isNativeApp) && withDownloadButton"
class="base-button flex items-center space-x-1 w-full completed-form-download-button" class="base-button flex items-center space-x-1 w-full completed-form-download-button"
:disabled="isDownloading" :disabled="isDownloading"
@click.prevent="download" @click.prevent="download"
@@ -195,6 +195,9 @@ export default {
} }
}, },
computed: { computed: {
isNativeApp () {
return !!window.webkit?.messageHandlers?.download
},
isWebView () { isWebView () {
return /webview|wv|ip((?!.*Safari)|(?=.*like Safari))/i.test(window.navigator.userAgent) return /webview|wv|ip((?!.*Safari)|(?=.*like Safari))/i.test(window.navigator.userAgent)
} }
@@ -230,6 +233,12 @@ export default {
download () { download () {
this.isDownloading = true this.isDownloading = true
if (this.isNativeApp) {
document.addEventListener('native:download-end', () => { this.isDownloading = false }, { once: true })
return window.webkit.messageHandlers.download.postMessage({ src: this.baseUrl + `/s/${this.submitterSlug}/documents` })
}
fetch(this.baseUrl + `/s/${this.submitterSlug}/documents`, { fetch(this.baseUrl + `/s/${this.submitterSlug}/documents`, {
method: 'GET', method: 'GET',
...this.fetchOptions ...this.fetchOptions