From 48465b11ab9d2d8c2d927e773e071dd9652e8537 Mon Sep 17 00:00:00 2001 From: Karson Date: Sat, 6 May 2017 14:50:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0plupload=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=90=8E=E5=A1=AB=E5=85=85=E6=96=87=E6=9C=AC=E6=A1=86=E7=9A=84?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/command/Crud.php | 4 ++-- application/admin/view/general/attachment/add.html | 8 ++++---- application/admin/view/page/add.html | 4 ++-- application/admin/view/page/edit.html | 4 ++-- application/admin/view/user/user/add.phtml | 4 ++-- application/admin/view/user/user/edit.phtml | 4 ++-- application/extra/upload.php | 8 ++++---- public/assets/js/require-upload.js | 12 ++++++++---- 8 files changed, 26 insertions(+), 22 deletions(-) diff --git a/application/admin/command/Crud.php b/application/admin/command/Crud.php index 0945db81..ade0a9a5 100644 --- a/application/admin/command/Crud.php +++ b/application/admin/command/Crud.php @@ -188,7 +188,7 @@ class Crud extends Command //如果是图片则额外附加 if (substr($field, -5) == 'image' || substr($field, -6) == 'avatar') { - $attr['data-plupload-id'] = "plupload-{$field}-text"; + //$attr['data-plupload-id'] = "plupload-{$field}-text"; $attr['size'] = 50; } $fieldFunc = substr($field, -4) == 'time' ? "|datetime" : ""; @@ -377,7 +377,7 @@ EOD; return << {$content} - + EOD; } diff --git a/application/admin/view/general/attachment/add.html b/application/admin/view/general/attachment/add.html index 65ab5db6..17eb07ef 100644 --- a/application/admin/view/general/attachment/add.html +++ b/application/admin/view/general/attachment/add.html @@ -2,28 +2,28 @@
- +
- +
- +
- +
diff --git a/application/admin/view/page/add.html b/application/admin/view/page/add.html index e55b7856..b10d8ad1 100644 --- a/application/admin/view/page/add.html +++ b/application/admin/view/page/add.html @@ -28,8 +28,8 @@
- - + +
diff --git a/application/admin/view/page/edit.html b/application/admin/view/page/edit.html index cf34746f..22ebfa28 100644 --- a/application/admin/view/page/edit.html +++ b/application/admin/view/page/edit.html @@ -28,8 +28,8 @@
- - + +
diff --git a/application/admin/view/user/user/add.phtml b/application/admin/view/user/user/add.phtml index 765ffd2f..3bee637f 100644 --- a/application/admin/view/user/user/add.phtml +++ b/application/admin/view/user/user/add.phtml @@ -81,8 +81,8 @@
- - + +
diff --git a/application/admin/view/user/user/edit.phtml b/application/admin/view/user/user/edit.phtml index b0e8209f..ba7e8913 100644 --- a/application/admin/view/user/user/edit.phtml +++ b/application/admin/view/user/user/edit.phtml @@ -82,8 +82,8 @@
- - + +
diff --git a/application/extra/upload.php b/application/extra/upload.php index dc06ec68..93504bfa 100644 --- a/application/extra/upload.php +++ b/application/extra/upload.php @@ -3,21 +3,21 @@ //上传配置 return [ /** - * 上传地址,如果不使用又拍云,则可以使用ajax/upload + * 上传地址,默认是本地上传,如果需要使用又拍云则改为http://v0.api.upyun.com/yourbucketname */ 'uploadurl' => 'ajax/upload', /** * 又拍云或本机的CDN地址 */ - 'cdnurl' => '', + 'cdnurl' => 'http://yourbucketname.b0.upaiyun.com', /** * 上传成功后的通知地址 */ - 'notifyurl' => '', + 'notifyurl' => 'http://www.yoursite.com/upyun/notify', /** * 又拍云Bucket */ - 'bucket' => '', + 'bucket' => 'yourbucketname', /** * 生成的policy有效时间 */ diff --git a/public/assets/js/require-upload.js b/public/assets/js/require-upload.js index 61622e8f..5c644cfd 100755 --- a/public/assets/js/require-upload.js +++ b/public/assets/js/require-upload.js @@ -19,6 +19,7 @@ define(['jquery', 'bootstrap', 'backend', 'config', 'plupload'], function ($, un var multiple = $(this).data("multiple"); //上传URL url = url ? url : Config.upload.uploadurl; + url = Backend.api.fixurl(url); //最大可上传 maxsize = maxsize ? maxsize : Config.upload.maxsize; //文件类型 @@ -50,7 +51,7 @@ define(['jquery', 'bootstrap', 'backend', 'config', 'plupload'], function ($, un //这里可以改成其它的表现形式 //document.getElementById('filelist').innerHTML += '
' + file.name + ' (' + plupload.formatSize(file.size) + ')
'; }); - $("#" + id).data("bakup-html", $("#" + id).html()); + $(that).data("bakup-html", $(that).html()); //添加后立即上传 setTimeout(function () { Upload.list[id].start(); @@ -59,11 +60,11 @@ define(['jquery', 'bootstrap', 'backend', 'config', 'plupload'], function ($, un UploadProgress: function (up, file) { //这里可以改成其它的表现形式 //document.getElementById(file.id).getElementsByTagName('b')[0].innerHTML = '' + file.percent + "%"; - $("#" + id).prop("disabled", true).html(" 上传" + file.percent + "%"); + $(that).prop("disabled", true).html(" 上传" + file.percent + "%"); }, FileUploaded: function (up, file, info) { //还原按钮文字及状态 - $("#" + id).prop("disabled", false).html($("#" + id).data("bakup-html")); + $(that).prop("disabled", false).html($(that).data("bakup-html")); //这里可以改成其它的表现形式 //document.getElementById(file.id).getElementsByTagName('b')[0].innerHTML += (' [Url]: ' + '' + url + ''); //这里建议不修改 @@ -75,7 +76,10 @@ define(['jquery', 'bootstrap', 'backend', 'config', 'plupload'], function ($, un var data = ret.hasOwnProperty("data") && ret.data != "" ? ret.data : null; var msg = ret.hasOwnProperty("msg") && ret.msg != "" ? ret.msg : ""; if (ret.code === 1) { - $("input[data-plupload-id='" + id + "-text']").val(data.url); + //$("input[data-plupload-id='" + id + "-text']").val(data.url); + if ($(that).data("input-id")) { + $("input#" + $(that).data("input-id")).val(data.url); + } var afterUpload = $("#" + id).data("after-upload"); if (afterUpload && typeof Upload.api.custom[afterUpload] == 'function') { Upload.api.custom[afterUpload].call(that, data);