tav-ui
Version:
94 lines (89 loc) • 2.39 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var is = require('../is2.js');
const typeDic = {
docx: "application/msword",
doc: "application/msword",
bin: "application/octet-stream",
exe: "application/octet-stream",
so: "application/octet-stream",
dll: "application/octet-stream",
pdf: "application/pdf",
ai: "application/postscript",
xls: "application/vnd.ms-excel",
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
ppt: "application/vnd.ms-powerpoint",
pptx: "application/vnd.ms-powerpoint",
dir: "application/x-director",
js: "application/x-javascript",
swf: "application/x-shockwave-flash",
xhtml: "application/xhtml+xml",
xht: "application/xhtml+xml",
zip: "application/zip",
mid: "audio/midi",
midi: "audio/midi",
mp3: "audio/mpeg",
rm: "audio/x-pn-realaudio",
rpm: "audio/x-pn-realaudio-plugin",
wav: "audio/x-wav",
bmp: "image/bmp",
gif: "image/gif",
jpeg: "image/jpeg",
jpg: "image/jpeg",
png: "image/png",
css: "text/css",
html: "text/html",
htm: "text/html",
txt: "text/plain",
xsl: "text/xml",
xml: "text/xml",
mpeg: "video/mpeg",
mpg: "video/mpeg",
avi: "video/x-msvideo",
movie: "video/x-sgi-movie"
};
function downLoadCallBack(res, name, suffix) {
if (!res)
return;
const fileReader = new FileReader();
fileReader.readAsText(res, "utf-8");
fileReader.onload = () => {
try {
} catch (err) {
if (window.navigator.msSaveBlob) {
try {
;
window.navigator.msSaveBlob(res, name);
} catch (e) {
}
} else {
const url = window.URL.createObjectURL(new Blob([res], { type: typeDic[suffix] }));
const link = document.createElement("a");
link.style.display = "none";
link.href = url;
link.setAttribute("download", name);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
window.URL.revokeObjectURL(url);
}
}
};
}
const download = (data) => {
if (is.isArray(data)) {
if (data.length == 0) {
return;
}
const ids = [];
data.forEach((v) => {
ids.push(v.id);
});
} else {
if (!data || !data.id) {
}
}
};
exports.downLoadCallBack = downLoadCallBack;
exports.download = download;
//# sourceMappingURL=_download2.js.map