1 Star 0 Fork 49

im / uni-chat

forked from 野火IM / uni-chat 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
platformHelper.js 992 Bytes
一键复制 编辑 原始数据 按行查看 历史
heavyrian2012 提交于 2022-06-07 16:12 . uni chat code
import {ipcRenderer, isElectron} from "@/platform";
export function downloadFile(message) {
let file = message.messageContent;
if (isElectron()) {
ipcRenderer.send('file-download', {
messageId: message.messageId,
remotePath: file.remotePath,
fileName: file.name
});
} else {
let fileHref = file.remotePath;
let filename = file.name;
if (window.navigator.msSaveBlob) {// ie
let xhr = new XMLHttpRequest();
xhr.onloadstart = function () {
xhr.responseType = 'blob';
};
xhr.onload = function () {
navigator.msSaveOrOpenBlob(xhr.response, filename);
};
xhr.open("GET", fileHref, true);
xhr.send();
} else {
let anchor = document.createElement('a');
anchor.download = filename;
anchor.href = fileHref;
anchor.click();
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wang_im/uni-chat.git
git@gitee.com:wang_im/uni-chat.git
wang_im
uni-chat
uni-chat
main

搜索帮助

344bd9b3 5694891 D2dac590 5694891