Files
waf-platform/EdgeAdmin/web/views/@default/httpdns/apps/sdkUpload.js

51 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Tea.context(function () {
this.platform = "android";
this.version = this.defaultVersion || "1.0.0";
this.isUploading = false;
if (!Array.isArray(this.uploadedFiles)) {
this.uploadedFiles = [];
}
this.beforeUpload = function () {
var maxSize = 20 * 1024 * 1024; // 20MB
var inputs = document.querySelectorAll("input[type=file]");
for (var i = 0; i < inputs.length; i++) {
var files = inputs[i].files;
if (files != null && files.length > 0) {
if (files[0].size > maxSize) {
teaweb.warn("文件 \"" + files[0].name + "\" 超过 20MB 限制(" + (files[0].size / 1024 / 1024).toFixed(1) + "MB请压缩后重试");
return false;
}
}
}
this.isUploading = true;
};
this.doneUpload = function () {
this.isUploading = false;
};
this.successUpload = function () {
teaweb.success("上传成功", function () {
window.location = "/httpdns/apps/sdk?appId=" + this.app.id;
}.bind(this));
};
this.deleteUploadedFile = function (filename) {
let that = this;
teaweb.confirm("确定要删除文件 " + filename + " 吗?", function () {
that.$post("/httpdns/apps/sdk/upload/delete")
.params({
appId: that.app.id,
filename: filename
})
.success(function () {
teaweb.success("删除成功", function () {
window.location.reload();
});
});
});
};
});