mirror of https://gitee.com/karson/fastadmin.git
Merge pull request !4 from PPPSCN/master
commit
3cac7c1f20
|
|
@ -5,4 +5,6 @@ composer.lock
|
||||||
thinkphp
|
thinkphp
|
||||||
vendor
|
vendor
|
||||||
runtime
|
runtime
|
||||||
public/assets/libs/
|
public/assets/libs/
|
||||||
|
/application/admin/command/Install/*.lock
|
||||||
|
/public/uploads
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,9 @@ CREATE TABLE `fa_attachment` (
|
||||||
`createtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建日期',
|
`createtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建日期',
|
||||||
`updatetime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
|
`updatetime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
|
||||||
`uploadtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '上传时间',
|
`uploadtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '上传时间',
|
||||||
PRIMARY KEY (`id`)
|
`sha1` varchar(40) NOT NULL DEFAULT '' COMMENT '文件 sha1编码',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `sha1` (`sha1`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='附件表';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='附件表';
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ use fast\Tree;
|
||||||
use think\Config;
|
use think\Config;
|
||||||
use think\Db;
|
use think\Db;
|
||||||
use think\Lang;
|
use think\Lang;
|
||||||
|
use think\Cache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ajax异步请求接口
|
* Ajax异步请求接口
|
||||||
|
|
@ -183,6 +184,16 @@ class Ajax extends Backend
|
||||||
{
|
{
|
||||||
$this->code = -1;
|
$this->code = -1;
|
||||||
$file = $this->request->file('file');
|
$file = $this->request->file('file');
|
||||||
|
|
||||||
|
//判断是否已经存在附件
|
||||||
|
$sha1 = $file->hash();
|
||||||
|
$uploaded = model("attachment")->where('sha1',$sha1)->find();
|
||||||
|
if($uploaded){
|
||||||
|
$this->code = 200;
|
||||||
|
$this->data = $uploaded['url'];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$upload = Config::get('upload');
|
$upload = Config::get('upload');
|
||||||
|
|
||||||
preg_match('/(\d+)(\w+)/', $upload['maxsize'], $matches);
|
preg_match('/(\d+)(\w+)/', $upload['maxsize'], $matches);
|
||||||
|
|
@ -230,7 +241,8 @@ class Ajax extends Backend
|
||||||
'imageframes' => 0,
|
'imageframes' => 0,
|
||||||
'mimetype' => $fileInfo['type'],
|
'mimetype' => $fileInfo['type'],
|
||||||
'url' => $uploadDir . $splInfo->getSaveName(),
|
'url' => $uploadDir . $splInfo->getSaveName(),
|
||||||
'uploadtime' => time()
|
'uploadtime' => time(),
|
||||||
|
'sha1' => $sha1,
|
||||||
);
|
);
|
||||||
model("attachment")->create(array_filter($params));
|
model("attachment")->create(array_filter($params));
|
||||||
$this->code = 200;
|
$this->code = 200;
|
||||||
|
|
@ -328,4 +340,25 @@ class Ajax extends Backend
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清空系统缓存
|
||||||
|
*/
|
||||||
|
public function wipeCache()
|
||||||
|
{
|
||||||
|
$wipe_cache_type = ['TEMP_PATH', 'LOG_PATH', 'CACHE_PATH'];
|
||||||
|
foreach ($wipe_cache_type as $item) {
|
||||||
|
if ($item == 'LOG_PATH') {
|
||||||
|
$dirs = (array) glob(constant($item) . '*');
|
||||||
|
foreach ($dirs as $dir) {
|
||||||
|
array_map('unlink', (array) glob($dir . DIRECTORY_SEPARATOR . '*.*'));
|
||||||
|
}
|
||||||
|
array_map('rmdir', $dirs);
|
||||||
|
} else {
|
||||||
|
array_map('unlink', (array) glob(constant($item) . DIRECTORY_SEPARATOR . '*.*'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Cache::clear();
|
||||||
|
$this->success('清空系统缓存成功!');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,12 @@
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<a href="javascript:;" data-toggle="wipeCache" title="清空缓存">
|
||||||
|
<i class="fa fa-trash"></i>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-language"></i></a>
|
<a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-language"></i></a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ class Backend extends Controller
|
||||||
$sort = $this->request->get("sort", "id");
|
$sort = $this->request->get("sort", "id");
|
||||||
$order = $this->request->get("order", "DESC");
|
$order = $this->request->get("order", "DESC");
|
||||||
$offset = $this->request->get("offset", 0);
|
$offset = $this->request->get("offset", 0);
|
||||||
$limit = $this->request->get("limit", 10);
|
$limit = $this->request->get("limit", 0);
|
||||||
$filter = json_decode($filter, TRUE);
|
$filter = json_decode($filter, TRUE);
|
||||||
$op = json_decode($op, TRUE);
|
$op = json_decode($op, TRUE);
|
||||||
$filter = $filter ? $filter : [];
|
$filter = $filter ? $filter : [];
|
||||||
|
|
|
||||||
|
|
@ -5,19 +5,19 @@ return [
|
||||||
/**
|
/**
|
||||||
* 上传地址,如果不使用又拍云,则可以使用/ajax/upload
|
* 上传地址,如果不使用又拍云,则可以使用/ajax/upload
|
||||||
*/
|
*/
|
||||||
'uploadurl' => 'http://v0.api.upyun.com/yourbucketname',
|
'uploadurl' => '/admin/ajax/upload',
|
||||||
/**
|
/**
|
||||||
* 又拍云或本机的CDN地址
|
* 又拍云或本机的CDN地址
|
||||||
*/
|
*/
|
||||||
'cdnurl' => 'http://yourbucketname.b0.upaiyun.com',
|
'cdnurl' => '',
|
||||||
/**
|
/**
|
||||||
* 上传成功后的通知地址
|
* 上传成功后的通知地址
|
||||||
*/
|
*/
|
||||||
'notifyurl' => 'http://www.yoursite.com/upyun/notify',
|
'notifyurl' => '',
|
||||||
/**
|
/**
|
||||||
* 又拍云Bucket
|
* 又拍云Bucket
|
||||||
*/
|
*/
|
||||||
'bucket' => 'yourbucketname',
|
'bucket' => '',
|
||||||
/**
|
/**
|
||||||
* 生成的policy有效时间
|
* 生成的policy有效时间
|
||||||
*/
|
*/
|
||||||
|
|
@ -29,7 +29,7 @@ return [
|
||||||
/**
|
/**
|
||||||
* 文件保存格式
|
* 文件保存格式
|
||||||
*/
|
*/
|
||||||
'savekey' => '/uploads/media/{year}{mon}{day}/{filemd5}{.suffix}',
|
'savekey' => '/uploads/{year}{mon}{day}/{filemd5}{.suffix}',
|
||||||
/**
|
/**
|
||||||
* 最大可上传大小
|
* 最大可上传大小
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,5 @@
|
||||||
|
|
||||||
RewriteCond %{REQUEST_FILENAME} !-d
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
|
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
|
||||||
</IfModule>
|
</IfModule>
|
||||||
|
|
|
||||||
|
|
@ -54,9 +54,13 @@ define(['jquery', 'bootstrap', 'backend', 'form', 'table', 'config'], function (
|
||||||
},
|
},
|
||||||
formatter: {
|
formatter: {
|
||||||
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) {
|
||||||
return '<a href="' + Config.upload.cdnurl + value + '" target="_blank"><img src="' + Config.upload.cdnurl + value + '!/fwfh/50x50" alt=""></a>';
|
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>';
|
||||||
|
} else {
|
||||||
|
return '<a href="' + Config.upload.cdnurl + value + '" target="_blank"><img src="' + Config.upload.cdnurl + value + '!/fwfh/50x50" alt=""></a>';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return '无';
|
return '无';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,22 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'adminlte', 'validator'], f
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//清除缓存
|
||||||
|
$(document).on('click', "[data-toggle='wipeCache']", function () {
|
||||||
|
$.ajax({
|
||||||
|
url: 'ajax/wipeCache',
|
||||||
|
dataType: 'json',
|
||||||
|
cache: false,
|
||||||
|
success: function (ret) {
|
||||||
|
if (ret.code === 1) {
|
||||||
|
Backend.api.toastr.success(ret.msg);
|
||||||
|
} else {
|
||||||
|
Backend.api.toastr.error('清除系统缓存失败!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
//全屏事件
|
//全屏事件
|
||||||
$(document).on('click', "[data-toggle='fullscreen']", function () {
|
$(document).on('click', "[data-toggle='fullscreen']", function () {
|
||||||
var doc = document.documentElement;
|
var doc = document.documentElement;
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,14 @@ define(['jquery', 'bootstrap', 'backend', 'config', 'toastr', 'moment', 'bootstr
|
||||||
method: 'get',
|
method: 'get',
|
||||||
toolbar: "#toolbar",
|
toolbar: "#toolbar",
|
||||||
search: true,
|
search: true,
|
||||||
|
cache: false,
|
||||||
advancedSearch: true,
|
advancedSearch: true,
|
||||||
idTable: 'advancedTable',
|
idTable: 'advancedTable',
|
||||||
showExport: true,
|
showExport: true,
|
||||||
|
exportDataType: "all",
|
||||||
|
exportTypes: ['json', 'xml', 'csv', 'txt', 'doc', 'excel'],
|
||||||
|
pageSize: 10,
|
||||||
|
pageList: [10, 25, 50, 'All'],
|
||||||
pagination: true,
|
pagination: true,
|
||||||
clickToSelect: true,
|
clickToSelect: true,
|
||||||
showRefresh: false,
|
showRefresh: false,
|
||||||
|
|
|
||||||
|
|
@ -69,11 +69,11 @@ 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 : ret.data;
|
ret.data = ret.code == 200 ? ret.data : 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.url);
|
$("input[data-plupload-id='" + id + "-text']").val(data);
|
||||||
var afterUpload = $("#" + id).data("after-upload");
|
var afterUpload = $("#" + id).data("after-upload");
|
||||||
if (afterUpload && typeof Upload.api.custom[afterUpload] == 'function') {
|
if (afterUpload && typeof Upload.api.custom[afterUpload] == 'function') {
|
||||||
Upload.api.custom[afterUpload].call(info, id, data);
|
Upload.api.custom[afterUpload].call(info, id, data);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue