Skip to content

Commit 8a1cb72

Browse files
committed
feat: 🎸 (xgplayer) download support authentication
1 parent eda69e6 commit 8a1cb72

File tree

2 files changed

+438
-5
lines changed

2 files changed

+438
-5
lines changed

packages/xgplayer/src/plugins/download/index.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
import downloadUtil from 'downloadjs'
21
import { POSITIONS, Util } from '../../plugin'
3-
import { xgIconTips } from '../common/iconTools'
4-
import IconPlugin from '../common/iconPlugin'
52
import DownloadSvg from '../assets/download.svg'
3+
import IconPlugin from '../common/iconPlugin'
4+
import { xgIconTips } from '../common/iconTools'
5+
import { saveAsWithAuth } from './saveAs'
6+
67
import './index.scss'
8+
79
/**
810
* @typedef { {
911
* position: string,
1012
* index: number,
1113
* disable: boolean,
14+
* saveAsOptions: import('./saveAs').SaveAsOptions,
1215
* [propName: string]: any
1316
* } } IDownloadConfig
1417
*/
@@ -24,7 +27,10 @@ export default class Download extends IconPlugin {
2427
return {
2528
position: POSITIONS.CONTROLS_RIGHT,
2629
index: 3,
27-
disable: true
30+
disable: true,
31+
saveAsOptions: {
32+
withCredentials: true
33+
}
2834
}
2935
}
3036

@@ -67,7 +73,7 @@ export default class Download extends IconPlugin {
6773
dUrl = url[0].src
6874
}
6975
const newUrl = this.getAbsoluteURL(dUrl)
70-
downloadUtil(newUrl)
76+
saveAsWithAuth(newUrl, Object.assign({}, this.config.saveAsOptions))
7177
this.isLock = true
7278
this.timer = window.setTimeout(() => {
7379
this.isLock = false

0 commit comments

Comments
 (0)