Skip to content

Commit

Permalink
fix download file on tg
Browse files Browse the repository at this point in the history
  • Loading branch information
XueMoMo committed Dec 23, 2024
1 parent 33a32bf commit f54639f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<link rel="preconnect" href="https://fonts.googleapis.com"/>
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin/>
<link href="https://fonts.googleapis.com/css2?family=Gupter:wght@400;500;700&family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap" rel="stylesheet"/>
<script src="https://telegram.org/js/telegram-web-app.js?56"></script>
</head>
<body>
<div id="root"></div>
Expand Down
7 changes: 6 additions & 1 deletion src/components/ATable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ const ATable = React.forwardRef(({ header = [], data = [], loading, className }:
// link.target = "_blank"
// link.href = host || '';
// link.click();
FileSaver.saveAs(host, item.fileName)
if ('Telegram' in window) {
(window.Telegram as any).WebApp.downloadFile({ url: host, file_name: item.fileName })
} else {
FileSaver.saveAs(host, item.fileName)
}

}
const onShare = (item: data) => {
return fileHost(item)
Expand Down

0 comments on commit f54639f

Please sign in to comment.