2020-01-01 13:17:19 +08:00
|
|
|
<?php
|
2022-08-02 20:48:54 +08:00
|
|
|
/*
|
|
|
|
* @Author: TaoLer <alipay_tao@qq.com>
|
|
|
|
* @Date: 2021-12-06 16:04:50
|
|
|
|
* @LastEditTime: 2022-05-12 16:02:40
|
|
|
|
* @LastEditors: TaoLer
|
|
|
|
* @Description: 搜索引擎SEO优化设置
|
|
|
|
* @FilePath: \TaoLer\app\common\controller\AdminController.php
|
|
|
|
* Copyright (c) 2020~2022 https://www.aieok.com All rights reserved.
|
|
|
|
*/
|
2020-01-01 13:17:19 +08:00
|
|
|
declare (strict_types = 1);
|
|
|
|
|
|
|
|
namespace app\common\controller;
|
|
|
|
|
|
|
|
use think\facade\Session;
|
|
|
|
use think\facade\View;
|
|
|
|
use think\facade\Db;
|
2021-02-01 15:51:32 +08:00
|
|
|
use think\facade\Request;
|
2020-02-12 17:20:07 +08:00
|
|
|
use taoser\think\Auth;
|
2020-03-05 20:15:01 +08:00
|
|
|
use taoler\com\Files;
|
2021-07-16 17:42:07 +08:00
|
|
|
use think\facade\Lang;
|
2020-01-01 13:17:19 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 控制器基础类
|
|
|
|
*/
|
2021-07-16 17:42:07 +08:00
|
|
|
class AdminController extends \app\BaseController
|
2020-01-01 13:17:19 +08:00
|
|
|
{
|
2021-12-15 15:46:04 +08:00
|
|
|
/**
|
|
|
|
* 初始化菜单
|
|
|
|
*/
|
2020-01-01 13:17:19 +08:00
|
|
|
protected function initialize()
|
|
|
|
{
|
|
|
|
//权限auth检查
|
2021-12-15 15:46:04 +08:00
|
|
|
$this->aid = Session::get('admin_id');
|
2020-01-01 13:17:19 +08:00
|
|
|
//$this->checkAuth();
|
|
|
|
$this->getMenu();
|
2021-03-19 14:38:06 +08:00
|
|
|
//系统配置
|
|
|
|
$this->getIndexUrl();
|
2020-01-01 13:17:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取侧边栏菜单
|
|
|
|
*/
|
|
|
|
protected function getMenu()
|
|
|
|
{
|
|
|
|
$menu = [];
|
2022-04-17 17:09:19 +08:00
|
|
|
$admin_id = $this->aid;
|
2020-01-01 13:17:19 +08:00
|
|
|
$auth = new Auth();
|
|
|
|
|
2022-04-17 17:09:19 +08:00
|
|
|
$auth_rule_list = Db::name('auth_rule')->where('delete_time',0)->where(['status'=> 1,'ishidden'=>1])->order(['sort' => 'asc'])->select();
|
2020-01-01 13:17:19 +08:00
|
|
|
//var_export($auth_rule_list);
|
|
|
|
|
|
|
|
foreach ($auth_rule_list as $value) {
|
|
|
|
if ($auth->check($value['name'], $admin_id) || $admin_id == 1) {
|
2022-04-17 17:09:19 +08:00
|
|
|
// 查询是否设置映射
|
|
|
|
// $map = array_search('admin',config('app.app_map'));
|
|
|
|
// //dump($map,$value);
|
|
|
|
// //stripos($value);
|
|
|
|
// if($map){
|
|
|
|
// $menu[] = strtr($value,'admin',$map);
|
|
|
|
// } else {
|
|
|
|
// $menu[] = $value;
|
|
|
|
// }
|
|
|
|
//dump($menu);
|
2020-01-01 13:17:19 +08:00
|
|
|
$menu[] = $value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$menu = !empty($menu) ? array2tree($menu) : [];
|
2021-12-15 15:46:04 +08:00
|
|
|
View::assign('menu', $menu);
|
2020-01-01 13:17:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取角色菜单
|
|
|
|
*/
|
2021-10-12 16:55:44 +08:00
|
|
|
protected function getMenus($type)
|
2020-01-01 13:17:19 +08:00
|
|
|
{
|
|
|
|
$menu = [];
|
2022-04-17 17:09:19 +08:00
|
|
|
$auth_rule_list = Db::name('auth_rule')->where('delete_time',0)->where(['status'=> 1])->where('type',$type)->order(['sort' => 'ASC', 'id' => 'ASC'])->select();
|
2020-01-01 13:17:19 +08:00
|
|
|
//var_export($auth_rule_list);
|
|
|
|
|
|
|
|
foreach ($auth_rule_list as $value) {
|
|
|
|
$menu[] = $value;
|
|
|
|
}
|
|
|
|
$menus = !empty($menu) ? array2tree($menu) : [];
|
|
|
|
//$menu2 = getTree($menu);
|
|
|
|
return $menus;
|
|
|
|
//return View::assign('menus', $menus);
|
|
|
|
}
|
|
|
|
|
2020-03-05 20:15:01 +08:00
|
|
|
//清除缓存Cache
|
2021-07-22 10:39:09 +08:00
|
|
|
public function clearSysCache()
|
2021-07-16 17:42:07 +08:00
|
|
|
{
|
2021-07-22 10:39:09 +08:00
|
|
|
//清理缓存
|
|
|
|
$atemp = str_replace('\\',"/",app()->getRootPath().'runtime/admin/temp/');
|
|
|
|
$itemp = str_replace('\\',"/",app()->getRootPath().'runtime/index/temp/');
|
|
|
|
$cache = str_replace('\\',"/",app()->getRootPath().'runtime/cache/');
|
|
|
|
Files::delDirAndFile($atemp);
|
|
|
|
Files::delDirAndFile($itemp);
|
|
|
|
Files::delDirAndFile($cache);
|
|
|
|
return true;
|
2020-03-05 20:15:01 +08:00
|
|
|
}
|
2021-03-19 14:38:06 +08:00
|
|
|
|
|
|
|
|
2020-01-01 13:17:19 +08:00
|
|
|
|
|
|
|
}
|