feat: 优化代码
This commit is contained in:
@@ -48,7 +48,10 @@ class Ajax extends AdminController
|
|||||||
/**
|
/**
|
||||||
* 文件上传
|
* 文件上传
|
||||||
* @return Response|void
|
* @return Response|void
|
||||||
* @throws \Exception
|
* @throws DataNotFoundException
|
||||||
|
* @throws DbException
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
* @throws ModelNotFoundException
|
||||||
*/
|
*/
|
||||||
public function upload()
|
public function upload()
|
||||||
{
|
{
|
||||||
@@ -72,7 +75,11 @@ class Ajax extends AdminController
|
|||||||
public function getImage(): Response
|
public function getImage(): Response
|
||||||
{
|
{
|
||||||
if (request()->isPost()) {
|
if (request()->isPost()) {
|
||||||
$file = Upload::instance()->download(input('url'));
|
$url = request()->post('url');
|
||||||
|
if (empty($url)) {
|
||||||
|
return $this->error('图片地址不能为空');
|
||||||
|
}
|
||||||
|
$file = Upload::instance()->download($url);
|
||||||
if (!$file) {
|
if (!$file) {
|
||||||
return $this->error(Upload::instance()->getError());
|
return $this->error(Upload::instance()->getError());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,14 @@
|
|||||||
|
|
||||||
namespace app\admin\controller\system;
|
namespace app\admin\controller\system;
|
||||||
|
|
||||||
|
use app\admin\service\AttachmentService;
|
||||||
use app\AdminController;
|
use app\AdminController;
|
||||||
|
|
||||||
use app\common\model\system\Attachment as AttachmentModel;
|
use app\common\model\system\Attachment as AttachmentModel;
|
||||||
|
use support\Response;
|
||||||
|
use think\db\exception\DataNotFoundException;
|
||||||
|
use think\db\exception\DbException;
|
||||||
|
use think\db\exception\ModelNotFoundException;
|
||||||
use Webman\Http\Request;
|
use Webman\Http\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,10 +37,8 @@ class Attachment extends AdminController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化函数
|
* 初始化函数
|
||||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
* Attachment constructor.
|
||||||
* @throws \think\db\exception\DataNotFoundException
|
* @throws \Exception|\Psr\SimpleCache\InvalidArgumentException
|
||||||
* @throws \think\db\exception\DbException
|
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
@@ -46,32 +49,18 @@ class Attachment extends AdminController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取资源列表
|
* 获取资源列表
|
||||||
|
* @return Response
|
||||||
|
* @throws DataNotFoundException
|
||||||
|
* @throws DbException
|
||||||
|
* @throws ModelNotFoundException
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index(): Response
|
||||||
{
|
{
|
||||||
if (request()->isAjax()) {
|
if (request()->isAjax()) {
|
||||||
|
|
||||||
// 生成查询条件
|
$params = request()->post();
|
||||||
$post = request()->post();
|
list($count, $list) = AttachmentService::dataList($params);
|
||||||
$page = (int)input('page') ?: 1;
|
return $this->success('查询成功', "/", $list, $count);
|
||||||
$limit = (int)input('limit') ?: 10;
|
|
||||||
$type = input('type','');
|
|
||||||
|
|
||||||
$where = [];
|
|
||||||
if (!empty($post['filename'])) {
|
|
||||||
$where[] = ['filename','like','%'.$post['filename'].'%'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($type)) {
|
|
||||||
$where[] = ['type','=',$type];
|
|
||||||
}
|
|
||||||
|
|
||||||
$count = $this->model->where($where)->count();
|
|
||||||
$page = ($count <= $limit) ? 1 : $page;
|
|
||||||
|
|
||||||
// 生成查询数据
|
|
||||||
$list = $this->model->where($where)->order("id desc")->limit((int)$limit)->page((int)$page)->select()->toArray();
|
|
||||||
return $this->success('查询成功', "", $list, $count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('/system/attachment/index',[
|
return view('/system/attachment/index',[
|
||||||
|
|||||||
@@ -1,13 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<layout name="layout:layout" />
|
||||||
<html lang="zh-CN">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>查看消息</title>
|
|
||||||
<include file="public:header"/>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
font-family: "helvetica neue", PingFangSC-Light, arial, "hiragino sans gb", "microsoft yahei ui", "microsoft yahei", simsun, sans-serif;
|
font-family: "helvetica neue", PingFangSC-Light, arial, "hiragino sans gb", "microsoft yahei ui", "microsoft yahei", simsun, sans-serif;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
@@ -28,19 +20,19 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
<div class="layui-fluid">
|
<div class="layui-fluid" style="margin-top: 15px">
|
||||||
<div id="unread" data-count="{$unread|default='0'}"></div>
|
<div id="unread" data-count="{$unread|default='0'}"></div>
|
||||||
<div class="layui-card">
|
<div class="layui-card">
|
||||||
<div class="layui-card-header">
|
<div class="layui-card-header">
|
||||||
<h1>{$info.title}</h1>
|
<h1>{$msgInfo.title}</h1>
|
||||||
<p style="color: #3464ff">{$info.nickname|default='系统'} 于 {$info.create_time}</p>
|
<p style="color: #3464ff">{$msgInfo.nickname|default='系统'} 于 {$msgInfo.create_time}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-card-body layui-text">
|
<div class="layui-card-body layui-text">
|
||||||
{$info.content|raw}
|
{$msgInfo.content|raw}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
|
||||||
<script>
|
<script>
|
||||||
layui.use('jquery', function () {
|
layui.use('jquery', function () {
|
||||||
let $ = layui.jquery;
|
let $ = layui.jquery;
|
||||||
@@ -54,5 +46,4 @@
|
|||||||
bellMessage(unread);
|
bellMessage(unread);
|
||||||
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
</html>
|
|
||||||
@@ -46,6 +46,7 @@ body a:hover {
|
|||||||
margin-right: 16px;
|
margin-right: 16px;
|
||||||
display: block;
|
display: block;
|
||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.layui-instant-item-right {
|
.layui-instant-item-right {
|
||||||
@@ -138,47 +139,118 @@ body a:hover {
|
|||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#instant-content .layui-card-header {
|
/*// 系统通知样式*/
|
||||||
padding: 0;
|
#adminNotice {
|
||||||
font-weight: bold;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#instant-content .layui-card-header div {
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
|
|
||||||
#instant-content .layui-card-header .time {
|
|
||||||
float: right;
|
|
||||||
font-weight: normal;
|
|
||||||
color: #999;
|
|
||||||
}
|
|
||||||
|
|
||||||
#instant-content .layui-panel {
|
|
||||||
min-height: 250px;
|
|
||||||
padding: 0 20px 20px;
|
|
||||||
/*border-top: 2px solid #fe5d58;*/
|
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
#instant-content .layui-banner {
|
#adminNotice .layui-title {
|
||||||
position: absolute;
|
font-size: 14px;
|
||||||
bottom: 8px;
|
font-weight: 400;
|
||||||
color: #999;
|
padding-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#instant-content #layui-info {
|
#adminNotice .layui-title .time {
|
||||||
|
font-weight: normal;
|
||||||
|
color: #999;
|
||||||
|
margin-top: 6px;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#adminNotice .layui-title img {
|
||||||
|
border-radius: 50%;
|
||||||
|
margin-bottom: 3px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
#adminNotice .layui-message {
|
||||||
height: 150px;
|
height: 150px;
|
||||||
|
padding: 5px 5px 10px;
|
||||||
|
text-indent: 1em;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
#instant-content #layui-info img {
|
#adminNotice .borderNone {
|
||||||
|
border-bottom: 1px solid #ebebeb;
|
||||||
|
}
|
||||||
|
|
||||||
|
#adminNotice .layui-message img {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
border: 1px solid #eee;
|
border: 1px solid #eee;
|
||||||
}
|
}
|
||||||
|
|
||||||
#instant-content .layui-footer {
|
#adminNotice .layui-instructions {
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
|
||||||
|
#adminNotice .layui-footer {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
padding: 10px 0;
|
padding: 10px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#adminNotice .layui-card-header {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
#adminNotice .layui-card-header .time {
|
||||||
|
float: right;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar {
|
||||||
|
width: 2px;
|
||||||
|
height: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*// 用户私信样式*/
|
||||||
|
#adminMessage {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*// 代办项样式*/
|
||||||
|
#adminTodo .layui-card-header {
|
||||||
|
padding: 0;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#adminTodo .layui-card-header div {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
#adminTodo .layui-card-header .time {
|
||||||
|
float: right;
|
||||||
|
font-weight: normal;
|
||||||
|
color: #999;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#adminTodo .layui-panel {
|
||||||
|
min-height: 250px;
|
||||||
|
padding: 0 20px 20px;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
#adminTodo .layui-banner {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 8px;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
|
||||||
|
#adminTodo .layui-todo {
|
||||||
|
height: 180px;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
#adminTodo .layui-todo img {
|
||||||
|
max-width: 100%;
|
||||||
|
padding: 10px;
|
||||||
|
border: 1px solid #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
#adminTodo .layui-footer {
|
||||||
|
text-align: right;
|
||||||
|
padding: 10px 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user