124 lines
3.3 KiB
PHP
124 lines
3.3 KiB
PHP
<?php
|
|
/*
|
|
* @Author: YwxApp <ywx@ywxapp.cn>
|
|
* @Date: 2026-04-29 02:32:33
|
|
* @LastEditors: YwxApp <ywx@ywxapp.cn>
|
|
* @LastEditTime: 2026-07-21 22:29:51
|
|
* @Description:
|
|
* @FilePath: \ywxapp_dev\app\backend\controller\Console.php
|
|
* @CustomString: Copyright (c) 2026 YwxApp
|
|
*/
|
|
|
|
declare (strict_types = 1);
|
|
namespace app\backend\controller;
|
|
|
|
use think\Request;
|
|
use think\facade\View;
|
|
use think\facade\Db;
|
|
use ywxapp\controller\BackendBase;
|
|
|
|
/**
|
|
* Console 类
|
|
*
|
|
* @author ywxapp <admin@ywxapp.cn>
|
|
*/
|
|
class Console extends BackendBase
|
|
{
|
|
/**
|
|
* Summary of needLogin
|
|
* @var array
|
|
*/
|
|
protected $noNeedLogin = [];
|
|
|
|
/**
|
|
* Summary of needRight
|
|
* @var array
|
|
*/
|
|
protected $noNeedVerify = [];
|
|
|
|
/**
|
|
* 控制器初始化 initialize
|
|
* @return void
|
|
*/
|
|
protected function initialize()
|
|
{}
|
|
|
|
/**
|
|
* 显示资源列表
|
|
*
|
|
* @param \think\Request $request
|
|
* @return \think\Response
|
|
*/
|
|
public function index()
|
|
{
|
|
View::assign('title', '控制台');
|
|
return View::fetch();
|
|
}
|
|
|
|
|
|
/**
|
|
* 热门统计(真实数据)
|
|
*
|
|
* @return \think\Response
|
|
*/
|
|
public function hotsearch()
|
|
{
|
|
$admin = Db::name('backend_admin')->count();
|
|
$user = Db::name('member')->count();
|
|
$article = Db::name('articles_article')->count();
|
|
$links = Db::name('links')->count();
|
|
$addon = Db::name('addon')->count();
|
|
$data = [
|
|
['keywords' => '管理员', 'frequency' => $admin, 'userNums' => $admin],
|
|
['keywords' => '会员', 'frequency' => $user, 'userNums' => $user],
|
|
['keywords' => '文章', 'frequency' => $article, 'userNums' => $article],
|
|
['keywords' => '友链', 'frequency' => $links, 'userNums' => $links],
|
|
['keywords' => '插件', 'frequency' => $addon, 'userNums' => $addon],
|
|
];
|
|
$this->result->success($data);
|
|
}
|
|
|
|
/**
|
|
* 热门内容(真实数据:最新文章)
|
|
*
|
|
* @return \think\Response
|
|
*/
|
|
public function hotTopic()
|
|
{
|
|
$list = Db::name('articles_article')
|
|
->field('id, title, author, cid, create_at')
|
|
->order('id', 'desc')
|
|
->limit(10)
|
|
->select()
|
|
->toArray();
|
|
$data = array_map(function ($item) {
|
|
return [
|
|
'id' => $item['id'],
|
|
'title' => $item['title'],
|
|
'username' => $item['author'] ?? '',
|
|
'channel' => $item['cid'] ?? '',
|
|
'href' => '',
|
|
'crt' => $item['create_at'] ?? 0,
|
|
];
|
|
}, $list);
|
|
$this->result->success($data);
|
|
}
|
|
|
|
/**
|
|
* 系统进度 / 环境信息(真实数据)
|
|
*
|
|
* @return \think\Response
|
|
*/
|
|
public function prograss()
|
|
{
|
|
$data = [
|
|
['prograss' => 'PHP 版本', 'time' => PHP_VERSION, 'complete' => '已完成'],
|
|
['prograss' => 'ThinkPHP', 'time' => \think\facade\App::version(), 'complete' => '已完成'],
|
|
['prograss' => '安装状态', 'time' => is_file(root_path() . 'install.lock') ? '已安装' : '未安装', 'complete' => '已完成'],
|
|
['prograss' => '运行环境', 'time' => php_sapi_name(), 'complete' => '进行中'],
|
|
];
|
|
$this->result->success($data);
|
|
}
|
|
|
|
}
|