mirror of https://gitee.com/karson/fastadmin.git
parent
3cac7c1f20
commit
ec0eefd16a
|
|
@ -187,10 +187,13 @@ class Ajax extends Backend
|
||||||
|
|
||||||
//判断是否已经存在附件
|
//判断是否已经存在附件
|
||||||
$sha1 = $file->hash();
|
$sha1 = $file->hash();
|
||||||
$uploaded = model("attachment")->where('sha1',$sha1)->find();
|
$uploaded = model("attachment")->where('sha1', $sha1)->find();
|
||||||
if($uploaded){
|
if ($uploaded)
|
||||||
$this->code = 200;
|
{
|
||||||
$this->data = $uploaded['url'];
|
$this->code = 1;
|
||||||
|
$this->data = [
|
||||||
|
'url' => $uploaded['url']
|
||||||
|
];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -245,8 +248,10 @@ class Ajax extends Backend
|
||||||
'sha1' => $sha1,
|
'sha1' => $sha1,
|
||||||
);
|
);
|
||||||
model("attachment")->create(array_filter($params));
|
model("attachment")->create(array_filter($params));
|
||||||
$this->code = 200;
|
$this->code = 1;
|
||||||
$this->data = $uploadDir . $splInfo->getSaveName();
|
$this->data = [
|
||||||
|
'url' => $uploadDir . $splInfo->getSaveName()
|
||||||
|
];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -343,22 +348,27 @@ class Ajax extends Backend
|
||||||
/**
|
/**
|
||||||
* 清空系统缓存
|
* 清空系统缓存
|
||||||
*/
|
*/
|
||||||
public function wipeCache()
|
public function wipecache()
|
||||||
{
|
{
|
||||||
$wipe_cache_type = ['TEMP_PATH', 'LOG_PATH', 'CACHE_PATH'];
|
$wipe_cache_type = ['TEMP_PATH', 'LOG_PATH', 'CACHE_PATH'];
|
||||||
foreach ($wipe_cache_type as $item) {
|
foreach ($wipe_cache_type as $item)
|
||||||
if ($item == 'LOG_PATH') {
|
{
|
||||||
|
if ($item == 'LOG_PATH')
|
||||||
|
{
|
||||||
$dirs = (array) glob(constant($item) . '*');
|
$dirs = (array) glob(constant($item) . '*');
|
||||||
foreach ($dirs as $dir) {
|
foreach ($dirs as $dir)
|
||||||
|
{
|
||||||
array_map('unlink', (array) glob($dir . DIRECTORY_SEPARATOR . '*.*'));
|
array_map('unlink', (array) glob($dir . DIRECTORY_SEPARATOR . '*.*'));
|
||||||
}
|
}
|
||||||
array_map('rmdir', $dirs);
|
array_map('rmdir', $dirs);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
array_map('unlink', (array) glob(constant($item) . DIRECTORY_SEPARATOR . '*.*'));
|
array_map('unlink', (array) glob(constant($item) . DIRECTORY_SEPARATOR . '*.*'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Cache::clear();
|
Cache::clear();
|
||||||
$this->success('清空系统缓存成功!');
|
$this->code = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,4 +28,6 @@ return [
|
||||||
'Login successful' => '登录成功!',
|
'Login successful' => '登录成功!',
|
||||||
'Logout successful' => '退出成功!',
|
'Logout successful' => '退出成功!',
|
||||||
'Verification code is incorrect' => '验证码不正确',
|
'Verification code is incorrect' => '验证码不正确',
|
||||||
|
'Wipe cache completed' => '清除缓存成功',
|
||||||
|
'Wipe cache failed' => '清除缓存失败',
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<a href="javascript:;" data-toggle="wipeCache" title="清空缓存">
|
<a href="javascript:;" data-toggle="wipecache" title="清空缓存">
|
||||||
<i class="fa fa-trash"></i>
|
<i class="fa fa-trash"></i>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,14 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="c-local" class="control-label col-xs-12 col-sm-2"></label>
|
<label for="c-local" class="control-label col-xs-12 col-sm-2"></label>
|
||||||
<div class="col-xs-12 col-sm-8">
|
<div class="col-xs-12 col-sm-8">
|
||||||
<button id="plupload-local" class="btn btn-primary plupload" data-url="{:url('ajax/upload')}"><i class="fa fa-upload"></i> {:__("Upload to local")}</button>
|
<button id="plupload-local" class="btn btn-primary plupload" data-url="{:url('ajax/upload')}" data-after-upload="afteruploadcallback"><i class="fa fa-upload"></i> {:__("Upload to local")}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="c-local" class="control-label col-xs-12 col-sm-2">{:__('Upload by summernote')}:</label>
|
||||||
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
<textarea name="row[summernote]" id="c-summernote" cols="30" rows="5" class="summernote"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
//上传配置
|
//上传配置
|
||||||
return [
|
return [
|
||||||
/**
|
/**
|
||||||
* 上传地址,如果不使用又拍云,则可以使用/ajax/upload
|
* 上传地址,如果不使用又拍云,则可以使用ajax/upload
|
||||||
*/
|
*/
|
||||||
'uploadurl' => '/admin/ajax/upload',
|
'uploadurl' => 'ajax/upload',
|
||||||
/**
|
/**
|
||||||
* 又拍云或本机的CDN地址
|
* 又拍云或本机的CDN地址
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ define(['jquery', 'bootstrap', 'backend', 'form', 'table', 'config'], function (
|
||||||
thumb: function (value, row, index) {
|
thumb: function (value, row, index) {
|
||||||
//console.log(row);
|
//console.log(row);
|
||||||
if (row.mimetype.indexOf("image") > -1) {
|
if (row.mimetype.indexOf("image") > -1) {
|
||||||
if (Config.upload.bucket.replace(/^\s+|\s+$/gm,'').length === 0){
|
if (Config.upload.bucket.replace(/^\s+|\s+$/gm, '').length === 0) {
|
||||||
return '<a href="' + Config.upload.cdnurl + value + '" target="_blank"><img src="' + Config.upload.cdnurl + value + '" alt="" style="max-height:90px;max-width:120px"></a>';
|
return '<a href="' + Config.upload.cdnurl + value + '" target="_blank"><img src="' + Config.upload.cdnurl + value + '" alt="" style="max-height:90px;max-width:120px"></a>';
|
||||||
} else {
|
} else {
|
||||||
return '<a href="' + Config.upload.cdnurl + value + '" target="_blank"><img src="' + Config.upload.cdnurl + value + '!/fwfh/50x50" alt=""></a>';
|
return '<a href="' + Config.upload.cdnurl + value + '" target="_blank"><img src="' + Config.upload.cdnurl + value + '!/fwfh/50x50" alt=""></a>';
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ define(['jquery', 'bootstrap', 'backend', 'config', 'plupload'], function ($, un
|
||||||
plupload: function (element, onAfterUpload) {
|
plupload: function (element, onAfterUpload) {
|
||||||
element = typeof element == 'undefined' ? Upload.config.classname : element;
|
element = typeof element == 'undefined' ? Upload.config.classname : element;
|
||||||
$(element, Upload.config.container).each(function () {
|
$(element, Upload.config.container).each(function () {
|
||||||
|
var that = this;
|
||||||
var id = $(this).prop("id");
|
var id = $(this).prop("id");
|
||||||
var url = $(this).data("url");
|
var url = $(this).data("url");
|
||||||
var maxsize = $(this).data("maxsize");
|
var maxsize = $(this).data("maxsize");
|
||||||
|
|
@ -69,17 +70,21 @@ define(['jquery', 'bootstrap', 'backend', 'config', 'plupload'], function ($, un
|
||||||
try {
|
try {
|
||||||
var ret = JSON.parse(info.response);
|
var ret = JSON.parse(info.response);
|
||||||
if (ret.hasOwnProperty('code')) {
|
if (ret.hasOwnProperty('code')) {
|
||||||
ret.data = ret.code == 200 ? ret.data : ret.data;
|
ret.data = ret.code == 200 ? ret : ret.data;
|
||||||
ret.code = ret.code == 200 ? 1 : ret.code;
|
ret.code = ret.code == 200 ? 1 : ret.code;
|
||||||
var data = ret.hasOwnProperty("data") && ret.data != "" ? ret.data : null;
|
var data = ret.hasOwnProperty("data") && ret.data != "" ? ret.data : null;
|
||||||
var msg = ret.hasOwnProperty("msg") && ret.msg != "" ? ret.msg : "";
|
var msg = ret.hasOwnProperty("msg") && ret.msg != "" ? ret.msg : "";
|
||||||
$("input[data-plupload-id='" + id + "-text']").val(data);
|
if (ret.code === 1) {
|
||||||
var afterUpload = $("#" + id).data("after-upload");
|
$("input[data-plupload-id='" + id + "-text']").val(data.url);
|
||||||
if (afterUpload && typeof Upload.api.custom[afterUpload] == 'function') {
|
var afterUpload = $("#" + id).data("after-upload");
|
||||||
Upload.api.custom[afterUpload].call(info, id, data);
|
if (afterUpload && typeof Upload.api.custom[afterUpload] == 'function') {
|
||||||
}
|
Upload.api.custom[afterUpload].call(that, data);
|
||||||
if (typeof onAfterUpload == 'function') {
|
}
|
||||||
onAfterUpload.call(info, id, data);
|
if (typeof onAfterUpload == 'function') {
|
||||||
|
onAfterUpload.call(that, data);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Toastr.error(msg ? msg : __('Operation failed'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Toastr.error(e.message + "(code:-2)");
|
Toastr.error(e.message + "(code:-2)");
|
||||||
|
|
@ -137,8 +142,8 @@ define(['jquery', 'bootstrap', 'backend', 'config', 'plupload'], function ($, un
|
||||||
},
|
},
|
||||||
custom: {
|
custom: {
|
||||||
//自定义上传完成回调
|
//自定义上传完成回调
|
||||||
afteruploadcallback: function (id, response) {
|
afteruploadcallback: function (response) {
|
||||||
console.log(this, id, response);
|
console.log(this, response);
|
||||||
alert("Custom Callback,Response URL:" + response.url);
|
alert("Custom Callback,Response URL:" + response.url);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue