application/admin/controller/Base.php

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php
//声明当前控制器的目录位置
namespace app\admin\controller;
//use think\Request;
use think\auth\Auth;
use app\admin\controller\Core;
//加载TP定义的控制器类,方便继承。
//use think\Controller;
use app\admin\model\AuthRule;
use think\Session;
//use app\admin\lib\lang\Hylang;

// //加载数据库类,方便直接用其工具。think相当于之前用于二开的lib类库
// public:权限是最大的,可以内部调用,实例调用等。
// protected: 受保护类型,用于本类和继承类调用。
// private: 私有类型,只有在本类中使用。
//一个类 默认对应 view视图文件夹的 index 文件夹,也代表一个TP所称的控制器
class Base extends Core {
   
    protected function _initialize() {
       //检测是否登录
       $this->check_logged();
        //检查访问权限
        $this->check_auth();
        
        //输出页面语言包
        $this->assign('cn',$this->hy_lang());
//        //当前用户uid
         $uid = Session::get('uid');
          $this->assign('uid', $uid);
//         //当前用户名
         $username = Session::get('username');
          $this->assign('username', $username);
        //页面控制器
        $controller=request()->controller();
        //页面操作
        $action=request()->action();
        //输出页面控制器英文名
        $this->assign('controller',$controller);
        //输出页面操作英文名
        $this->assign('action', $action);

        //输出页面控制器中文名
       //继承base的页面一定Hylang.php里声明。要在如果在Hylang.php里没有 该$controller中文名会出错,ajax调用也会出错。
        //echo $controller;
         $c_name=$this->hy_lang($controller);
         //echo $c_name;
         $this->assign('c_name', $c_name);
        //输出页面操作中文名
        $a_name=$this->hy_lang(request()->action());
        $this->assign('a_name', $a_name);
        
//        $this->assign('f_title', $this->hy_lang('admin_manage'));
//        $this->assign('p_title', $this->hy_lang('admin_list'));//这里想办法换成能表示页面的
        //检查当前页面是否已经加入控制器
        $route=$controller."-".$action;
        $route_auth_id=AuthRule::where('name',$route)->value('id');
         $this->assign('route_auth_id',$route_auth_id);
         
      // request()->instance()->bind('controller',request()->controller());
后面还有 49 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。