Index.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * lemocms
  4. * ============================================================================
  5. * 版权所有 2018-2027 lemocms,并保留所有权利。
  6. * 网站地址: https://www.lemocms.com
  7. * ----------------------------------------------------------------------------
  8. * 采用最新Thinkphp6实现
  9. * ============================================================================
  10. * Author: yuege
  11. * Date: 2019/8/2
  12. */
  13. namespace app\admin\controller;
  14. use app\admin\model\AuthRule;
  15. use app\common\controller\Backend;
  16. use think\facade\View;
  17. use think\facade\Db;
  18. use think\facade\Cache;
  19. use think\facade\Session;
  20. class Index extends Backend{
  21. public function initialize()
  22. {
  23. parent::initialize(); // TODO: Change the autogenerated stub
  24. }
  25. /**
  26. * @return string
  27. * @throws \Exception
  28. * 首页
  29. */
  30. public function index(){
  31. // 所有显示的菜单;
  32. $admin_id = Session::get('admin.id');
  33. $menus = Cache::get('adminMenus_'.$admin_id);
  34. $menus = '';
  35. if(!$menus){
  36. $cate = AuthRule::where('menu_status',1)->order('sort asc')->select()->toArray();
  37. $menus = Menu::authMenu($cate);
  38. Cache::set('adminMenus_'.$admin_id,$menus,'3600');
  39. }
  40. $href = (string)url('main');
  41. $home = ["href"=>$href,"icon"=>"fa fa-home","title"=>"首页"];
  42. $menusinit =['menus'=>$menus,'home'=>$home];
  43. View::assign('menus',json_encode($menusinit));
  44. return View::fetch();
  45. }
  46. /**
  47. * @return string
  48. * @throws \think\db\exception\BindParamException
  49. * @throws \think\db\exception\PDOException
  50. * 主页面
  51. */
  52. public function main(){
  53. // $version = Db::query('SELECT VERSION() AS ver');
  54. //// var_dump($version);die();
  55. // $config = Cache::get('main_config');
  56. // if(!$config){
  57. // $config = [
  58. // 'url' => $_SERVER['HTTP_HOST'],
  59. // 'document_root' => $_SERVER['DOCUMENT_ROOT'],
  60. // 'document_protocol' => $_SERVER['SERVER_PROTOCOL'],
  61. // 'server_os' => PHP_OS,
  62. // 'server_port' => $_SERVER['SERVER_PORT'],
  63. // 'server_ip' => $_SERVER['REMOTE_ADDR'],
  64. // 'server_soft' => $_SERVER['SERVER_SOFTWARE'],
  65. // 'server_file' => $_SERVER['SCRIPT_FILENAME'],
  66. // 'php_version' => PHP_VERSION,
  67. // 'mysql_version' => $version[0]['ver'],
  68. // 'max_upload_size' => ini_get('upload_max_filesize'),
  69. // ];
  70. // Cache::set('main_config',$config,3600);
  71. // }
  72. //
  73. // View::assign('config', $config);
  74. return View::fetch();
  75. }
  76. }