# 快速搭建一個用戶中心,只需一杯茶的功夫!
## 第一步,建立自己的模塊(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
- 簡介/安裝
- 快速搭建一個用戶中心
- Js代碼寫在哪里
- 環境變量Args
- 前臺組件
- Dialog方式打開頁面
- Addtab方式打開頁面
- Alert提醒框
- Confirm確認框
- Prompt輸入框
- 表單Form
- 列表Table/list
- 基礎Table
- 控制Table
- 搜索Table
- 城市選擇city-picker
- 文件上傳組件
- 基礎版本
- 簡單版本
- 更多實用組件
- 后臺
- 實現方式綜述
- 命令管理類JsCmd
- 命令
- Alert命令
- Url命令
- Toast命令
- JsEval命令
- Close命令
- Refresh命令
- CloseAndRefresh命令
- 常用命令的簡化
- 文件上傳
- 后臺基礎
- 后臺進階
- 左側導航badge配置