-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
|
||
import { downloadFile } from '@nmsn/utils'; | ||
|
||
const url = 'https://s2.loli.net/2023/04/20/4t8NgpMxkdVCJcs.png'; | ||
|
||
export default () => { | ||
return ( | ||
<> | ||
<img src={url} alt="logo" style={{ width: 200, height: 150 }} /> | ||
<button onClick={() => downloadFile(url)}>click</button> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
title: downloadFile | ||
toc: false | ||
--- | ||
|
||
## downloadFile | ||
|
||
下载文件,避免浏览器默认行为,如图片pdf会被浏览器直接打开 | ||
|
||
<code src="./demo.tsx"></code> | ||
|
||
### API | ||
|
||
```typescript | ||
downloadFile(url: string, name?: string); | ||
``` | ||
|
||
### Params | ||
|
||
| 参数 | 说明 | 类型 | 默认值 | | ||
| ---- | ---- | -------- | ------ | | ||
| url | 资源地址 | `string` | - | | ||
| name | 覆盖的文件名 | `string` | - | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { default as download } from './download'; | ||
export { default as downloadFile } from './downloadFile'; |
7d6f425
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
utils – ./
utils-git-main-nmsn.vercel.app
nmsn-utils.vercel.app
utils-nmsn.vercel.app