phuongitvn / yii2adminlte
为 Yii 2.0 框架提供的 AdminLTE 后端主题资源包
Requires
- almasaeed2010/adminlte: ^3.0.5
- yiisoft/yii2: 2.*
- yiisoft/yii2-bootstrap4: ~2.0.8
Requires (Dev)
Suggests
- cebe/yii2-gravatar: Display user icons
- rmrevin/yii2-fontawesome: Font icons
- dev-master / 3.x-dev
- 3.0.1
- 3.0.0
- 3.0.0-beta1
- 3.0.0-alpha1
- 2.7.0-beta1
- 2.6.2
- 2.6.1
- 2.6.0
- 2.5.0
- 2.5.0-rc1
- 2.4.4
- 2.4.3
- 2.4.2
- 2.4.1
- 2.4.0
- 2.4.0-rc1
- 2.4.0-beta1
- 2.3.4
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.0
- 2.0.0-beta1
- 2.0.0-alpha1
- 1.1.1
- 1.1.0
- 1.0.x-dev
- 1.0.0
- 0.2.0
- 0.1.0
- dev-develop
- dev-feature/default-options
- dev-feature/scrutinizer
- dev-feature/fix-64
- dev-feature/tests
- dev-feature/phundament-sidebar-update
This package is auto-updated.
Last update: 2024-09-12 16:34:42 UTC
README
基于 AdminLTE 的 Yii2 框架的后端 UI
此包包含一个为 Yii 2.0 框架注册 AdminLTE 用户界面 CSS 文件的 资源包。
CSS 文件通过 Yii 推荐的 fxp/composer-asset-plugin
v1.1.1 或更高版本安装。
安装
安装此扩展的首选方法是使用 composer。
安装 AdminLTE v2,请运行
composer require dmstr/yii2-adminlte-asset "^2.1"
安装 AdminLTE v1,请运行
composer require dmstr/yii2-adminlte-asset "^1"
常见问题解答
Web 字体使用
AdminLTE 在 2.4.0
中删除了 Web 字体的包含,因此您需要手动包含所需的字体,例如。
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
不建议在生产环境中通过 CDN 包含,请根据您项目的资源打包工作流程进行调整。
详细信息请见 #140。
升级
升级时,请参阅 AdminLTE 升级指南,了解您需要在视图中进行的调整。
Composer 安装
兼容性矩阵
对于其他 问题,请首先在 GitHub 上搜索。
快速入门
安装扩展后,您可以通过重新配置视图组件的路径映射来获得一个 预览。
'components' => [ 'view' => [ 'theme' => [ 'pathMap' => [ '@app/views' => '@vendor/dmstr/yii2-adminlte-asset/example-views/yiisoft/yii2-app' ], ], ], ],
对于 phd5 应用
'components' => [ 'view' => [ 'theme' => [ 'pathMap' => [ '@app/views' => '@vendor/dmstr/yii2-adminlte-asset/example-views/testing/app' ], ], ], ],
此资源包提供了布局和视图的示例文件(请参阅文件夹 examples/
),它们不应用于直接在 vendor/
文件夹中自定义。
因此,建议您将视图复制到您的应用程序中,并根据需要进行调整。
自定义
- 从
vendor/dmstr/yii2-adminlte-asset/example-views/yiisoft/yii2-app
(或其他主题)复制文件到@app/views
。 - 如果之前已添加,通过删除路径映射来删除您的应用程序中的自定义
view
配置。 - 编辑您的视图,遵循
vendor/almasaeed2010/adminlte/pages
的 html 标记
AdminLTE 插件
AdminLTE 插件的 资源 不包含在我们的 AdminLteAsset
中,但您可以在您的供应商目录下的 vendor/almasaeed2010/adminlte/plugins
中找到这些文件。因此,如果您想使用任何一个,我们建议您创建一个自定义包,其中列出您需要的插件文件。
use yii\web\AssetBundle; class AdminLtePluginAsset extends AssetBundle { public $sourcePath = '@vendor/almasaeed2010/adminlte/plugins'; public $css = [ 'chart.js/Chart.min.css', // more plugin CSS here ]; public $js = [ 'chart.js/Chart.bundle.min.js' // more plugin Js here ]; public $depends = [ 'dmstr\adminlte\web\AdminLteAsset', ]; }
由于此资源依赖于我们的 AdminLteAsset
,因此它是您必须注册的唯一资源,例如在您的 main.php
布局文件中。
自定义内容头部
如果您想使用AdminLTE的头部的本地DOM
<h1> About <small>static page</small> </h1>
那么您可以按照以下代码操作
/* @var yii\web\View $this */ $this->params['breadcrumbs'][] = 'About'; $this->beginBlock('content-header'); ?> About <small>static page</small> <?php $this->endBlock(); ?> <div class="site-about"> <p> This is the About page. You may modify the following file to customize its content: </p> <code><?= __FILE__ ?></code> </div>
左侧边栏菜单 - 小部件菜单
如果您需要将菜单的部分进行分离,只需在items
中的项添加header
选项
'items' => [ ['label' => 'Gii', 'iconType' => 'far' 'icon' => 'file-code', 'url' => ['/gii']], ['label' => 'Debug', 'icon' => 'dashboard-alt', 'url' => ['/debug']], ['label' => 'MAIN NAVIGATION', 'header' => true], // here // ... a group items ['label' => '', 'header' => true], // ... a group items ['label' => '', 'header' => true], // ... a group items
为项目添加徽章
'items' => [ [ 'label' => 'Mailbox', 'iconType' => 'far', 'icon' => 'envelope', 'url' => ['/mailbox'], 'badge' => '<span class="badge badge-info right">123</span>' ], ]
默认情况下,图标将添加Font Awesome的前缀
用于Gii CRUD生成器的模板
告诉Gii关于我们的模板。设置在配置文件中完成
if (YII_ENV_DEV) { $config['modules']['gii'] = [ 'class' => 'yii\gii\Module', 'generators' => [ // HERE 'crud' => [ 'class' => 'yii\gii\generators\crud\Generator', 'templates' => [ 'adminlte' => '@vendor/dmstr/yii2-adminlte-asset/gii/templates/crud/simple', ] ] ], ]; }
测试
进入测试文件夹并启动测试栈
cd tests
docker-compose up -d
在测试应用程序中安装yii2-adminlte-asset
docker-compose exec php composer install
在您的浏览器中打开测试URL
http://docker.local:20580/test
http://docker.local:20580/test/login
更多信息
有关AdminLTE文档,请阅读https://almsaeedstudio.com/themes/AdminLTE/documentation/index.html
命名空间规则遵循Yii 2.0框架结构,例如Asset Bundle的
dmstr\adminlte\web
。