感觉corethink把thinkphp的思想复用到淋漓尽致。
1.把opencmf.php文件配置好了后台该模块的菜单就能在安装后自动读取(分析好父子关系,否则页面死循环,apache资源占用率100%)
Equip/opencmf.php
<?php // 模块信息配置 return array( // 模块信息 ‘info‘ => array( ‘name‘ => ‘Equip‘, ‘title‘ => ‘设备‘, ‘icon‘ => ‘fa fa-newspaper-o‘, ‘icon_color‘ => ‘#9933FF‘, ‘description‘ => ‘设备模块‘, ‘developer‘ => ‘pangPython‘, ‘website‘ => ‘http://www.opencmf.cn‘, ‘version‘ => ‘1.0.0‘, ‘dependences‘ => array( ‘Admin‘ => ‘1.1.0‘, ), ), // 用户中心导航 ‘user_nav‘ => array( ), // 模块配置 ‘config‘ => array( ), // 后台菜单及权限节点配置 ‘admin_menu‘ => array( ‘1‘ => array( ‘id‘ => ‘1‘, ‘uid‘ => ‘0‘, ‘title‘ => ‘设备‘, ‘icon‘ => ‘fa fa-newspaper-o‘, ), ‘2‘ => array( ‘pid‘ => ‘1‘, ‘title‘ => ‘设备管理‘, ‘icon‘ => ‘fa fa-folder-open-o‘, ), ‘3‘ => array( ‘pid‘ => ‘2‘, ‘title‘ => ‘设备配置‘, ‘icon‘ => ‘fa fa-wrench‘, ), ‘4‘ => array( ‘pid‘ => ‘2‘, ‘title‘ => ‘设备类型‘, ‘icon‘ => ‘fa fa-th-large‘, ), ), );
2.让页面自动构建表格
在Equip目录下的Admin目录下建立IndexAdmin.class.php
这个文件继承AdminController,AdminController实现了登录权限检测,自动读取后台模块左侧导航栏,而AdminController继承了CommonController,CommonController实现了模板显示功能,CommonController继承了Controller
Equip/Admin/IndexAdmin.class.php
<?php namespace Equip\Admin; use Admin\Controller\AdminController; use Common\Util\Think\Page; class IndexAdmin extends AdminController{ public function index(){ //使用Builder快速建立列表页面 $builder = new \Common\Builder\ListBuilder(); $builder->setMetaTitle(‘设备管理‘) //设置页面标题 ->addTableColumn(‘id‘, ‘ID‘) ->addTableColumn(‘create_time‘, ‘设备名称‘, ‘time‘) ->addTableColumn(‘sort‘, ‘排序‘, ‘text‘) ->addTableColumn(‘status‘, ‘状态‘, ‘status‘) ->addTableColumn(‘right_button‘, ‘操作‘, ‘btn‘) ->setExtraHtml(‘<div class="alert alert-success">请点击左侧的列表树进行操作</div>‘) ->display(); } }
此时再安装模块,就能正常显示页面了
效果图logo已打码
时间: 2024-10-02 06:31:26