99 lines
2.4 KiB
PHP
99 lines
2.4 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace app\controller\manager;
|
||
|
|
||
|
use app\model\Overview;
|
||
|
use app\model\Spu;
|
||
|
use app\repository\CmsRepository;
|
||
|
use Exception;
|
||
|
use think\db\exception\DataNotFoundException;
|
||
|
use think\db\exception\DbException;
|
||
|
use think\db\exception\ModelNotFoundException;
|
||
|
use think\response\Json;
|
||
|
use think\response\View;
|
||
|
use app\model\Member;
|
||
|
use app\model\Menu;
|
||
|
|
||
|
class Index extends Base
|
||
|
{
|
||
|
protected $noNeedLogin = ['index', 'init'];
|
||
|
|
||
|
/**
|
||
|
* 后台初始页面 随后进入dashboard页面
|
||
|
*
|
||
|
* @return View
|
||
|
* @throws DataNotFoundException
|
||
|
* @throws DbException
|
||
|
* @throws ModelNotFoundException
|
||
|
*/
|
||
|
public function index(): View
|
||
|
{
|
||
|
$auth = session('auth');
|
||
|
$this->data['user'] = Member::findById($auth['user_id'] ?? 0, ['id', 'username', 'nickname', 'mobile']);
|
||
|
return $this->view();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 控制台
|
||
|
*
|
||
|
* @return Json|View
|
||
|
* @throws Exception
|
||
|
*/
|
||
|
public function dashboard()
|
||
|
{
|
||
|
if ($this->request->isPost()) {
|
||
|
|
||
|
return $this->json(0, '操作成功', []);
|
||
|
}
|
||
|
|
||
|
|
||
|
$this->data['count'] = 0;
|
||
|
return $this->view();
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 菜单初始化
|
||
|
*
|
||
|
* @return Json
|
||
|
*/
|
||
|
public function init(): Json
|
||
|
{
|
||
|
\think\facade\Config::load('extra/base', 'base');
|
||
|
$config = config('base');
|
||
|
|
||
|
$title = $config['admin_title'] ?: '大向天诚商城管理系统';
|
||
|
// $title = mb_strlen($title) > 3 ? mb_substr($title, 0, 3).'...' : $title;
|
||
|
|
||
|
|
||
|
$res = [];
|
||
|
$res['homeInfo'] = ['title' => '控制台', 'href' => "manager/index/dashboard"];
|
||
|
$res['logoInfo'] = [
|
||
|
'title' => $title,
|
||
|
'href' => "",
|
||
|
'image' => $config['logo'] ?: '/static/manager/image/logo.png'
|
||
|
];
|
||
|
|
||
|
$menus = CmsRepository::getInstance()->getMenuList(Menu::TYPE_MENU, Menu::SHOW_YES)->toArray();
|
||
|
$userId = $this->auth['user_id'] ?? 0;
|
||
|
$menus = CmsRepository::getInstance()->handMenuRule($userId, $menus);
|
||
|
$menus = CmsRepository::getInstance()->buildMenuChild(0, $menus, 'child');
|
||
|
$res['menuInfo'] = $menus;
|
||
|
|
||
|
return json($res);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 缓存清理
|
||
|
*
|
||
|
* @return Json
|
||
|
*/
|
||
|
public function clear(): Json
|
||
|
{
|
||
|
$res = ['code' => 1, 'msg' => '服务端清理缓存成功'];
|
||
|
sleep(2);
|
||
|
|
||
|
return json($res);
|
||
|
}
|
||
|
}
|