Commit b417470e authored by rlgy's avatar rlgy

redis cache&menu fixed

parent 8466f078
...@@ -134,7 +134,8 @@ class MenuController extends BaseController ...@@ -134,7 +134,8 @@ class MenuController extends BaseController
$lists = Menu::find()->orderBy('sort asc')->where(['hide' => 0])->asArray()->all(); $lists = Menu::find()->orderBy('sort asc')->where(['hide' => 0])->asArray()->all();
$lists = ArrayHelper::list_to_tree($lists, 'id', 'pid'); $lists = ArrayHelper::list_to_tree($lists, 'id', 'pid');
$lists = ArrayHelper::jstree($lists); $lists = ArrayHelper::jstree($lists);
echo json_encode($lists); Yii::$app->response->format='json';
return $lists;
} }
/** /**
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
\backend\assets\TreeAsset::register($this); \backend\assets\TreeAsset::register($this);
?> ?>
<div class="portlet light portlet-fit portlet-datatable bordered"> <div class="portlet light portlet-fit portlet-datatable bordered">
<div class="portlet-title"> <div class="portlet-title">
<div class="caption"> <div class="caption">
<i class="fa fa-tree font-dark-sunglo"></i> <i class="fa fa-tree font-dark-sunglo"></i>
...@@ -18,18 +18,18 @@ ...@@ -18,18 +18,18 @@
</div> </div>
</div> </div>
</div> </div>
<!-- 定义数据块 --> <!-- 定义数据块 -->
<?php $this->beginBlock('test'); ?> <?php $this->beginBlock('test'); ?>
jQuery(document).ready(function() { jQuery(document).ready(function() {
$("#tree_3").jstree({ $("#tree_3").jstree({
"plugins" : [ "themes", "state", "types"], "plugins" : [ "themes", "state", "types"],
"core" : { "core" : {
'multiple' : false, 'multiple' : false,
'data': { 'data': {
"url" : "<?=yii\helpers\Url::toRoute('/menu/tree');?>", "url" : "<?= yii\helpers\Url::toRoute('/menu/tree'); ?>",
"dataType" : "json" "dataType" : "json"
}, },
}, },
...@@ -42,7 +42,7 @@ jQuery(document).ready(function() { ...@@ -42,7 +42,7 @@ jQuery(document).ready(function() {
console.log(currentNode); console.log(currentNode);
}); });
}); });
<?php $this->endBlock() ?> <?php $this->endBlock() ?>
<!-- 将数据块 注入到视图中的某个位置 --> <!-- 将数据块 注入到视图中的某个位置 -->
<?php $this->registerJs($this->blocks['test'], \yii\web\View::POS_END); ?> <?php $this->registerJs($this->blocks['test'], \yii\web\View::POS_END); ?>
\ No newline at end of file
...@@ -70,14 +70,12 @@ return [ ...@@ -70,14 +70,12 @@ return [
], ],
], ],
'cache' => [ 'cache' => [
'class' => 'yii\caching\FileCache', 'class' => 'yii\redis\Cache',
], 'redis' => [
// 'cache' => [ 'hostname' => 'localhost',
// 'class' => 'yii\redis\Connection', 'port' => 6379,
// 'hostname' => 'localhost', ],
// 'port' => 6379, ],
// 'database' => 0,
// ],
'i18n' => [ 'i18n' => [
'translations' => [ 'translations' => [
'*' => [ '*' => [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment