企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 快速搭建一个用户中心,只需一杯茶的功夫! ## 第一步,建立自己的模块(user)目录。 ``` application --user --controller --model --view ``` ## 第二步 建立用户模块入口控制器。 #### 在 controller 目录下建立 User.php,在model目录下建立UserAdminData.php(可自定义名称) ``` 在 controller 目录下建立 User.php application --user --controller -- User.php --model -- UserAdminData.php --view ``` > UserAdminData.php负责用户中心数据设置,比如左侧的导航等。必须实现*ILeftAndTopData*接口 ## *ILeftAndTopData*接口负责实现框架的基础数据 ![screen] ```php <?php namespace app\user\model; use think\facade\Url; use wslibs\i\epiiadmin\ILeftAndTopData; class UserAdminData implements ILeftAndTopData { public function __construct($args=[]) { } public function getLeftTopData()//获取左上侧数据 { return ["user_avatar" => STATIC_URL_ROOT . "/img/user2-160x160.jpg", "user_name" => "Alexander Pierce", "site_logo" => STATIC_URL_ROOT . "/img/AdminLTELogo.png", "site_name" => "管理中心", "site_url" => Url::build(), ]; } public function getLeftMenuData()//获取导航数据 { // TODO: Implement getLeftMenuData() method. return [ ["id" => 1, "name" => "仪表盘", "url" => "http://www.baidu.com", "icon" => " fa fa-dashboard", "pid" => 0], ["id" => 9, "name" => "demo1", "url" => url("demo/index/demo1", ['html' => "simple"]), "icon" => " fa fa-circle-o", "pid" => 1, "badge" => "new"], ["id" => 2, "name" => "仪表盘1", "url" => url("demo/index/showhtml", ['html' => "simple"]), "icon" => " fa fa-circle-o", "pid" => 1, "badge" => "new"], ["id" => 3, "name" => "仪表盘2", "url" => url("demo/index/showhtml", ['html' => "data"]), "icon" => " fa fa-circle-o", "pid" => 1], ["id" => 4, "name" => "仪表盘3", "url" => "http://www.baidu.com", "icon" => " fa fa-circle-o", "pid" => 1], ["id" => 5, "name" => "小组件", "url" => "http://www.baidu.com", "icon" => " fa fa-th", "pid" => 0, "badge" => "hot", "badge_class" => "badge badge-info"], ["header" => 1, "title" => "其它设置", "after_id" => 5], ["id" => 6, "name" => "验证测试", "url" => url("demo/index/showhtml", ['html' => "validate"]), "icon" => " fa fa-circle-o text-danger", "pid" => 0], ["id" => 7, "name" => "关于我们", "url" => "http://www.baidu.com", "icon" => " fa fa-circle-o text-info", "pid" => 0], ["id" => 8, "name" => "联系我们", "url" => "http://www.baidu.com", "icon" => " fa fa-circle-o text-waring", "pid" => 0], ]; } public function getTopRightNavs()//获取右上侧数据 { // TODO: Implement getTopNoticeData() method. return [\app\demo\controller\Notice::class, \app\demo\controller\chat::class, ]; } public function getTheme()//获取主题 { // TODO: Implement getTheme() method. //primary warning info danger success return "danger"; } public function getLeftMenuTheme()// 获取左侧导航主题 dark or light { // TODO: Implement getLeftMenuTheme() method. return "light"; } } ``` ## 第三步 显示界面。 User.php内容 ```php <?php namespace app\user\controller; use app\epiiadmin\controller\EpiiController; class User extends EpiiController//框架Controller基类 { public function index() { return $this->showTopWindow(new \app\user\model\UserAdminData()); } } ?> ``` 大功告成,访问http://hostname/user/user/index 即可显示界面。 在任何一个action中,使用以下方法即可显示前台框架页面。 ``` return $this->showTopWindow(ILeftAndTopData $dataProvider); ``` [screen]:https://epii.gitee.io/epiiadmin-js/img/screen1.png