Skip to content

Commit

Permalink
fix: 修复因mix-content导致无法在https环境下载http资源的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed Feb 7, 2020
1 parent 394eb32 commit c54cab7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/shared/project.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ interface ProjectConfig {
version: string;
environment: string;
platform: string;
isSSL: boolean;
io: {
protocol: 'wss' | 'ws';
host: string;
Expand Down Expand Up @@ -105,6 +106,7 @@ const config: ProjectConfig = {
version: require('../../package.json').version,
environment,
platform,
isSSL,
io: {
protocol: isSSL ? 'wss' : 'ws',
host: currentHost,
Expand Down
7 changes: 7 additions & 0 deletions src/shared/utils/file-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ export const getUploadsImagePath = (filename: string, isTemporary = false) => {
* @param url 下载地址
*/
export const downloadFileWeb = (url: string) => {
if (config.isSSL && url.startsWith('http://')) {
// 如果当前是ssl协议且下载地址是http协议
// 直接打开窗口(因为mix-content限制)
window.open(url);
return;
}

let a = document.createElement('a');
a.style.display = 'none';
a.href = url;
Expand Down

0 comments on commit c54cab7

Please sign in to comment.