Compare commits

...

4 Commits

Author SHA1 Message Date
Anyon
b73af56831 修改样式 2022-07-13 14:13:12 +08:00
Anyon
67bbc41b50 增加样式 2022-07-13 14:10:22 +08:00
Anyon
126f36a51d 图片上传 增加 input[data-path] 支持 2022-07-13 10:07:13 +08:00
Anyon
3cef2b2139 文件上传,增加 data-path 参数 2022-07-13 10:05:03 +08:00
5 changed files with 17 additions and 4 deletions

View File

@ -11,6 +11,7 @@ define(['md5', 'notify'], function (SparkMD5, Notify, allowMime) {
this.option.safe = this.option.elem.data('safe') ? 1 : 0;
this.option.hide = this.option.elem.data('hload') ? 1 : 0;
this.option.mult = this.option.elem.data('multiple') > 0;
this.option.path = (this.option.elem.data('path') || '').replace(/\W/g, '');
this.option.type = this.option.safe ? 'local' : this.option.elem.attr('data-uptype') || '';
this.option.quality = parseFloat(this.option.elem.data('quality') || '1.0');
this.option.maxWidth = parseInt(this.option.elem.data('max-width') || '0');
@ -35,6 +36,7 @@ define(['md5', 'notify'], function (SparkMD5, Notify, allowMime) {
obj.items = [], obj.files = obj.pushFile();
layui.each(obj.files, function (idx, file) {
obj.items.push(file);
file.path = that.option.path;
file.quality = that.option.quality;
file.maxWidth = that.option.maxWidth;
file.maxHeight = that.option.maxHeight;
@ -83,7 +85,7 @@ define(['md5', 'notify'], function (SparkMD5, Notify, allowMime) {
require(['compressor'], function (Compressor) {
new Compressor(file, {
quality: file.quality, resize: 'cover', width: file.cutWidth || 0, height: file.cutHeight || 0, maxWidth: file.maxWidth, maxHeight: file.maxHeight, success(blob) {
files[index] = blob, blob.index = file.index, files[index].notify = file.notify;
blob.index = file.index, blob.notify = file.notify, blob.path = file.path, files[index] = blob;
that.hash(files[index]).then(function (file) {
that.event('upload.hash', file).request(file, done);
});
@ -247,6 +249,7 @@ define(['md5', 'notify'], function (SparkMD5, Notify, allowMime) {
function SetFileXdata(file, xmd5, slice) {
file.xmd5 = xmd5, file.xstate = 0, file.xstats = '';
file.xkey = file.xmd5.substring(0, slice || 2) + '/' + file.xmd5.substring(slice || 2) + '.' + file.xext;
if (file.path) file.xkey = file.path + '/' + file.xkey;
return defer.resolve(file, file.xmd5, file.xkey), file;
}

View File

@ -607,6 +607,7 @@ $(function () {
}).on('click', 'i.layui-icon-close', function (event) {
event.stopPropagation(), $bt.attr('style', ''), $in.val('');
}).find('[data-file]').data('input', this).attr({
'data-path': $in.data('path') || '',
'data-size': $in.data('size') || 0, 'data-type': $in.data('type') || 'gif,png,jpg,jpeg',
'data-max-width': $in.data('max-width') || 0, 'data-max-height': $in.data('max-height') || 0,
'data-cut-width': $in.data('cut-width') || 0, 'data-cut-height': $in.data('cut-height') || 0,
@ -621,6 +622,7 @@ $(function () {
var $bt = $('<div class="uploadimage"><span><a data-file="mul" class="layui-icon layui-icon-upload-drag"></a></span><span data-file="images"></span></div>');
var ims = this.value ? this.value.split('|') : [], $in = $(this).after($bt);
$bt.find('[data-file]').attr({
'data-path': $in.data('path') || '',
'data-size': $in.data('size') || 0, 'data-type': $in.data('type') || 'gif,png,jpg,jpeg',
'data-max-width': $in.data('max-width') || 0, 'data-max-height': $in.data('max-height') || 0,
'data-cut-width': $in.data('cut-width') || 0, 'data-cut-height': $in.data('cut-height') || 0,

View File

@ -122,7 +122,15 @@
}
.absolute {
position: absolute !important
position: absolute !important;
&-full {
top: 0;
left: 0;
right: 0;
bottom: 0;
position: absolute;
}
}
.relative {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long