diff --git a/app/admin/controller/Ajax.php b/app/admin/controller/Ajax.php index 58a50ef..c75916d 100644 --- a/app/admin/controller/Ajax.php +++ b/app/admin/controller/Ajax.php @@ -213,4 +213,23 @@ class Ajax extends AdminController return json($config); } } + + public function composerInfo(): Json + { + $lockFilePath = root_path() . '/composer.lock'; + $list = []; + if (file_exists($lockFilePath)) { + $lockFileContent = file_get_contents($lockFilePath); + if ($lockFileContent !== false) { + $lockData = json_decode($lockFileContent, true); + if (!empty($lockData['packages'])) { + foreach ($lockData['packages'] as $package) { + $list[] = ['name' => $package['name'], 'version' => $package['version']]; + } + } + } + } + $this->success('success', $list); + } + } \ No newline at end of file diff --git a/app/admin/controller/system/Config.php b/app/admin/controller/system/Config.php index d2f1385..1ec36c4 100644 --- a/app/admin/controller/system/Config.php +++ b/app/admin/controller/system/Config.php @@ -41,12 +41,12 @@ class Config extends AdminController if ($group == 'upload') { $upload_types = config('admin.upload_types'); // 兼容旧版本 - $this->model->where('name', 'upload_allow_type')->update(['value' => implode(',', array_keys($upload_types))]); + $this->model->removeOption('where')->where('name', 'upload_allow_type')->update(['value' => implode(',', array_keys($upload_types))]); } foreach ($post as $key => $val) { if (in_array($key, $notAddFields)) continue; - if ($this->model->where('name', $key)->count()) { - $this->model->where('name', $key)->update(['value' => $val,]); + if ($this->model->removeOption('where')->where('name', $key)->count()) { + $this->model->removeOption('where')->where('name', $key)->update(['value' => $val,]); }else { $this->model->create( [ @@ -59,7 +59,7 @@ class Config extends AdminController TriggerService::updateMenu(); TriggerService::updateSysConfig(); }catch (\Exception $e) { - $this->error('保存失败'); + $this->error('保存失败' .$e->getMessage()); } $this->success('保存成功'); } diff --git a/app/admin/controller/system/Log.php b/app/admin/controller/system/Log.php index 118b6aa..559ab15 100644 --- a/app/admin/controller/system/Log.php +++ b/app/admin/controller/system/Log.php @@ -34,7 +34,7 @@ class Log extends AdminController } [$page, $limit, $where, $excludeFields] = $this->buildTableParams(['month']); $month = !empty($excludeFields['month']) ? date('Ym', strtotime($excludeFields['month'])) : date('Ym'); - $model = $this->model->setMonth($month)->with('admin')->where($where); + $model = $this->model->setSuffix("_$month")->with('admin')->where($where); try { $count = $model->count(); $list = $model->page($page, $limit)->order($this->sort)->select(); @@ -60,7 +60,8 @@ class Log extends AdminController $this->error('演示环境下不允许操作'); } [$page, $limit, $where, $excludeFields] = $this->buildTableParams(['month']); - $tableName = $this->model->getName(); + $month = !empty($excludeFields['month']) ? date('Ym', strtotime($excludeFields['month'])) : date('Ym'); + $tableName = $this->model->setSuffix("_$month")->getName(); $tableName = CommonTool::humpToLine(lcfirst($tableName)); $prefix = config('database.connections.mysql.prefix'); $dbList = Db::query("show full columns from {$prefix}{$tableName}"); @@ -71,15 +72,18 @@ class Log extends AdminController $header[] = [$comment, $vo['Field']]; } } - $month = !empty($excludeFields['month']) ? date('Ym', strtotime($excludeFields['month'])) : date('Ym'); - $model = $this->model->setMonth($month)->with('admin')->where($where); + $model = $this->model->setSuffix("_$month")->with('admin')->where($where); try { $list = $model ->where($where) - ->limit(100000) + ->limit(10000) ->order('id', 'desc') ->select() ->toArray(); + foreach ($list as &$vo) { + $vo['content'] = json_encode($vo['content'], JSON_UNESCAPED_UNICODE); + $vo['response'] = json_encode($vo['response'], JSON_UNESCAPED_UNICODE); + } }catch (PDOException|DbException $exception) { $this->error($exception->getMessage()); } diff --git a/app/admin/controller/system/Node.php b/app/admin/controller/system/Node.php index 61c13f5..da0eff2 100644 --- a/app/admin/controller/system/Node.php +++ b/app/admin/controller/system/Node.php @@ -10,6 +10,9 @@ use app\admin\service\annotation\NodeAnnotation; use app\admin\service\NodeService; use app\Request; use think\App; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; use think\response\Json; #[ControllerAnnotation(title: '系统节点管理')] @@ -55,11 +58,11 @@ class Node extends AdminController try { if ($force == 1) { - $updateNodeList = $model->whereIn('node', array_column($nodeList, 'node'))->select(); + $updateNodeList = $model->removeOption('where')->whereIn('node', array_column($nodeList, 'node'))->select(); $formatNodeList = array_format_key($nodeList, 'node'); foreach ($updateNodeList as $vo) { isset($formatNodeList[$vo['node']]) - && $model->where('id', $vo['id'])->update( + && $model->removeOption('where')->where('id', $vo['id'])->update( [ 'title' => $formatNodeList[$vo['node']]['title'], 'is_auth' => $formatNodeList[$vo['node']]['is_auth'], @@ -67,7 +70,7 @@ class Node extends AdminController ); } } - $existNodeList = $model->field('node,title,type,is_auth')->select(); + $existNodeList = $model->removeOption('where')->field('node,title,type,is_auth')->select(); foreach ($nodeList as $key => $vo) { foreach ($existNodeList as $v) { if ($vo['node'] == $v->node) { @@ -76,8 +79,10 @@ class Node extends AdminController } } } - $model->saveAll($nodeList); - TriggerService::updateNode(); + if (!empty($nodeList)) { + $model->saveAll($nodeList); + TriggerService::updateNode(); + } }catch (\Exception $e) { $this->error('节点更新失败'); } diff --git a/app/admin/model/MallCate.php b/app/admin/model/MallCate.php index 24bf889..c2b9f23 100644 --- a/app/admin/model/MallCate.php +++ b/app/admin/model/MallCate.php @@ -8,6 +8,11 @@ use app\common\model\TimeModel; class MallCate extends TimeModel { - protected $deleteTime = 'delete_time'; + protected function getOptions(): array + { + return [ + 'deleteTime' => 'delete_time', + ]; + } } \ No newline at end of file diff --git a/app/admin/model/SystemAdmin.php b/app/admin/model/SystemAdmin.php index 77252ad..03abf16 100644 --- a/app/admin/model/SystemAdmin.php +++ b/app/admin/model/SystemAdmin.php @@ -8,7 +8,12 @@ use app\common\model\TimeModel; class SystemAdmin extends TimeModel { - protected $deleteTime = 'delete_time'; + protected function getOptions(): array + { + return [ + 'deleteTime' => 'delete_time', + ]; + } public array $notes = [ 'login_type' => [ @@ -17,12 +22,9 @@ class SystemAdmin extends TimeModel ], ]; - public function getAuthList() + public function getAuthList(): array { - $list = (new SystemAuth()) - ->where('status', 1) - ->column('title', 'id'); - return $list; + return (new SystemAuth())->removeOption('where')->where('status', 1)->column('title', 'id'); } } \ No newline at end of file diff --git a/app/admin/model/SystemAuth.php b/app/admin/model/SystemAuth.php index 89b6757..2657e70 100644 --- a/app/admin/model/SystemAuth.php +++ b/app/admin/model/SystemAuth.php @@ -3,44 +3,52 @@ namespace app\admin\model; use app\common\model\TimeModel; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; class SystemAuth extends TimeModel { - protected $deleteTime = 'delete_time'; + protected function getOptions(): array + { + return [ + 'deleteTime' => 'delete_time', + ]; + } /** * 根据角色ID获取授权节点 * @param $authId * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ - public function getAuthorizeNodeListByAdminId($authId) + public function getAuthorizeNodeListByAdminId($authId): array { $checkNodeList = (new SystemAuthNode()) ->where('auth_id', $authId) ->column('node_id'); - $systemNode = new SystemNode(); - $nodelList = $systemNode + $systemNode = new SystemNode(); + $nodeList = $systemNode ->where('is_auth', 1) ->field('id,node,title,type,is_auth') ->select() ->toArray(); - $newNodeList = []; - foreach ($nodelList as $vo) { + $newNodeList = []; + foreach ($nodeList as $vo) { if ($vo['type'] == 1) { - $vo = array_merge($vo, ['field' => 'node', 'spread' => true]); + $vo = array_merge($vo, ['field' => 'node', 'spread' => true]); $vo['checked'] = false; - $vo['title'] = "{$vo['title']}【{$vo['node']}】"; - $children = []; - foreach ($nodelList as $v) { + $vo['title'] = "{$vo['title']}【{$vo['node']}】"; + $children = []; + foreach ($nodeList as $v) { if ($v['type'] == 2 && strpos($v['node'], $vo['node'] . '/') !== false) { - $v = array_merge($v, ['field' => 'node', 'spread' => true]); + $v = array_merge($v, ['field' => 'node', 'spread' => true]); $v['checked'] = in_array($v['id'], $checkNodeList) ? true : false; - $v['title'] = "{$v['title']}【{$v['node']}】"; - $children[] = $v; + $v['title'] = "{$v['title']}【{$v['node']}】"; + $children[] = $v; } } !empty($children) && $vo['children'] = $children; diff --git a/app/admin/model/SystemLog.php b/app/admin/model/SystemLog.php index d399d1f..5f8f017 100644 --- a/app/admin/model/SystemLog.php +++ b/app/admin/model/SystemLog.php @@ -4,24 +4,23 @@ namespace app\admin\model; use app\admin\service\SystemLogService; use app\common\model\TimeModel; +use think\model\relation\BelongsTo; class SystemLog extends TimeModel { - public function __construct(array $data = []) - { - parent::__construct($data); - $this->name = 'system_log_' . date('Ym'); - } + protected array $type = [ + 'content' => 'json', + 'response' => 'json', + ]; - public function setMonth($month) + protected function init(): void { SystemLogService::instance()->detectTable(); - $this->name = 'system_log_' . $month; - return $this; } - public function admin() + + public function admin(): BelongsTo { return $this->belongsTo('app\admin\model\SystemAdmin', 'admin_id', 'id'); } diff --git a/app/admin/model/SystemMenu.php b/app/admin/model/SystemMenu.php index 9df01d7..e651cfb 100644 --- a/app/admin/model/SystemMenu.php +++ b/app/admin/model/SystemMenu.php @@ -4,31 +4,41 @@ namespace app\admin\model; use app\common\constants\MenuConstant; use app\common\model\TimeModel; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; class SystemMenu extends TimeModel { - - protected $deleteTime = 'delete_time'; - - public function getPidMenuList() + protected function getOptions(): array { - $list = $this->field('id,pid,title') - ->where([ - ['pid', '<>', MenuConstant::HOME_PID], - ['status', '=', 1], - ]) - ->select() - ->toArray(); + return [ + 'deleteTime' => 'delete_time', + ]; + } + + + /** + * @throws ModelNotFoundException + * @throws DbException + * @throws DataNotFoundException + */ + public function getPidMenuList(): array + { + $list = $this->removeOption('where')->field('id,pid,title')->where([ + ['pid', '<>', MenuConstant::HOME_PID], + ['status', '=', 1], + ])->select()->toArray(); + $pidMenuList = $this->buildPidMenu(0, $list); - $pidMenuList = array_merge([[ + return array_merge([[ 'id' => 0, 'pid' => 0, 'title' => '顶级菜单', ]], $pidMenuList); - return $pidMenuList; } - protected function buildPidMenu($pid, $list, $level = 0) + protected function buildPidMenu($pid, $list, $level = 0): array { $newList = []; foreach ($list as $vo) { diff --git a/app/admin/model/SystemNode.php b/app/admin/model/SystemNode.php index 72d5a7d..3b20375 100644 --- a/app/admin/model/SystemNode.php +++ b/app/admin/model/SystemNode.php @@ -7,22 +7,21 @@ use app\common\model\TimeModel; class SystemNode extends TimeModel { - public function getNodeTreeList() + public function getNodeTreeList(): array { - $list = $this->select()->toArray(); - $list = $this->buildNodeTree($list); - return $list; + $list = $this->removeOption('where')->select()->toArray(); + return $this->buildNodeTree($list); } - protected function buildNodeTree($list) + protected function buildNodeTree($list): array { - $newList = []; + $newList = []; $repeatString = " "; foreach ($list as $vo) { if ($vo['type'] == 1) { $newList[] = $vo; foreach ($list as $v) { - if ($v['type'] == 2 && strpos($v['node'], $vo['node'] . '/') !== false) { + if ($v['type'] == 2 && str_contains($v['node'], $vo['node'] . '/')) { $v['node'] = "{$repeatString}├{$repeatString}" . $v['node']; $newList[] = $v; } diff --git a/app/admin/model/SystemQuick.php b/app/admin/model/SystemQuick.php index 6262ddb..27542f8 100644 --- a/app/admin/model/SystemQuick.php +++ b/app/admin/model/SystemQuick.php @@ -7,6 +7,11 @@ use app\common\model\TimeModel; class SystemQuick extends TimeModel { - protected $deleteTime = 'delete_time'; + protected function getOptions(): array + { + return [ + 'deleteTime' => 'delete_time', + ]; + } } \ No newline at end of file diff --git a/app/admin/view/index/welcome.html b/app/admin/view/index/welcome.html index 0014880..127e231 100644 --- a/app/admin/view/index/welcome.html +++ b/app/admin/view/index/welcome.html @@ -151,12 +151,18 @@
${html}`
+ layer.open({
+ type: 1,
+ title: 'composer 信息',
+ area: ['50%', '90%'],
+ shade: 0.8,
+ shadeClose: true,
+ content: html,
+ success: function () {
+ layui.code({elem: '.code-demo', theme: 'dark', lang: 'php'});
+ }
+ })
+ }, function (error) {
+ console.error(error)
+ return false;
+ })
+
+ }
+ })
},
editAdmin: function () {
let form = layui.form
diff --git a/public/static/admin/js/system/log.js b/public/static/admin/js/system/log.js
index 2e71721..46a6538 100644
--- a/public/static/admin/js/system/log.js
+++ b/public/static/admin/js/system/log.js
@@ -49,9 +49,10 @@ define(["jquery", "easy-admin"], function ($, ea) {
{field: 'url', minWidth: 150, title: '路由地址', align: "left"},
{
field: 'content', minWidth: 200, title: '请求数据', align: "left", templet: function (res) {
+ console.log(res.content)
let html = '