it-yakutia / yii2-materialadmin
Yii2 的 Material Admin 模块
v1.0.7
2023-02-26 04:23 UTC
Requires
- it-yakutia/yii2-rbac: ~1.0.0
- it-yakutia/yii2-setting: ~1.0.0
- uraankhayayaal/yii2-materializecomponents: ~1.0.1
- uraankhayayaal/yii2-redactor: ~1.0.0
- uraankhayayaal/yii2-sortable: ~1.0.1
- yiisoft/yii2: ~2.0.0
README
Yii2 的 Material Admin 模块
安装
安装此扩展的首选方式是通过 composer。
可以运行
php composer.phar require --prefer-dist it-yakutia/yii2-materialadmin "*"
或者添加
"it-yakutia/yii2-materialadmin": "*"
到您的 composer.json
文件的 require 部分。
使用方法
扩展安装完成后,只需将其添加到您的 backend
配置
... 'layoutPath' => '@vendor/it-yakutia/yii2-materialadmin/src/views/layouts', 'components' => [ ... ],
扩展安装完成后,使用此 SiteController
为 backend
/** * Site controller */ class SiteController extends Controller { /** * {@inheritdoc} */ public function behaviors() { return [ 'access' => [ 'class' => AccessControl::className(), 'rules' => [ [ 'actions' => ['login', 'error'], 'allow' => true, ], [ 'actions' => ['logout', 'index'], 'allow' => true, 'roles' => ['@'], ], ], ], 'verbs' => [ 'class' => VerbFilter::className(), 'actions' => [ 'logout' => ['post'], ], ], ]; } /** * @inheritdoc */ public function actions() { return [ 'error' => [ 'class' => 'yii\web\ErrorAction', 'layout' => 'empty' ], ]; } /** * Displays homepage. * * @return string */ public function actionIndex() { return $this->render('index'); } public function actionLogin() { return $this->redirect(['/materialadmin/profile/login']); } }
扩展安装完成后,只需将其添加到您的 console
配置
'controllerMap' => [ ... 'faker' => [ 'class' => \ityakutia\materialadmin\commands\FakerController::class, ], 'migrate' => [ 'class' => MigrateController::class, 'migrationPath' => [ ... '@ityakutia/materialadmin/migrations', ], ], ]
为 @backend/views/layout/_sidenav
创建自定义导航项
<?php use yii\helpers\Url; ?> <?php if(Yii::$app->user->can("costom_modules")) { ?> <li><a class="subheader grey-text"><i class="material-icons grey-text tiny">public</i> <?= Yii::t('app', 'Мои модули')?></a></li> <?php } ?> <?php if(Yii::$app->user->can("costom_module")) { ?> <li class="<?= (Yii::$app->controller->module->id=='costom_module' && Yii::$app->controller->id=='back')?'active':''; ?>"><a class="waves-effect waves-teal" href="<?= Url::toRoute('/costom_module/back/index') ?>"><i class="material-icons">pageview</i> <?= Yii::t('app', 'Мой модуль') ?></a></li> <?php } ?>
设置自定义标志,只需将其添加到您的 backend
参数
'materialadmin_module' => [
'custom_assets' => [
'logo_favicon' => '/admin/images/logo_favicon.png',
'logo_sidenav' => '/admin/images/logo_sidenav.png',
'logo_login' => '/admin/images/logo_login.png',
],
],