mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2026-07-11 18:11:07 +08:00
Compare commits
8 Commits
c5a8bc9141
...
5d5305a454
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d5305a454 | ||
|
|
f4bda9cf4b | ||
|
|
5c0919a5ca | ||
|
|
d6075b9ec8 | ||
|
|
b44c3237f3 | ||
|
|
7b3d4047cb | ||
|
|
7e446bae09 | ||
|
|
bb3ab695a7 |
@ -100,15 +100,15 @@ class Menu extends Controller
|
||||
{
|
||||
if ($this->request->isGet()) {
|
||||
/* 清理权限节点 */
|
||||
if ($this->app->isDebug()) {
|
||||
if ($isDebug = $this->app->isDebug()) {
|
||||
AdminService::instance()->clearCache();
|
||||
}
|
||||
/* 选择自己的上级菜单 */
|
||||
/* 选择自己上级菜单 */
|
||||
$vo['pid'] = $vo['pid'] ?? input('pid', '0');
|
||||
/* 读取系统功能节点 */
|
||||
$this->auths = [];
|
||||
$this->nodes = MenuService::instance()->getList();
|
||||
foreach (NodeService::instance()->getMethods($this->app->isDebug()) as $node => $item) {
|
||||
$this->nodes = MenuService::instance()->getList($isDebug);
|
||||
foreach (NodeService::instance()->getMethods($isDebug) as $node => $item) {
|
||||
if ($item['isauth'] && substr_count($node, '/') >= 2) {
|
||||
$this->auths[] = ['node' => $node, 'title' => $item['title']];
|
||||
}
|
||||
|
||||
@ -17,6 +17,9 @@
|
||||
namespace app\admin\controller\api;
|
||||
|
||||
use think\admin\Controller;
|
||||
use think\admin\helper\QueryHelper;
|
||||
use think\admin\model\SystemFile;
|
||||
use think\admin\service\AdminService;
|
||||
use think\admin\Storage;
|
||||
use think\admin\storage\AliossStorage;
|
||||
use think\admin\storage\LocalStorage;
|
||||
@ -66,10 +69,21 @@ class Upload extends Controller
|
||||
{
|
||||
[$name, $safe] = [input('name'), $this->getSafe()];
|
||||
$data = ['uptype' => $this->getType(), 'safe' => intval($safe), 'key' => input('key')];
|
||||
$file = SystemFile::mk()->data($this->_vali([
|
||||
'xkey.value' => $data['key'],
|
||||
'type.value' => $this->getType(),
|
||||
'uuid.value' => AdminService::instance()->getUserId(),
|
||||
'name.require' => '名称不能为空!',
|
||||
'hash.require' => '哈希不能为空!',
|
||||
'xext.require' => '后缀不能为空!',
|
||||
'size.require' => '大小不能为空!',
|
||||
'mime.require' => "类型不能为空!",
|
||||
'status.value' => 1
|
||||
]));
|
||||
if ($info = Storage::instance($data['uptype'])->info($data['key'], $safe, $name)) {
|
||||
$data['url'] = $info['url'];
|
||||
$data['key'] = $info['key'];
|
||||
$this->success('文件已经上传', $data, 200);
|
||||
$file->save(['xurl' => $info['url'], 'isfast' => 1, 'issafe' => $data['safe']]);
|
||||
$extr = ['id' => $file->id ?? 0, 'url' => $info['url'], 'key' => $info['key']];
|
||||
$this->success('文件已经上传', array_merge($data, $extr), 200);
|
||||
} elseif ('local' === $data['uptype']) {
|
||||
$data['url'] = LocalStorage::instance()->url($data['key'], $safe, $name);
|
||||
$data['server'] = LocalStorage::instance()->upload();
|
||||
@ -100,7 +114,47 @@ class Upload extends Controller
|
||||
$data['authorization'] = $token['authorization'];
|
||||
$data['server'] = UpyunStorage::instance()->upload();
|
||||
}
|
||||
$this->success('获取上传授权参数', $data, 404);
|
||||
$file->save(['xurl' => $data['url'], 'isfast' => 0, 'issafe' => $data['safe']]);
|
||||
$this->success('获取上传授权参数', array_merge($data, ['id' => $file->id ?? 0]), 404);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新文件状态
|
||||
* @login true
|
||||
* @return void
|
||||
*/
|
||||
public function done()
|
||||
{
|
||||
$data = $this->_vali([
|
||||
'id.require' => '编号不能为空!',
|
||||
'hash.require' => '哈希不能为空!',
|
||||
]);
|
||||
$data['uuid'] = AdminService::instance()->getUserId();
|
||||
$file = SystemFile::mk()->where($data)->findOrEmpty();
|
||||
if ($file->isEmpty()) $this->error('文件不存在!');
|
||||
if ($file->save(['status' => 2])) {
|
||||
$this->success('更新成功!');
|
||||
} else {
|
||||
$this->error('更新失败!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件选择器
|
||||
* @login true
|
||||
* @return void
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function modal()
|
||||
{
|
||||
SystemFile::mQuery()->layTable(function () {
|
||||
$this->title = '文件选择器';
|
||||
}, function (QueryHelper $query) {
|
||||
$query->where(['status' => 2])->order('id desc');
|
||||
$query->like('name,hash')->dateBetween('create_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -95,10 +95,11 @@ define(['md5', 'notify'], function (SparkMD5, Notify, allowMime) {
|
||||
// 文件上传
|
||||
Adapter.prototype.request = function (file, done) {
|
||||
var that = this, data = {key: file.xkey, safe: that.option.safe, uptype: that.option.type};
|
||||
data.size = file.size, data.name = file.name, data.hash = file.xmd5;
|
||||
data.size = file.size, data.name = file.name, data.hash = file.xmd5, data.mime = file.type, data.xext = file.xext;
|
||||
jQuery.ajax("{:url('admin/api.upload/state')}", {
|
||||
data: data, method: 'post', success: function (ret) {
|
||||
file.xurl = ret.data.url, file.xsafe = ret.data.safe, file.xpath = ret.data.key, file.xtype = ret.data.uptype;
|
||||
file.id = ret.data.id || 0, file.xurl = ret.data.url;
|
||||
file.xsafe = ret.data.safe, file.xpath = ret.data.key, file.xtype = ret.data.uptype;
|
||||
if (parseInt(ret.code) === 404) {
|
||||
var uploader = {};
|
||||
uploader.url = ret.data.server;
|
||||
@ -179,6 +180,7 @@ define(['md5', 'notify'], function (SparkMD5, Notify, allowMime) {
|
||||
/*! 检查单个文件上传返回的结果 */
|
||||
if (ret.code < 1) return $.msg.tips(ret.info || '文件上传失败!');
|
||||
if (typeof file.xurl !== 'string') return $.msg.tips('无效的文件上传对象!');
|
||||
jQuery.post("{:url('admin/api.upload/done')}", {id: file.id, hash: file.xmd5});
|
||||
/*! 单个文件上传成功结果处理 */
|
||||
if (typeof done === 'function') {
|
||||
done.call(this.option.elem, file.xurl, this.files['id']);
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
"topthink/framework": "^6.0",
|
||||
"topthink/think-view": "^1.0",
|
||||
"zoujingli/ip2region": "^1.0",
|
||||
"zoujingli/think-library": "^6.0",
|
||||
"zoujingli/think-library": "^6.0.33",
|
||||
"zoujingli/wechat-developer": "^1.2"
|
||||
},
|
||||
"autoload": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user