mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-09-10 21:30:14 +08:00
format
This commit is contained in:
parent
b6c13eb26a
commit
836dad24b9
69
src/vendor/Blob.js
vendored
69
src/vendor/Blob.js
vendored
@ -33,37 +33,37 @@
|
|||||||
var
|
var
|
||||||
get_class = function (object) {
|
get_class = function (object) {
|
||||||
return Object.prototype.toString.call(object).match(/^\[object\s(.*)\]$/)[1];
|
return Object.prototype.toString.call(object).match(/^\[object\s(.*)\]$/)[1];
|
||||||
}
|
},
|
||||||
, FakeBlobBuilder = function BlobBuilder() {
|
FakeBlobBuilder = function BlobBuilder() {
|
||||||
this.data = [];
|
this.data = [];
|
||||||
}
|
},
|
||||||
, FakeBlob = function Blob(data, type, encoding) {
|
FakeBlob = function Blob(data, type, encoding) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.size = data.length;
|
this.size = data.length;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.encoding = encoding;
|
this.encoding = encoding;
|
||||||
}
|
},
|
||||||
, FBB_proto = FakeBlobBuilder.prototype
|
FBB_proto = FakeBlobBuilder.prototype,
|
||||||
, FB_proto = FakeBlob.prototype
|
FB_proto = FakeBlob.prototype,
|
||||||
, FileReaderSync = view.FileReaderSync
|
FileReaderSync = view.FileReaderSync,
|
||||||
, FileException = function(type) {
|
FileException = function (type) {
|
||||||
this.code = this[this.name = type];
|
this.code = this[this.name = type];
|
||||||
}
|
},
|
||||||
, file_ex_codes = (
|
file_ex_codes = (
|
||||||
"NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR "
|
"NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR " +
|
||||||
+ "NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR"
|
"NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR"
|
||||||
).split(" ")
|
).split(" "),
|
||||||
, file_ex_code = file_ex_codes.length
|
file_ex_code = file_ex_codes.length,
|
||||||
, real_URL = view.URL || view.webkitURL || view
|
real_URL = view.URL || view.webkitURL || view,
|
||||||
, real_create_object_URL = real_URL.createObjectURL
|
real_create_object_URL = real_URL.createObjectURL,
|
||||||
, real_revoke_object_URL = real_URL.revokeObjectURL
|
real_revoke_object_URL = real_URL.revokeObjectURL,
|
||||||
, URL = real_URL
|
URL = real_URL,
|
||||||
, btoa = view.btoa
|
btoa = view.btoa,
|
||||||
, atob = view.atob
|
atob = view.atob
|
||||||
|
|
||||||
, ArrayBuffer = view.ArrayBuffer
|
,
|
||||||
, Uint8Array = view.Uint8Array
|
ArrayBuffer = view.ArrayBuffer,
|
||||||
;
|
Uint8Array = view.Uint8Array;
|
||||||
FakeBlob.fake = FB_proto.fake = true;
|
FakeBlob.fake = FB_proto.fake = true;
|
||||||
while (file_ex_code--) {
|
while (file_ex_code--) {
|
||||||
FileException.prototype[file_ex_codes[file_ex_code]] = file_ex_code + 1;
|
FileException.prototype[file_ex_codes[file_ex_code]] = file_ex_code + 1;
|
||||||
@ -73,9 +73,8 @@
|
|||||||
}
|
}
|
||||||
URL.createObjectURL = function (blob) {
|
URL.createObjectURL = function (blob) {
|
||||||
var
|
var
|
||||||
type = blob.type
|
type = blob.type,
|
||||||
, data_URI_header
|
data_URI_header;
|
||||||
;
|
|
||||||
if (type === null) {
|
if (type === null) {
|
||||||
type = "application/octet-stream";
|
type = "application/octet-stream";
|
||||||
}
|
}
|
||||||
@ -85,7 +84,8 @@
|
|||||||
return data_URI_header + ";base64," + blob.data;
|
return data_URI_header + ";base64," + blob.data;
|
||||||
} else if (blob.encoding === "URI") {
|
} else if (blob.encoding === "URI") {
|
||||||
return data_URI_header + "," + decodeURIComponent(blob.data);
|
return data_URI_header + "," + decodeURIComponent(blob.data);
|
||||||
} if (btoa) {
|
}
|
||||||
|
if (btoa) {
|
||||||
return data_URI_header + ";base64," + btoa(blob.data);
|
return data_URI_header + ";base64," + btoa(blob.data);
|
||||||
} else {
|
} else {
|
||||||
return data_URI_header + "," + encodeURIComponent(blob.data);
|
return data_URI_header + "," + encodeURIComponent(blob.data);
|
||||||
@ -104,11 +104,10 @@
|
|||||||
// decode data to a binary string
|
// decode data to a binary string
|
||||||
if (Uint8Array && (data instanceof ArrayBuffer || data instanceof Uint8Array)) {
|
if (Uint8Array && (data instanceof ArrayBuffer || data instanceof Uint8Array)) {
|
||||||
var
|
var
|
||||||
str = ""
|
str = "",
|
||||||
, buf = new Uint8Array(data)
|
buf = new Uint8Array(data),
|
||||||
, i = 0
|
i = 0,
|
||||||
, buf_len = buf.length
|
buf_len = buf.length;
|
||||||
;
|
|
||||||
for (; i < buf_len; i++) {
|
for (; i < buf_len; i++) {
|
||||||
str += String.fromCharCode(buf[i]);
|
str += String.fromCharCode(buf[i]);
|
||||||
}
|
}
|
||||||
@ -152,9 +151,7 @@
|
|||||||
type = null;
|
type = null;
|
||||||
}
|
}
|
||||||
return new FakeBlob(
|
return new FakeBlob(
|
||||||
this.data.slice(start, args > 1 ? end : this.data.length)
|
this.data.slice(start, args > 1 ? end : this.data.length), type, this.encoding
|
||||||
, type
|
|
||||||
, this.encoding
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
FB_proto.toString = function () {
|
FB_proto.toString = function () {
|
||||||
|
4
src/vendor/Export2Zip.js
vendored
4
src/vendor/Export2Zip.js
vendored
@ -14,7 +14,9 @@ export function export_txt_to_zip(th, jsonData, txtName, zipName) {
|
|||||||
txtData += `${tempStr}\r\n`
|
txtData += `${tempStr}\r\n`
|
||||||
})
|
})
|
||||||
zip.file(`${txt_name}.txt`, txtData)
|
zip.file(`${txt_name}.txt`, txtData)
|
||||||
zip.generateAsync({type:"blob"}).then((blob) => {
|
zip.generateAsync({
|
||||||
|
type: "blob"
|
||||||
|
}).then((blob) => {
|
||||||
saveAs(blob, `${zip_name}.zip`)
|
saveAs(blob, `${zip_name}.zip`)
|
||||||
}, (err) => {
|
}, (err) => {
|
||||||
alert('导出失败')
|
alert('导出失败')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user